I have a type defined thus:
UCLASS(Blueprintable)
class ROGUELIKE_API UAbility : public UObject
{ .....
With a series of properties and functions. In the editor, I have created a new blueprint derived from this class.
When I try to load a reference to this blueprint in C++, casting to UAbility always fails, despite it seemingly being a derived type.
The code I am using to load this type:
FStringAssetReference chargeReference = "Blueprint'/Game/Content/Abilities/Charge/ChargeAbility.ChargeAbility'";
StaticLoadObject(UObject::StaticClass(), nullptr, *chargeReference.ToString());
UObject* chargeReferenceObj = chargeReference.ResolveObject();
UBlueprint* chargeAbilityBlueprint = Cast<UBlueprint>(chargeReferenceObj);
UAbility* chargeCast = Cast<UAbility>(chargeAbilityBlueprint);
In the above example, chargeAbilityBlueprint is a pointer to an actual object, but chargeCast is NULL. Trying to get a UAbility type by replacing UBlueprint with UAbility also results in a null object.
Any suggestions would be greatly appreciated!