Hi.
I’m doing some editor related C++ plugin development and I need to to maintain list of references to all FProperty’s of an spawned BP Actor, it should (also) work in Editor mode… Also I need my FProperty references to be valid even after the related blueprint is recompiled.*
TArray<FProperty *> PropertiesOfSpawnedActor;
Actor->GetClass()->PropertyLink //(collecting FPropert* references)
I spawn an actor with C++ and right after I spawn the actor, I collect all FProperty’s and store them in an array.
From now on, if you don’t touch anything, FProperties stay as valid…
But I need to handle “Blueprint recompile” event. After recompilation, I need to update my FProperty* references so that they won’t reference to invalid locations.
For this purpose there is an excellent event which is:
FCoreUObjectDelegates::OnObjectsReplaced
This event helps me to match old and new object. The problem is, before this event is broadcasted, somewhere in the code my spawned actor’s (private)class is being reinstanced…
In another way, when I catch “OnObjectsReplaced” event, my Actor->GetClass() is already changed when compared to initally spawned case
Make a Actor->GetClass() call before and after recompiling, I get different UClass.
Since I get different UClass, I cant match OldObject<->NewObject properties.
So I want a delegate/method to be notified when a PrivateClass/UClass of and Actor is changed, so that I can track FPropert* list…
Here is extra information:
In internals of Unreal, there are some places I found that are related with my problem. For example:
void UObjectBase::SetClass(UClass* NewClass)
{
...
ClassPrivate->CreatePersistentUberGraphFrame((UObject*)this, /*bCreateOnlyIfEmpty =*/false, /*bSkipSuperClass =*/false, OldClass); // THIS LINE CHANGES THE UCLASS
}
In KismetReinstanceUtilities.cpp, there is a method that collects and maps old to new properties which is:
void FBlueprintCompileReinstancer::GenerateFieldMappings(TMap<FFieldVariant, FFieldVariant>& FieldMapping)
But I couldn’t find any code that broadcast this mapping information…