I have an asset that fails to correctly load to memory unless I open it in Editor. What’s strange is that is passes tests to check whether or not it has been loaded, but does not work accordingly (no crash occurs, but it returns wrong information)
I have an TSoftObjectPtr to the asset.
I already tried out what’s been suggested on these threads:
(this and this, )
I also tried some different approaches:
Load Synchronous
UMyObject* MyObject = MyObjectSoftPtr.LoadSynchronous();
Streamable Manager
FStreamableManager& Streamable = UAssetManager::GetStreamableManager();
const FSoftObjectPath& AssetRef = MyObjectSoftPtr.ToSoftObjectPath();
MyObjectSoftPtr= Cast<UMyObject>(Streamable.LoadSynchronous(AssetRef ));
UMyObject* MyObject = MyObjectSoftPtr.Get();
Asset Registry
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
IAssetRegistry& AssetRegistry = AssetRegistryModule.Get();
FAssetData MyObjectAsset = AssetRegistry.GetAssetByObjectPath(*MyObjectSoftPtr.ToString());
UMyObject* MyObject = Cast<UMyObject>(MyObjectAsset .GetAsset());
It also passes tests such as:
if(MyObject)
or
if(MyObjectAsset.IsAssetLoaded())
But when I need the actual functionality of the asset, the code runs (prints in it do show), but does not return the expected results until I open the asset in the Editor.
Anyone got any clues?