Can't cast data only blueprints to their native parent primary asset type

We were having issues with our blueprint data assets not being found by the asset manager until we found the following comment in DataAsset.h: “* With blueprint subclasses, use Data Only Blueprints (and not Data Asset instances) to properly handle data inheritance and updating the parent class.” Following that we changed all the blueprint data assets to be data only blueprints instead. Now the asset manager recognizes and loads them.

However, these blueprints can no longer be cast to their native parent class! I’ve tried using the “Load Asset Blocking” node in blueprints and then casting to the parent class - it never succeeds. I also tried doing this in C++:

TSharedPtr<FStreamableHandle> Handle{ Manager.LoadPrimaryAsset(MyAssetId) }; if (ensure(Handle.IsValid())) { Handle->WaitUntilComplete(); } UObject* MyObject{ Manager.GetPrimaryAssetObject(MyAssetId) }; UMyType* MyTypedObject{ Cast<UMyType>(MyObject) };MyObject is valid and appears to be the expected blueprint directly inheriting from UMyType, but MyTypedObject is always null.

I have seen this kind of thing work before - there has to be something simple I’m missing!

Steps to Reproduce

I’ve figured it out! UAssetManager::GetPrimaryAssetObject has this sneaky comment: “Will return blueprint class for blueprint assets.” So it was returning a blueprint class. I had to cast it to UClass and then get the default object from that instead, like so

const UClass* MyClass = Cast<UClass>(Manager.GetPrimaryAssetObject(MyAssetId)); const UMyType* MyTypedObject{ Cast<UMyType>(MyClass->GetDefaultObject()) };

Hey there, glad to hear you found the answer yourself! Closing this.