Эх сурвалжийг харах

[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.

badlogic 1 жил өмнө
parent
commit
65d68ed45f

+ 8 - 11
spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineAtlasAsset.cpp

@@ -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

+ 12 - 0
spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonDataAsset.cpp

@@ -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() {

+ 1 - 3
spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineAtlasAsset.h

@@ -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
 };

+ 1 - 0
spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonDataAsset.h

@@ -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();