Code reverts to old version when reopening editor

My C++ code seems to revert to an older version whenever I close and reopen the editor.

I have to hot reload the code once in order to get the editor to recognize the current code.

(Using 4.7.3)

The editor doesn’t load a module built for hot-reload if you close and re-open it.

If you’ve been hot-reloading your code, you’ll need to build again after closing the editor to update the module the editor loads, and also to clear out any stale hot-reload modules.

I see, that explains a lot!

I’m still having trouble getting the project to update to the current code when reopened. Here’s what I did:

  1. Open editor

  2. Change the code a bit, and build (F6)

  3. Hot reload correctly shows changes to code

  4. Close editor

  5. Build again after a small change to force update (F6) - I also tried doing a full clean/rebuild in this step

  6. Re-open editor

Is there something special that need be done to “update the module the editor loads”?

There shouldn’t be anything special that needs to be done.

Could you check that your build after closing the editor is definitely not building for a hot-reload.

The following should be absent from the output in VS: Compiling game modules for hot reload, and you should instead see something like this: Deleting old hot reload file.

Here’s the VS output for closed vs open compliation:

Editor closed:

1>------ Build started: Project: MonsterGame, Configuration: DebugGame_Editor x64 ------
2>------ Skipped Build: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------
2>Project not selected to build for this solution configuration 
1>  Parsing headers for MonsterGameEditor
1>  Reflection code generated for MonsterGameEditor
1>  Performing 8 actions (4 in parallel)
1>  MonsterGame.generated.cpp
1>  SharedAPI.cpp
1>  EventManager.cpp
1>  [8/8] Link UE4Editor-MonsterGame-Win64-DebugGame.dll
1>     Creating library ...\Build\Win64\MonsterGameEditor\DebugGame\UE4Editor-MonsterGame-Win64-DebugGame.lib and object ...\Build\Win64\MonsterGameEditor\DebugGame\UE4Editor-MonsterGame-Win64-DebugGame.exp
1>  -------- End Detailed Actions Stats -----------------------------------------------------------
1>  Cumulative action seconds (4 processors): 0.00 building projects, 4.94 compiling, 0.00 creating app bundles, 0.00 generating debug info, 0.73 linking, 0.00 other
1>  UBT execution time: 20.12 seconds
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 1 skipped ==========

And with the editor open:

1>------ Build started: Project: MonsterGame, Configuration: DebugGame_Editor x64 ------
2>------ Skipped Build: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------
2>Project not selected to build for this solution configuration 
1>  Compiling game modules for hot reload
1>  Parsing headers for MonsterGameEditor
1>  Reflection code generated for MonsterGameEditor
1>  Performing 8 actions (4 in parallel)
1>  MonsterGame.generated.cpp
1>  ServerAPI.cpp
1>  EventManager.cpp
1>  [8/8] Link UE4Editor-MonsterGame-3592-Win64-DebugGame.dll
1>     Creating library ...\Build\Win64\MonsterGameEditor\DebugGame\UE4Editor-MonsterGame-3592-Win64-DebugGame.lib and object ...\Build\Win64\MonsterGameEditor\DebugGame\UE4Editor-MonsterGame-3592-Win64-DebugGame.exp
1>  -------- End Detailed Actions Stats -----------------------------------------------------------
1>  Cumulative action seconds (4 processors): 0.00 building projects, 9.11 compiling, 0.00 creating app bundles, 0.00 generating debug info, 2.75 linking, 0.00 other
1>  UBT execution time: 24.59 seconds
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 1 skipped ==========

Those both look correct to me.

How do you run the editor after you’ve built? Via Visual Studio, by double clicking the .uproject file, or via some other method?

Thanks.

I notice you’re building the “DebugGame Editor” configuration, however opening your project via the launcher, or via double clicking the .uproject file in explorer, will always run the “Development Editor” configuration.

If you’re already building via Visual Studio and want to continue to use the “DebugGame Editor” configuration, you may just want to start your editor via Visual Studio. If you use Ctrl+F5 the editor will start without attaching the debugger so you’ll still be able to use hot-reload via VS. Alternatively you could just build the “Development Editor” configuration until you actively need to debug your game.

I’ve been running it via the Epic Games Launcher

That seems to have done it! Many thanks!

I am using Visual Studio 2017 community edition. Also, I am launching an Unreal editor (Ctrl+F5) from visual studio. For some unknown reasons I am unable to see C++ class inside Classes not showing up in content browser. Any help will be very much appreciated.

Is it definitely a UObject based class? The Content Browser can only show you UObject based classes since those are the only ones we generate reflection data for.