I’m having problems with this, maybe I don’t understand exactly what it’s supposed to do. UE Docs page.
From this description I imagine it works like this:
- I create an UPROPERTY with this flag. Example:
// AWeapon.h
UPROPERTY(Instanced, EditDefaultsOnly, Category=FireMode)
TSubclassOf<UFireMode> FireModeClass;
- This is editable directly in the Weapon blueprint in the editor, I don’t need to create an extra Blueprint based on the fire mode or anything.
- Now, editing it like in 2 only works if it’s a “TSubclassOf” which means in C++ this is a type, not an instance, which again means I can’t directly use it but need to instance it first.
- So I take the type/class and instance it like this:
UFireMode* FireMode = ConstructObject<class UFireMode>(FireModeClass);
- Now I’d imagine this takes the edited properties (the changes I made in the blueprint) and gives me an instance with those. But it doesn’t, all the properties are returned to UFireMode’s default values.
- BUT, if I get the default object for FireModeClass the values are exactly what I set in the Blueprint.
Am I missing something here?
I also tried constructing the object like this:
UFireMode* FireMode = ConstructObject<class UFireMode>(FireModeClass, (UObject*)GetTransientPackage(), NAME_None, RF_NoFlags, FireModeClass->GetDefaultObject());
where I pass the edited default object as Template to the ConstructObject method but this doesn’t change anything.