[ue] Temporary (disabled) hack to get atlas and skeleton assets to display in content browsers. This doesn't work, as the UE editor thinks the assets are cooked. It also only loads assets that are referenced. As soon as the references no longer exist, the assets are unloaded. See #2368.

This commit is contained in:
badlogic 2023-10-18 18:18:04 +02:00
parent c2425dbdde
commit 65d68ed45f
4 changed files with 22 additions and 14 deletions

View File

@ -52,24 +52,21 @@ void USpineAtlasAsset::PostInitProperties() {
Super::PostInitProperties();
}
void USpineAtlasAsset::GetAssetRegistryTags(TArray<FAssetRegistryTag> &OutTags) const {
Super::GetAssetRegistryTags(OutTags);
}
void USpineAtlasAsset::Serialize(FArchive &Ar) {
Super::Serialize(Ar);
if (Ar.IsLoading() && Ar.UE4Ver() < VER_UE4_ASSET_IMPORT_DATA_AS_JSON && !importData)
importData = NewObject<UAssetImportData>(this, TEXT("AssetImportData"));
}
FPrimaryAssetId USpineAtlasAsset::GetPrimaryAssetId() const {
return FPrimaryAssetId("spine-atlas", GetFName());
}
void USpineAtlasAsset::PostLoadAssetRegistryTags(const FAssetData& InAssetData,
TArray<FAssetRegistryTag>& OutTagsAndValuesToUpdate) const
{
UObject::PostLoadAssetRegistryTags(InAssetData, OutTagsAndValuesToUpdate);
TArray<FAssetRegistryTag>& OutTagsAndValuesToUpdate) const {
// FIXME: this is a massive hack. It will set the PackageFlags of the FAssetData
// in the AssetRegistry to PKG_FilterEditorOnly so the content browser displays it.
// This is necessary in UE 5.3 due to a regression in ContentBrowserAssetDataCore::IsPrimaryAsset
// See https://github.com/EsotericSoftware/spine-runtimes/issues/2368
FAssetData& MutableAssetData = const_cast<FAssetData&>(InAssetData);
// MutableAssetData.PackageFlags = EPackageFlags::PKG_FilterEditorOnly;
UObject::PostLoadAssetRegistryTags(MutableAssetData, OutTagsAndValuesToUpdate);
}
#endif

View File

@ -80,6 +80,18 @@ void USpineSkeletonDataAsset::Serialize(FArchive &Ar) {
LoadInfo();
}
void USpineSkeletonDataAsset::PostLoadAssetRegistryTags(const FAssetData& InAssetData,
// FIXME: this is a massive hack. It will set the PackageFlags of the FAssetData
// in the AssetRegistry to PKG_FilterEditorOnly so the content browser displays it.
// This is necessary in UE 5.3 due to a regression in ContentBrowserAssetDataCore::IsPrimaryAsset
// See https://github.com/EsotericSoftware/spine-runtimes/issues/2368
TArray<FAssetRegistryTag>& OutTagsAndValuesToUpdate) const {
FAssetData& MutableAssetData = const_cast<FAssetData&>(InAssetData);
// MutableAssetData.PackageFlags = EPackageFlags::PKG_FilterEditorOnly;
UObject::PostLoadAssetRegistryTags(MutableAssetData, OutTagsAndValuesToUpdate);
}
#endif
void USpineSkeletonDataAsset::ClearNativeData() {

View File

@ -36,7 +36,7 @@
// clang-format on
UCLASS(BlueprintType, ClassGroup = (Spine))
class SPINEPLUGIN_API USpineAtlasAsset : public UObject {
class SPINEPLUGIN_API USpineAtlasAsset : public UPrimaryDataAsset {
GENERATED_BODY()
public:
@ -70,9 +70,7 @@ protected:
class UAssetImportData *importData;
virtual void PostInitProperties() override;
virtual void GetAssetRegistryTags(TArray<FAssetRegistryTag> &OutTags) const override;
virtual void Serialize(FArchive &Ar) override;
virtual FPrimaryAssetId GetPrimaryAssetId() const override;
virtual void PostLoadAssetRegistryTags(const FAssetData& InAssetData, TArray<FAssetRegistryTag>& OutTagsAndValuesToUpdate) const override;
#endif
};

View File

@ -116,6 +116,7 @@ protected:
virtual void PostInitProperties() override;
virtual void GetAssetRegistryTags(TArray<FAssetRegistryTag> &OutTags) const override;
virtual void Serialize(FArchive &Ar) override;
virtual void PostLoadAssetRegistryTags(const FAssetData& InAssetData, TArray<FAssetRegistryTag>& OutTagsAndValuesToUpdate) const override;
#endif
void LoadInfo();