Is there a clear definition on how Hot Reload is supposed to work?

I just wasted a solid 90 minutes debugging an extremely weird problem I had that wasn’t even actually a problem because Hot Reload didn’t work how I thought it would.

My old, reliable, crappy workflow was:

  1. Start the editor from my game’s VS project (with the debugger attached, built in DebugGame Editor mode)
  2. Play the game in the editor, hitting breakpoints in the code, etc.
  3. Make code changes
  4. Hit Restart in VS
  5. Wait for the code to build
  6. Wait for the editor to restart (reliably the longest wait in this cycle)
  7. Play in editor to test code change

That sucked because of the downtime of waiting for the editor to load each time. I asked IRC and someone mentioned that I could just hit the big Compile button in the editor after making my changes to test them without having to restart the whole thing. So my new, awesome workflow is:

  1. Start the editor from my game’s VS project
  2. Play the game in the editor
  3. Make code changes
  4. Hit Compile in the editor
  5. Wait for the code to build
  6. Play in editor to test code change

Except I had an issue of code not acting the way I thought it would. I would add code in multiple parts of a file, and only certain changes would actually be reflected upon hot reloading.

Steps to reproduce:

  1. In the Tick function of a subclass of Actor, break if Tags.Num() == 1, else if Tags.Num() == 0, break.
  2. Build the game in Visual Studio
  3. Open editor
  4. Play, then spawn that object
  5. The breakpoint for no tags will be hit
  6. Edit the constructor to add the tag “Tag 1” to that Actor
  7. Hit the Compile button in the Editor
  8. Play, then spawn that object
  9. The breakpoint for no tags will be hit.
  10. Close the editor, then restart it
  11. Play, then spawn the object
  12. The breakpoint for 1 tag will be hit.

It really sucks that, on any given code edit, anything going a way I don’t expect could actually just be hot reload ******** up rather than my doing something wrong. But according to folks in #unrealengine, you pretty much have to accept that with this feature. Is this really the case?

It can be unpredictable, I agree. What I tend to do is just launch the editor and VS separately. I compile in VS (takes about 8-10 seconds), then just switch to the editor and play from there. Most of the time that works fine for me. Occasionally it will fail to update a certain class. One of the big things in particular is if you make changes to a class that you already have a blueprint of - the members in the blueprint may not reflect the code changes.

If I find that something isn’t working that should, then I just shut down the editor, then compile (which deletes the old hot-reload libraries) and then restart the editor. That has proven (almost) fool-proof for me.

As far as I can tell, it won’t work if you make changes to reflected data (e.g. add new UPROPERTY() etc.) but as long as you just change function definitions or edit existing properties you should be good to go.

you can also Detach the editor from VS, then you can hot-reload it by compiling from VS.

I find that it works almost perfectly when you’re only making .cpp changes, except in the case of anything UMG related which doesn’t seem to hotreload correctly at all.

Any changes to Header files seem less likely to work. I usually just hit the restart button at that point. Iteration is still relatively fast, the header compile time is the killer for me.