More advanced and convenient Data Asset based on Primary Data Asset with its own Thumbnail Render
This asset has a feature in the form of an overridden ID function.
The ID is formed as follows: FPrimaryAssetId(FPrimaryAssetType(AssetType), AssetId)
You can set the asset type directly in the C++ constructor:
class YOUR_API UMyAdvancedDataAsset : public UAdvancedDataAsset {
GENERATED_BODY()
public:
UMyAdvancedDataAsset();
}
UMyAdvancedDataAsset::UMyAdvancedDataAsset()
{
AssetType = TEXT("MyAsset");
}
You can set the ID in the asset editor:
Don't forget to add your asset to Asset Manager
You can select any icon from the project to display. You can also add a short name for the display.
Due to ID-Type you can use the following snippet code to load the data asset directly
class YOUR_API UMyAssetManager : public UAssetManager
{
GENERATED_BODY()
public:
template <class T>
T* LoadAsset(FName ID)
{
if (const UAdvancedDataAsset* Default = Cast<UAdvancedDataAsset>(T::StaticClass()->GetDefaultObject()))
{
const FPrimaryAssetId PrimaryAssetId = FPrimaryAssetId(Default->GetType(), ID);
const FSoftObjectPath path = GetPrimaryAssetPath(PrimaryAssetId);
if (T* LoadedItem = Cast<T>(path.TryLoad()))
{
return LoadedItem;
}
}
return nullptr;
}
};
Doxygen documentation: GitHubPages
Documentation sources: GitHub