TMap is empty after add

Hey all,

I’m having an issue with a TMap, I have it declared as a public variable of type TMap, where FIOStruct is a custom struct, then in a class method on the UActorComponent this variable is declared on, I call the line this->TargetMap.Add(HashID, IOStruct), where IOStruct is a pointer to a struct of type FIOStruct given to the method as a parameter.

Initially after it calls Add, I can see the entry in the TMap is there, but once the method that called this method to add to the TMap has completed, the TMap entry disappears.

Also important to note, this is all being called in editor with an #if WITH_EDITOR wrapping the methods, and this specific method is being called by an overridden PostEditChangeProperty method.

Not too sure why it’s not persistently storing in memory, does it have to be a UPROPERTY or something?

Ok I figured out the variables needed to be static to retain changes made in editor

Edit: I thought this was the answer to go with, but since I’ve got a good number of properties that need to be local to classes / structs and retain changes while in Editor, static ain’t really a good option… I need some way to have local variables that retain changes while in editor and without exposing the variables…

Edit 2: I’ve figured it out finally, so as mentioned in my comment, the Constructor is being called whenever I modify a property on the object through the Editor, but the thing calling the Constructor was the Super::PostEditChangeChainProperty() call, and from playing around, it was if I placed my code after the Super call that all changes were being lost because it was after the Constructor call… So placing the Super call after the Super instead of before, all changes are carried over with the Constructor to the new instance… Doesn’t make 100% sense to me, but it works now

Update, I’ve figured out why any variables edited in C++ in Editor aren’t retaining values assigned after completion of callstack, is because each time there’s a change on the object, it will call the constructor which resets all the values set by C++. Have yet to figure a way to remedy this.