When I run this straight after starting the editor, CalmSeaOceanMaterialAsset contains an invalid reference. However, if I open the SmallWaves asset and then run this, it works as expected. Is this a bug/is there something I can do to force the object to be loaded before I try to find it in the AssetRegistry.
I am using UE4.4.1
I propose a tag “asset-registry” but don’t have high enough rep to create it.
Hi there! In the editor you might have to wait until the asset registry has finished discovering assets.
If AssetRegistry.IsLoadingAssets() returns true, you might have to come back later. Alternatively, you can bind onto its OnFilesLoaded() event to get notified when it has finished loading files.
EDIT:
This turned out to be failing due to the Material’’ type decoration that only succeeds when the asset is loaded. Passing in just the object path proved successful in both cases.
Could you try changing it to just “/Game/Materials/Ocean/OceanDisplacementMaterials/SmallWaves.SmallWaves” without the extra UObject type decoration? When it is loaded, it will route through FindObject<> but when it has not been loaded yet, it needs to exactly match the object path that is stored in the asset registry map.