mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[unity] Fixed very long build times due to a regression in commit 32dfaf1 which removed some past improvements. See #2960
This commit is contained in:
parent
c3ac62d1dd
commit
022a4bacbd
@ -39,6 +39,9 @@
|
|||||||
#define HAS_ON_POSTPROCESS_PREFAB
|
#define HAS_ON_POSTPROCESS_PREFAB
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if UNITY_2020_3_16_OR_NEWER || UNITY_2021_1_17_OR_NEWER
|
||||||
|
#define HAS_SAVE_ASSET_IF_DIRTY
|
||||||
|
#endif
|
||||||
#define SPINE_OPTIONAL_ON_DEMAND_LOADING
|
#define SPINE_OPTIONAL_ON_DEMAND_LOADING
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -64,7 +67,8 @@ namespace Spine.Unity.Editor {
|
|||||||
internal static void PreprocessBuild () {
|
internal static void PreprocessBuild () {
|
||||||
isBuilding = true;
|
isBuilding = true;
|
||||||
#if HAS_ON_POSTPROCESS_PREFAB
|
#if HAS_ON_POSTPROCESS_PREFAB
|
||||||
PreprocessSpinePrefabMeshes();
|
if (SpineEditorUtilities.Preferences.removePrefabPreviewMeshes)
|
||||||
|
PreprocessSpinePrefabMeshes();
|
||||||
#endif
|
#endif
|
||||||
#if SPINE_OPTIONAL_ON_DEMAND_LOADING
|
#if SPINE_OPTIONAL_ON_DEMAND_LOADING
|
||||||
PreprocessOnDemandTextureLoaders();
|
PreprocessOnDemandTextureLoaders();
|
||||||
@ -75,7 +79,8 @@ namespace Spine.Unity.Editor {
|
|||||||
internal static void PostprocessBuild () {
|
internal static void PostprocessBuild () {
|
||||||
isBuilding = false;
|
isBuilding = false;
|
||||||
#if HAS_ON_POSTPROCESS_PREFAB
|
#if HAS_ON_POSTPROCESS_PREFAB
|
||||||
PostprocessSpinePrefabMeshes();
|
if (SpineEditorUtilities.Preferences.removePrefabPreviewMeshes)
|
||||||
|
PostprocessSpinePrefabMeshes();
|
||||||
#endif
|
#endif
|
||||||
#if SPINE_OPTIONAL_ON_DEMAND_LOADING
|
#if SPINE_OPTIONAL_ON_DEMAND_LOADING
|
||||||
PostprocessOnDemandTextureLoaders();
|
PostprocessOnDemandTextureLoaders();
|
||||||
@ -96,12 +101,17 @@ namespace Spine.Unity.Editor {
|
|||||||
|
|
||||||
GameObject prefabGameObject = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
|
GameObject prefabGameObject = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
|
||||||
if (SpineEditorUtilities.CleanupSpinePrefabMesh(prefabGameObject)) {
|
if (SpineEditorUtilities.CleanupSpinePrefabMesh(prefabGameObject)) {
|
||||||
|
#if HAS_SAVE_ASSET_IF_DIRTY
|
||||||
|
AssetDatabase.SaveAssetIfDirty(prefabGameObject);
|
||||||
|
#endif
|
||||||
prefabsToRestore.Add(assetPath);
|
prefabsToRestore.Add(assetPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AssetDatabase.StopAssetEditing();
|
AssetDatabase.StopAssetEditing();
|
||||||
|
#if !HAS_SAVE_ASSET_IF_DIRTY
|
||||||
if (prefabAssets.Length > 0)
|
if (prefabAssets.Length > 0)
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
|
#endif
|
||||||
} finally {
|
} finally {
|
||||||
BuildUtilities.IsInSkeletonAssetBuildPreProcessing = false;
|
BuildUtilities.IsInSkeletonAssetBuildPreProcessing = false;
|
||||||
}
|
}
|
||||||
@ -113,9 +123,14 @@ namespace Spine.Unity.Editor {
|
|||||||
foreach (string assetPath in prefabsToRestore) {
|
foreach (string assetPath in prefabsToRestore) {
|
||||||
GameObject g = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
|
GameObject g = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
|
||||||
SpineEditorUtilities.SetupSpinePrefabMesh(g, null);
|
SpineEditorUtilities.SetupSpinePrefabMesh(g, null);
|
||||||
|
#if HAS_SAVE_ASSET_IF_DIRTY
|
||||||
|
AssetDatabase.SaveAssetIfDirty(g);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#if !HAS_SAVE_ASSET_IF_DIRTY
|
||||||
if (prefabsToRestore.Count > 0)
|
if (prefabsToRestore.Count > 0)
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
|
#endif
|
||||||
prefabsToRestore.Clear();
|
prefabsToRestore.Clear();
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
@ -197,10 +212,15 @@ namespace Spine.Unity.Editor {
|
|||||||
spriteAtlasTexturesToRestore[assetPath] = AssetDatabase.GetAssetPath(atlasAsset.materials[0].mainTexture);
|
spriteAtlasTexturesToRestore[assetPath] = AssetDatabase.GetAssetPath(atlasAsset.materials[0].mainTexture);
|
||||||
atlasAsset.materials[0].mainTexture = null;
|
atlasAsset.materials[0].mainTexture = null;
|
||||||
}
|
}
|
||||||
|
#if HAS_SAVE_ASSET_IF_DIRTY
|
||||||
|
AssetDatabase.SaveAssetIfDirty(atlasAsset);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
AssetDatabase.StopAssetEditing();
|
AssetDatabase.StopAssetEditing();
|
||||||
|
#if !HAS_SAVE_ASSET_IF_DIRTY
|
||||||
if (spriteAtlasAssets.Length > 0)
|
if (spriteAtlasAssets.Length > 0)
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
|
#endif
|
||||||
} finally {
|
} finally {
|
||||||
BuildUtilities.IsInSpriteAtlasBuildPreProcessing = false;
|
BuildUtilities.IsInSpriteAtlasBuildPreProcessing = false;
|
||||||
}
|
}
|
||||||
@ -216,9 +236,14 @@ namespace Spine.Unity.Editor {
|
|||||||
Texture atlasTexture = AssetDatabase.LoadAssetAtPath<Texture>(pair.Value);
|
Texture atlasTexture = AssetDatabase.LoadAssetAtPath<Texture>(pair.Value);
|
||||||
atlasAsset.materials[0].mainTexture = atlasTexture;
|
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)
|
if (spriteAtlasTexturesToRestore.Count > 0)
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
|
#endif
|
||||||
spriteAtlasTexturesToRestore.Clear();
|
spriteAtlasTexturesToRestore.Clear();
|
||||||
} finally {
|
} finally {
|
||||||
BuildUtilities.IsInSpriteAtlasBuildPostProcessing = false;
|
BuildUtilities.IsInSpriteAtlasBuildPostProcessing = false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user