I’m using a
USTRUCTs, each with a
UPROPERTY field called
AssetPtr, like so:
UPROPERTY(EditAnywhere) TAssetSubclassOf<UQuestAsset> AssetPtr;
I go through each and call
AssetPtr.LoadSynchronous() to process the referenced asset and load it into memory.
As it turns out,
TAssetSubclassOf use weak pointers underneath the surface, so it makes sense that the referenced assets might get unloaded at some point.
But what seems odd is that when the
WeakPtr is set to null, I also notice that the
AssetLongPathname members within
TAssetSubclassOf are reset to empty as well.
When I made a separate
TAssetSubclassOf field in the struct that was not a
UPROPERTY, I got these results:
TAssetSubclassOf<UQuestAsset> AssetPtrNotUProperty; // stale pointer, but valid AssetLongPathname UPROPERTY(EditAnywhere) TAssetSubclassOf<UQuestAsset> AssetPtr; // stale pointer and empty AssetLongPathname
So though the weak pointer was stale in the non-UPROPERTY version, the asset path information was preserved.
I’m guessing that the distinction is that garbage collection processed the
UPROPERTY version of
TAssetSubclassOf and not the other. But is it intentional for
FAssetPtrs to lose the asset pathname information when their underlying weak pointers are null, or is that a bug? Am I misuing