Details
We'll be enabling live reload of C++ code in Unreal Engine 5 and Visual Studio.
With our C++ project open. Go to the menu Edit > Edit Preferences. From there we could change our source code editor to from Visual Studio to Visual Studio Code or to CLion. However, for this video we'll be keeping it with Visual Studio.
Next go to the Liv Coding menu under General. Here we can enable the live coding hot reload functionality. Once enabled we'll get the Live Coding window which will allow us to restart the editor and will handle all C++ code change recompiles.
Currently Live Reload supports changes made to gameplay implementation code. Specifically functions within the .cpp file.
This means that any changes made to a classes private variables, function declarations, constructors or destructors, along with any macros still require a full recompile.
To ensure Live Reload is working, lets make a simple change to the cursor location within our `ue5testHUD.cpp` file in the `DrawHUD()` function. Lets move the Y position down the screen and set it to `0.9f`.
Since we just enabled live reload lets shutdown the editor and then relaunch the editor via Visual Studio's `Local Windows Debugger`. This will allow live reload to work properly.
Once restarted we see the cursor has move down near the bottom of the screen. Now lets change the cursor back to the center of the screen by changing the Y value back to `0.5f`. Then press `Ctrl + Alt + F11` to recompile and live reload without having to recompile the entire project.
Once live reload is complete we can see the cursor has moved back to the center of the screen as we wanted without having to recompile the entire project. With live reload enabled we can now rapidly iterate on gameplay functionality and tweak it until it feels right instead of having to recompile the entire editor and game each time to test new tweaks.