UE5
I have a c++ class, with Actor as the parent class, to spawn blueprints at run time:
.h
UPROPERTY(EditAnywhere, Category = “Actors To Be Spawned”)
TSubclassOf ActorToBeSpawned;
.cpp
world->SpawnActor(ActorToBeSpawned, Loc, Rot, SpawnParams);
I have an instance of this class in the level, visible in the Outliner. In the details of this actor I have a category “Actors To Be Spawned” and in this category I have ActorToBeSpawned, to which I allocate a blueprint.
This works as intended. However, when I save the project and reload UE the category and value for ActorToBeSpawned is lost, the project runs, but nothing spawns (I have a check that ActorToBeSpawned exists). If I then ctrl + alt + F11 to force a live coding compilation, the category then reappears, but with an empty value. I can then re-set the ActorToBeSpawned to my blueprint and everything works again.
I am a novice at UE and obviously doing something incorrectly. How can I have the instance of my class in the level “remember” the additional category and the allocated values after a project save / load cycle?
Edit: I think this might be related to UCLASS and UPROPERTY, but I cannot figure out what I need to set.