C++ and Live Coding

When programming with C++, I understood I can use Live Coding to get my code compiled and ready to use in the editor. However, when I close the project and reopen it, everything is gone, leading me to recompile with Live Coding, but the changes I made are gone, having to close the Unreal Editor and compile the code in my IDE of choice.
After this, the code changes appear right away and with the changes, I made in the Unreal Editor.

My question is, do I have to compile the code in my IDE of choice every time I close the Unreal project, in order to keep these changes and have them once I open the Unreal Editor the next time?

No, you should not have to recompile your code in your IDE every time you close the Unreal project. Once you have used Live Coding to compile your code in the Unreal Editor, the changes should persist and be available the next time you open the project.

It’s possible that the problem you’re experiencing is related to how you’re saving your code. Here are a few things to check:

  • Make sure you’re saving your code changes in the Unreal Editor by going to File > Save All or by using the keyboard shortcut Ctrl + Shift + S.
  • Make sure you’re saving your code changes to the correct location, such as the project’s source folder.
  • Verify that you have the correct version of the engine and the plugin for Live Coding, as well as the correct versions of the development tools you are using.
  • Check if there is any plugin or add-on that is causing the problem, try disabling them and see if the problem persists.
  • If none of the above steps help, try creating a new C++ class in the Unreal Editor and see if the changes persist after closing and reopening the project.
1 Like

Unfortunately, this happens from time to time. When this happens, I close UE5 and ‘rebuild’ the project in Visual Studio. Once rebuilt, I let Visual Studio reopen the project again. Afterwards, the project should be working as intended.

I’m not exactly sure why this happens, but I have gotten into the habit of opening UE5 via Visual Studio, instead of opening the project directly from UE5.

I started learning Unreal and am learning the basics and so on from a Udemy course and it was explained to me that this would happen, so I was wondering if this was really needed (to compile in the IDE after closing Unreal).
I will look into it again and try to record what happens.
Thanks!

This has been happening to me, while I do it the other way, I open Unreal, and then my editor (Rider), but I can’t seem to keep the changes… I will try to record a clip of it and share it via a youtube link.
Thank you!

Yes, this is how it works.

When Live Coding, the game cannot replace the DLL files that it is linking into, it has to create new ones, and then switch to them.

When you are done with your session, or when you start your next session, you will need to build again so that the regular DLL files are updated.

3 Likes

btw, imo, if you’re coding, just always launch from visual studio Debug->Start (with debugging if you’re going to be using debugger, without otherwise) and it will build for you if any code is out of date before launching.

i just now realized that that’s probably what people who don’t automatically understand this issue are hitting – they probably launch the editor from epic launcher or command line or something, rather than from visual studio … so it doesn’t make obvious sense when the code isn’t automatically updated.

launching from visual studio will always keep the code in sync when possible.

2 Likes

So you mean I should open Visual Studio and then open Unreal from there? I might have misunderstood so I just wanna make sure.
Well then the main problem is solved I believe, since I’ll have to do it as I explained it happened.

Also, when packaging, do I need to close the editor and build the solution? Or will it compile before the packaging?

that is how i’ve always done it (i’ve also always used full source builds, so i’m not entirely certain if there’s an obstacle to doing that if you aren’t using full engine source builds) …

Open Visual Studio, use one of the Debug->Start options. Live Coding trigger is Ctrl-Alt-F11 i think, and if you do that, the next time you launch from VS, if code is out of sync with the DLLs it will build before it launches

1 Like