I have a static value in my actor and it would change and assign to another non-static value once a actor is spawned.
For some reason, some actors have to be spawned in the editor by the designer and would be saved in the map later while some others would be spawned ‘automatically’ in the built version during runing without saving in the end.
However, the static value is reset once the editor is closed and it is obviously that it would be not kept in built version, either. Thus, is there a method to distinguish/separate the code between editor version and built version, so that I can design a condition logic to avoid conflict.
I am not familiar to this part, it may be something like:
The counter is to record the number of spawned actors and its increment is finished on PostActorCreated() since some of the non-static value is initialized at BeginPlay in its components according to the counter value. The main problem is still the static value, which would be reset/losed after built. I don’t want to use a gamesave system, because the actors should not be spawned in editor in the final version. It was just designed for my groupmate to debug.
As my descriptions don’t seem to be detailed enough, I’ve just edited them.
What I found was that the non-static values which are assigned at PostActorCreated() in the editor didn’t change in built version because they had already finished calling PostActorCreated() in editor mode and do not need to call agian in built version.
What I actually need is a function like ‘Pre’ BeginPlay that runs once like BeginPlay but I only found PostActorCreated().