How to keep UPROPERTIES changed through C++ in a Level Actor Instance Persistent between Editor Sessions?

So yea question is a mouthful, Let me try to simplify.

I’m currently trying to create a component that through c++ makes a new FGuid whenever it is placed in a level. So the FGuid generation is working and I can see each component placed with a unique id, however, I want to keep each FGuid persistent through editor sessions. I should be able to close and open unreal and each FGuid should stay the same instead of getting reset back to 0.

However, it seems Unreal doesn’t save properties unless you explicitly change them through the details view so my FGuids keeps getting reset everytime I restart Unreal unless I explicitly generate them through the details panel.

I’ve tried numerous different things including

  • Extending the FActorComponentInstanceData struct, but this doesn’t seem to work because the values for the FGuid are being loaded onto the actor which are just loaded onto the struct which is then loaded onto the actor. Seems kind of useless tbh.
  • Using Modify and/or Pre/PostEditChangeProperty

Should specify that this FGuid generation is directly on the component itself. I just don’t understand how Unreal goes about saving components and actors placed in the world.

Sorry for the essay :stuck_out_tongue:

I don’t know the proper solution on this, but i solved it via Editor Utility Widget where on button click i’m:

Not 100% automated, but this solves the problem for me for now.

I did try to do it “properly”, but there was so much problems that it isn’t worth further research for me.
fyi the problems to consider:

  • guids regenerating each time object is moved;
  • guids not regenerating on actor duplication (like alt+move);
  • guids regenerating on each blueprint compilation.

Yea I gave up similarly too… ended up using a separate editor module with bindings to FEditorDelegates::OnActorPlaced and all the other delegates I would need. Good to know about the Editor Utility Widget tho!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.