When creating a C++ UE5.2 project you open the editor, add some c++ logic, add it to your world and everything is working fine.
Until then the next time the project is opened, you are now in a dysfunctional project as there are no C++ files in your content browser, your blueprints don’t work, your maps are telling you they have invalid assets. To fix all these problems you have to click the “Recompile and reload C++ code for game systems on the fly” button in the lower right. Once this has completed all is well again.
Is there a way to force Unreal 5 to perform this step automatically on startup of the project? Since there is almost never a situation you do not want to do this. I would like this to be the default behavior.
if it was created as Blueprint and then C++ was added later, then @Kehel18 suggestion should probably fix this behavior (if the project is under Source/Revision Control then you may need to check the permissions on the /DerivedDataCache and /Binaries as these should be folders related to turning your C++ code files into what the Editor Understands and uses
(if you are going to remove folders to fix this then leave /Content, /Source, ( maybe /config if you have done a bunch of work in Project Settings) and the [projectName].uproject
Right click the [projectName].uproject and select “Generate [Visual Studio] project files”
open the resulting [projectName].sln allow it to parse
Build and Run
when the editor comes up it should work by just opening the uproject since the last Build+Run from your IDE.
I had an empty class for learning purposes, but in order to get the .h and .cpp files compiled, I had to create a dummy Actor subclass, so the editor would find the empty class!
I’m just starting Unreal Engine dev (on Macintosh) so I blame being a noob.
in the New C++ class Dialog box there is “None” this will enable you to not have it be a UCLASS or USTRUCT and no generated Body
keep in mind this can still be used, but will be completely unmanaged by the Garbage Collector so you will need to do your own pointer management, and you really shouldn’t point at things that are managed by the Garbage Collector but if you need to you can
in theory you can also slap a non UCLASS/USTRUCT into .h file with those things already in them (similar to how you can just slap a USTRUCT into any .h file that is already under the engines reflection system to get those structs to be usable just remember to add the GENERATED_BODY() or GENERATED_USTRUCT_BODY() to your struct or else reflection just wont work for it.
Thank you for taking the time to type all of that! My problem is more fundamental to the editor. It didn’t find my empty class (basically “hello world”) to compile, until I created a separate, Actor class file, which caused the editor to also compile my hello files.
gardian206 & Kehel18. thanks for the suggestions, but I had already found these answers online, the problem with the methods mentioned is that these also do not resolve the problem permantly, Everytime after closing the UE5 project and reopening it again Im back to a situation where it does not immediately detects the c++ files.
Are you guys regenerating / “rebuilding” your project everytime before opening it up?
PS. The project is not under version control and was started as a C++ project.