Creating editor-loadable "save" states

I am creating a game which all takes place on a single scene, over the course of a day. As such, the “state” of the scene changes multiple times.

For instance, in the morning the sun will have so and so an intensity and be at such an angle, and doors X, Y, and Z will be locked, while door A will be standing open, and at noon the sun will be in a different state and all of the doors might be locked or all opened.

I want to be able to load these different scenes from the editor for playtesting. What I have done so far is modify my save game code, which remembers the state of all of the doors and the position and intensity of the sun in the game, to also be able to save all of that data to objects I can drop around the level. Then, in the blueprints there are editor events I can use to save all the stuff in the scene or load the data into the scene.

This works. But the problem is that the in editor scene doesn’t update to reflect the changes. While loading a game works fine and correctly will open/close the doors that are opened or closed, updating all of the doors states from an editor function doesn’t actually update their states. That is, while the boolean will appropriately be checked as “open”, the door will not actually be open until the game runs. Apparently, the constructor script on blueprints is not called when updating a value from C++ code?

This is difficult for me to playtest with because I would like to be able to load any state like that and see how it looks - what doors are opened and where the sun is, etc. This is how I was planning on lighting each part of the game, but if the sun doesn’t actually update, I can’t see how each part is lit.

Has anyone handled something like this before?

In case I was not clear above: I need a way to save/load from the editor the state of certain objects in my game, including the positioning and intensity and color of the sun, etc, and have that stuff actually update when their values are loaded.


If your problem is that the constructions script are not getting called, you can call them manually from C++ with AActor::RerunConstructionScripts.

Also, if you have other BP events that you want to call from C++ while in the editor, you have to specify the CallInEditor metadata into your UFUNCTION declaration.

Calling RerunConstructionScripts actually did work for a subset of my problems. Thanks for that.

However, it does not help my lights. What I am doing, for instance, is saving the intensity of my directional light, changing it, and then loading the value of the intensity back into the directional light. This update to its intensity is not reflected in the editor. It does not light the scene according to that intensity. When I click on it, I see that its intensity has been changed to the value I saved it to, but it doesn’t actually change how much it is lighting the scene unless I change another value of it, like change its intensity a little bit or turn shadows off then on again.

I don’t know for sure but maybe try calling MarkRenderStateDirty or ReregisterAllComponents on the lights to get the editor to recognize that changes have been made to them?

Yep that worked perfectly. I have been having trouble with this for some time now, should have just came to the forums sooner!