I am currently trying to learn Unreal Engine and having a great time doing so, but running into some issues with crashes. I am strictly using C++ right now with Visual Studio 2019. The problem I’m facing is that every time I open up my project, all of the new C++ classes I created are erased from the editor.
To be clear, the flow to create the classes went like this:
- New C++ Class from within the Editor
- New Actor Class
- Give it a Static Mesh, Sphere Component, and Projectile Movement Component
Now, after all this, I created a blueprint in the editor based on this new class and I have modified it and played around with it in the editor. However, whenever I close the project, or if the project crashes - when I open the editor back up, the C++ class has disappeared from the editor.
In order for me to get this class back, I have to hit Ctrl+Alt+F11 and start “Live Coding”. The problem with that is, if I don’t comment out certain parts of code, the editor crashes during the reload. The funny thing with THAT is the code that causes the editor to crash has nothing to do with the new C++ class, no references or anything.
The code that needs to be commented:
- OnOverlapBegin and OnOverlapEnd (the standard function declarations for these in header and cpp)
*Same thing except OnOverlapEnd
If those lines of code are not commented, the editor crashes. I really would like a solution that stops me from having to recompile in order to get my same blueprints back, and also stops me from having to comment code to successfully recompile.
I hope this makes sense, thank you!
I had the problem too (Classes disappearing in Editor and compile errors which stated that some references are missing). My solution was: close the Unreal Editor and do a clean rebuild from the IDE. After that, the editor also displayed all classes correctly again and the errors are gone. You additionally can try to rebuild the .sln if this doesn’t work for.
Since I use Rider as IDE, I hope that this can also be transferred to Visual Studio.
I hope this works for you too
To be honest my first instinct was to turn off Live Coding but I was unsure how this would effect my project.
If you turn it off does it just default back to being able to compile from the IDE itself?
I will try this when I get home from work and update you guys.
Thank you for the suggestion. I will try this solution later today and update you guys.
I do have a question for you regarding this - if I do a clean rebuild of my project in the IDE, how exactly does the editor get modified when it is closed?
Sure, you can simply disable Live Coding. It shouldn`t take any effect on your project. After that you have to shutdown Unreal for every code change and rebuild in the IDE.
Unreal Editor loads your compiled code in form of a shared lib (i.E. on windows its a .DLL) and references the functions defined within (wiring it up with engine events). When you use Live Coding and start compiling from the Editor it compiles a new library and patches/switches the previous library in memory. The last build library will be referenced every time you start your project in Unreal Editor.
Hey thank you for the explanation and for the tip! IT WORKED! It even fixed some bugs lol. I guess it’s obvious that rebuilding should fix things but thank you for pointing it out.
My only question now is how do I compile code changes if they’re minimal? For instance I take out a couple lines or I add a few variables, I need to close and rebuild every time?
I’m glad it’s working now. As far as i know, without Live Coding you need to close Unreal Editor every time you make changes to your code and recompile it in the IDE. In earlier versions of Unreal (4.x) there also was a “predecessor” to Live Coding called Hot Reload but it was very error prone since it was able to do weird stuff with your blueprints.
If you use Live Coding you only have to reload the editor if you make any changes to header files or constructors in your project. (further informations: Hot Reload and Live Coding | Unreal Engine Community Wiki)
For me Live Coding works quite well and is a huge time saver.
Oh wow, I didn’t know you only had to reload the editor after .h or constructor modifications. I was doing it after all code changes.
When you say reload you mean the Ctrl+Alt+F11 right?
Maybe I will turn Live Coding back on and if it errors just do the reload from the IDE again. Either way, I appreciate your help and all the information.
I had the exact sam issue with vanishing classes. UE5.01 and VS 2022
Actually i couldnt make any classes at all…
But disabling Live Coding worked for me too.
Just wondering why its working for others
YEEES, solved the problem!!! it was irritating!
1st time posting in forum
What did you do to make this work?
I’ve been using Live Coding for months, but now upgraded my Visual Studio 2022 to newer 2022 and it stopped working (also uninstalled an old Visual Studio 2019 that I wasn’t using). UE5 remain version 5.0.3 before and after it stopped working.
Managed to get Live Coding working again after moving Saved/, Intermediates/ and DerivedDataCache/ folders elsewhere and then regenerate the project files.
In my experience, just make sure C++ code compiles, then reopen the project.
Also, for some event binding, simple game logic, and simple calculations, with Blue print you can save lots of time, really, avoiding some C++ pitfalls.