Merge branch '4.0' into 4.1-beta

This commit is contained in:
Harald Csaszar 2022-06-09 18:14:07 +02:00
commit f48e32b70c

View File

@ -36,6 +36,10 @@
#define HAS_ON_POSTPROCESS_PREFAB
#endif
#if UNITY_2020_3_OR_NEWER
#define HAS_SAVE_ASSET_IF_DIRTY
#endif
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.Build;
@ -80,13 +84,18 @@ namespace Spine.Unity.Editor {
string assetPath = AssetDatabase.GUIDToAssetPath(asset);
GameObject prefabGameObject = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
if (SpineEditorUtilities.CleanupSpinePrefabMesh(prefabGameObject)) {
#if HAS_SAVE_ASSET_IF_DIRTY
AssetDatabase.SaveAssetIfDirty(prefabGameObject);
#endif
prefabsToRestore.Add(assetPath);
}
EditorUtility.UnloadUnusedAssetsImmediate();
}
AssetDatabase.StopAssetEditing();
#if !HAS_SAVE_ASSET_IF_DIRTY
if (prefabAssets.Length > 0)
AssetDatabase.SaveAssets();
#endif
} finally {
BuildUtilities.IsInSkeletonAssetBuildPreProcessing = false;
}
@ -98,9 +107,14 @@ namespace Spine.Unity.Editor {
foreach (string assetPath in prefabsToRestore) {
GameObject g = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
SpineEditorUtilities.SetupSpinePrefabMesh(g, null);
#if HAS_SAVE_ASSET_IF_DIRTY
AssetDatabase.SaveAssetIfDirty(g);
#endif
}
#if !HAS_SAVE_ASSET_IF_DIRTY
if (prefabsToRestore.Count > 0)
AssetDatabase.SaveAssets();
#endif
prefabsToRestore.Clear();
} finally {
@ -121,11 +135,16 @@ namespace Spine.Unity.Editor {
spriteAtlasTexturesToRestore[assetPath] = AssetDatabase.GetAssetPath(atlasAsset.materials[0].mainTexture);
atlasAsset.materials[0].mainTexture = null;
}
#if HAS_SAVE_ASSET_IF_DIRTY
AssetDatabase.SaveAssetIfDirty(atlasAsset);
#endif
EditorUtility.UnloadUnusedAssetsImmediate();
}
AssetDatabase.StopAssetEditing();
#if !HAS_SAVE_ASSET_IF_DIRTY
if (spriteAtlasAssets.Length > 0)
AssetDatabase.SaveAssets();
#endif
} finally {
BuildUtilities.IsInSpriteAtlasBuildPreProcessing = false;
}
@ -141,9 +160,14 @@ namespace Spine.Unity.Editor {
Texture atlasTexture = AssetDatabase.LoadAssetAtPath<Texture>(pair.Value);
atlasAsset.materials[0].mainTexture = atlasTexture;
}
#if HAS_SAVE_ASSET_IF_DIRTY
AssetDatabase.SaveAssetIfDirty(atlasAsset);
#endif
}
#if !HAS_SAVE_ASSET_IF_DIRTY
if (spriteAtlasTexturesToRestore.Count > 0)
AssetDatabase.SaveAssets();
#endif
spriteAtlasTexturesToRestore.Clear();
} finally {
BuildUtilities.IsInSpriteAtlasBuildPostProcessing = false;