Hi,
I want to add UProperties (FProperty in c++) to some UObject at runtime.
this is for a plugin that should change assets in the editor. i add a short use case to make it clear. in the editor i have blueprint “MyBP” and i want to add “MyProp” to it via code (triggered by an editor widget). as a result, when i open “MyBP” in the asset editor, “MyProp” should be visible under the variables section of the blueprint and when i save the asset, the property should be there after loading. in general the whole blueprint should just work as if i added the property via asset editor or if i added a UPROPERTY in the class header in c++.
I don’t want any workaround for that. i already have workarounds. i specifically want to add properties via code ^^
at the moment i can add properties but they don’t show in the editor and are not saved. here is my code
EObjectFlags Flags = EObjectFlags::RF_Transient | EObjectFlags::RF_Public | EObjectFlags::RF_MarkAsNative;
EPropertyFlags PFLags = EPropertyFlags::CPF_Edit
| EPropertyFlags::CPF_BlueprintVisible
| EPropertyFlags::CPF_SaveGame
| EPropertyFlags::CPF_Net
| EPropertyFlags::CPF_SaveGame
| EPropertyFlags::CPF_IsPlainOldData
| EPropertyFlags::CPF_Interp
| EPropertyFlags::CPF_SimpleDisplay;
//LDK_PROPERTY_ANIM_PERCENTAGE is the name
FFloatProperty* Prop = new FFloatProperty(ObjectClass, FName(LDK_PROPERTY_ANIM_PERCENTAGE), Flags);
//FFloatProperty* Prop = new FFloatProperty(ObjectClass, FName(LDK_PROPERTY_ANIM_PERCENTAGE), Flags, MaxOffset, PFLags);
Prop->SetPropertyFlags(PFLags);
ObjectClass->AddCppProperty(Prop);
ObjectClass->Modify();
thanks in advance