mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-22 02:06:03 +08:00
[unity] Fixed SpineBuildProcessor potentially trying to modifying a readonly prefab asset. Closes #2223.
This commit is contained in:
parent
07b54ee18e
commit
042a6dfd1d
@ -51,6 +51,10 @@
|
||||
#define PROBLEMATIC_PACKAGE_ASSET_MODIFICATION
|
||||
#endif
|
||||
|
||||
#if UNITY_2017_3_OR_NEWER
|
||||
#define HAS_PACKAGE_INFO
|
||||
#endif
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@ -114,6 +118,17 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
}
|
||||
|
||||
public static bool AssetCanBeModified (string assetPath) {
|
||||
#if HAS_PACKAGE_INFO
|
||||
UnityEditor.PackageManager.PackageInfo packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssetPath(assetPath);
|
||||
return (packageInfo == null ||
|
||||
packageInfo.source == UnityEditor.PackageManager.PackageSource.Embedded ||
|
||||
packageInfo.source == UnityEditor.PackageManager.PackageSource.Local);
|
||||
#else
|
||||
return assetPath.StartsWith("Assets");
|
||||
#endif
|
||||
}
|
||||
|
||||
#region Match SkeletonData with Atlases
|
||||
static readonly AttachmentType[] AtlasTypes = { AttachmentType.Region, AttachmentType.Linkedmesh, AttachmentType.Mesh };
|
||||
|
||||
|
||||
@ -91,6 +91,8 @@ namespace Spine.Unity.Editor {
|
||||
string[] prefabAssets = AssetDatabase.FindAssets("t:Prefab");
|
||||
foreach (string asset in prefabAssets) {
|
||||
string assetPath = AssetDatabase.GUIDToAssetPath(asset);
|
||||
if (!AssetUtility.AssetCanBeModified(assetPath)) continue;
|
||||
|
||||
GameObject prefabGameObject = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
|
||||
if (SpineEditorUtilities.CleanupSpinePrefabMesh(prefabGameObject)) {
|
||||
#if HAS_SAVE_ASSET_IF_DIRTY
|
||||
@ -139,6 +141,8 @@ namespace Spine.Unity.Editor {
|
||||
string[] spriteAtlasAssets = AssetDatabase.FindAssets("t:SpineSpriteAtlasAsset");
|
||||
foreach (string asset in spriteAtlasAssets) {
|
||||
string assetPath = AssetDatabase.GUIDToAssetPath(asset);
|
||||
if (!AssetUtility.AssetCanBeModified(assetPath)) continue;
|
||||
|
||||
SpineSpriteAtlasAsset atlasAsset = AssetDatabase.LoadAssetAtPath<SpineSpriteAtlasAsset>(assetPath);
|
||||
if (atlasAsset && atlasAsset.materials.Length > 0) {
|
||||
spriteAtlasTexturesToRestore[assetPath] = AssetDatabase.GetAssetPath(atlasAsset.materials[0].mainTexture);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user