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:
- Start the editor from my game’s VS project (with the debugger attached, built in DebugGame Editor mode)
- Play the game in the editor, hitting breakpoints in the code, etc.
- Make code changes
- Hit Restart in VS
- Wait for the code to build
- Wait for the editor to restart (reliably the longest wait in this cycle)
- 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:
- Start the editor from my game’s VS project
- Play the game in the editor
- Make code changes
- Hit Compile in the editor
- Wait for the code to build
- 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:
- In the Tick function of a subclass of Actor, break if Tags.Num() == 1, else if Tags.Num() == 0, break.
- Build the game in Visual Studio
- Open editor
- Play, then spawn that object
- The breakpoint for no tags will be hit
- Edit the constructor to add the tag “Tag 1” to that Actor
- Hit the Compile button in the Editor
- Play, then spawn that object
- The breakpoint for no tags will be hit.
- Close the editor, then restart it
- Play, then spawn the object
- 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?