Переглянути джерело

Merge branch '4.0' into 4.1-beta

# Conflicts:
#	spine-ts/package-lock.json
#	spine-ts/package.json
#	spine-ts/spine-canvas/package.json
#	spine-ts/spine-core/package.json
#	spine-ts/spine-player/package.json
#	spine-ts/spine-threejs/package.json
#	spine-ts/spine-webgl/package.json
Mario Zechner 3 роки тому
батько
коміт
78e8f637bb

+ 1 - 1
spine-ts/spine-threejs/example/index.html

@@ -3,7 +3,7 @@
 <head>
 	<meta charset="UTF-8">
 	<title>spine-threejs</title>
-	<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.js"></script>
+	<script src="https://unpkg.com/[email protected]/build/three.js"></script>
 	<script src="../dist/iife/spine-threejs.js"></script>
 </head>
 <style>

+ 3 - 3
spine-ts/spine-threejs/src/SkeletonMesh.ts

@@ -48,14 +48,14 @@ export class SkeletonMeshMaterial extends THREE.ShaderMaterial {
 		`;
 		let fragmentShader = `
 			uniform sampler2D map;
-			#ifdef USE_ALPHATEST
+			#ifdef USE_SPINE_ALPHATEST
 			uniform float alphaTest;
 			#endif
 			varying vec2 vUv;
 			varying vec4 vColor;
 			void main(void) {
 				gl_FragColor = texture2D(map, vUv)*vColor;
-				#ifdef USE_ALPHATEST
+				#ifdef USE_SPINE_ALPHATEST
 				if (gl_FragColor.a < alphaTest) discard;
 				#endif
 			}
@@ -74,7 +74,7 @@ export class SkeletonMeshMaterial extends THREE.ShaderMaterial {
 		};
 		customizer(parameters);
 		if (parameters.alphaTest > 0) {
-			parameters.defines = { "USE_ALPHATEST": 1 };
+			parameters.defines = { "USE_SPINE_ALPHATEST": 1 };
 			parameters.uniforms["alphaTest"] = { value: parameters.alphaTest };
 		}
 		super(parameters);

+ 61 - 40
spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/SpineBuildProcessor.cs

@@ -71,62 +71,83 @@ namespace Spine.Unity.Editor {
 
 #if HAS_ON_POSTPROCESS_PREFAB
 		internal static void PreprocessSpinePrefabMeshes () {
-			AssetDatabase.StartAssetEditing();
-			prefabsToRestore.Clear();
-			var prefabAssets = AssetDatabase.FindAssets("t:Prefab");
-			foreach (var asset in prefabAssets) {
-				string assetPath = AssetDatabase.GUIDToAssetPath(asset);
-				GameObject prefabGameObject = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
-				if (SpineEditorUtilities.CleanupSpinePrefabMesh(prefabGameObject)) {
-					prefabsToRestore.Add(assetPath);
+			BuildUtilities.IsInSkeletonAssetBuildPreProcessing = true;
+			try {
+				AssetDatabase.StartAssetEditing();
+				prefabsToRestore.Clear();
+				var prefabAssets = AssetDatabase.FindAssets("t:Prefab");
+				foreach (var asset in prefabAssets) {
+					string assetPath = AssetDatabase.GUIDToAssetPath(asset);
+					GameObject prefabGameObject = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
+					if (SpineEditorUtilities.CleanupSpinePrefabMesh(prefabGameObject)) {
+						prefabsToRestore.Add(assetPath);
+					}
+					EditorUtility.UnloadUnusedAssetsImmediate();
 				}
-				EditorUtility.UnloadUnusedAssetsImmediate();
+				AssetDatabase.StopAssetEditing();
+				if (prefabAssets.Length > 0)
+					AssetDatabase.SaveAssets();
+			} finally {
+				BuildUtilities.IsInSkeletonAssetBuildPreProcessing = false;
 			}
-			AssetDatabase.StopAssetEditing();
-			if (prefabAssets.Length > 0)
-				AssetDatabase.SaveAssets();
 		}
 
 		internal static void PostprocessSpinePrefabMeshes () {
-			foreach (string assetPath in prefabsToRestore) {
-				GameObject g = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
-				SpineEditorUtilities.SetupSpinePrefabMesh(g, null);
+			BuildUtilities.IsInSkeletonAssetBuildPostProcessing = true;
+			try {
+				foreach (string assetPath in prefabsToRestore) {
+					GameObject g = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
+					SpineEditorUtilities.SetupSpinePrefabMesh(g, null);
+				}
+				if (prefabsToRestore.Count > 0)
+					AssetDatabase.SaveAssets();
+				prefabsToRestore.Clear();
+
+			} finally {
+				BuildUtilities.IsInSkeletonAssetBuildPostProcessing = false;
 			}
-			if (prefabsToRestore.Count > 0)
-				AssetDatabase.SaveAssets();
-			prefabsToRestore.Clear();
 		}
 #endif
 		internal static void PreprocessSpriteAtlases () {
-			AssetDatabase.StartAssetEditing();
-			spriteAtlasTexturesToRestore.Clear();
-			var spriteAtlasAssets = AssetDatabase.FindAssets("t:SpineSpriteAtlasAsset");
-			foreach (var asset in spriteAtlasAssets) {
-				string assetPath = AssetDatabase.GUIDToAssetPath(asset);
-				SpineSpriteAtlasAsset atlasAsset = AssetDatabase.LoadAssetAtPath<SpineSpriteAtlasAsset>(assetPath);
-				if (atlasAsset && atlasAsset.materials.Length > 0) {
-					spriteAtlasTexturesToRestore[assetPath] = AssetDatabase.GetAssetPath(atlasAsset.materials[0].mainTexture);
-					atlasAsset.materials[0].mainTexture = null;
+			BuildUtilities.IsInSpriteAtlasBuildPreProcessing = true;
+			try {
+				AssetDatabase.StartAssetEditing();
+				spriteAtlasTexturesToRestore.Clear();
+				var spriteAtlasAssets = AssetDatabase.FindAssets("t:SpineSpriteAtlasAsset");
+				foreach (var asset in spriteAtlasAssets) {
+					string assetPath = AssetDatabase.GUIDToAssetPath(asset);
+					SpineSpriteAtlasAsset atlasAsset = AssetDatabase.LoadAssetAtPath<SpineSpriteAtlasAsset>(assetPath);
+					if (atlasAsset && atlasAsset.materials.Length > 0) {
+						spriteAtlasTexturesToRestore[assetPath] = AssetDatabase.GetAssetPath(atlasAsset.materials[0].mainTexture);
+						atlasAsset.materials[0].mainTexture = null;
+					}
+					EditorUtility.UnloadUnusedAssetsImmediate();
 				}
-				EditorUtility.UnloadUnusedAssetsImmediate();
+				AssetDatabase.StopAssetEditing();
+				if (spriteAtlasAssets.Length > 0)
+					AssetDatabase.SaveAssets();
+			} finally {
+				BuildUtilities.IsInSpriteAtlasBuildPreProcessing = false;
 			}
-			AssetDatabase.StopAssetEditing();
-			if (spriteAtlasAssets.Length > 0)
-				AssetDatabase.SaveAssets();
 		}
 
 		internal static void PostprocessSpriteAtlases () {
-			foreach (var pair in spriteAtlasTexturesToRestore) {
-				string assetPath = pair.Key;
-				SpineSpriteAtlasAsset atlasAsset = AssetDatabase.LoadAssetAtPath<SpineSpriteAtlasAsset>(assetPath);
-				if (atlasAsset && atlasAsset.materials.Length > 0) {
-					Texture atlasTexture = AssetDatabase.LoadAssetAtPath<Texture>(pair.Value);
-					atlasAsset.materials[0].mainTexture = atlasTexture;
+			BuildUtilities.IsInSpriteAtlasBuildPostProcessing = true;
+			try {
+				foreach (var pair in spriteAtlasTexturesToRestore) {
+					string assetPath = pair.Key;
+					SpineSpriteAtlasAsset atlasAsset = AssetDatabase.LoadAssetAtPath<SpineSpriteAtlasAsset>(assetPath);
+					if (atlasAsset && atlasAsset.materials.Length > 0) {
+						Texture atlasTexture = AssetDatabase.LoadAssetAtPath<Texture>(pair.Value);
+						atlasAsset.materials[0].mainTexture = atlasTexture;
+					}
 				}
+				if (spriteAtlasTexturesToRestore.Count > 0)
+					AssetDatabase.SaveAssets();
+				spriteAtlasTexturesToRestore.Clear();
+			} finally {
+				BuildUtilities.IsInSpriteAtlasBuildPostProcessing = false;
 			}
-			if (spriteAtlasTexturesToRestore.Count > 0)
-				AssetDatabase.SaveAssets();
-			spriteAtlasTexturesToRestore.Clear();
 		}
 	}
 

+ 5 - 0
spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SpineAtlasAsset.cs

@@ -251,6 +251,11 @@ namespace Spine.Unity {
 		}
 
 		public void Load (AtlasPage page, string path) {
+#if UNITY_EDITOR
+			if (BuildUtilities.IsInSkeletonAssetBuildPreProcessing ||
+				BuildUtilities.IsInSkeletonAssetBuildPostProcessing)
+				return;
+#endif
 			String name = Path.GetFileNameWithoutExtension(path);
 			Material material = null;
 			foreach (Material other in atlasAsset.materials) {

+ 4 - 0
spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs

@@ -169,6 +169,10 @@ namespace Spine.Unity {
 		public override void Initialize (bool overwrite, bool quiet = false) {
 			if (valid && !overwrite)
 				return;
+#if UNITY_EDITOR
+			if (BuildUtilities.IsInSkeletonAssetBuildPreProcessing)
+				return;
+#endif
 			base.Initialize(overwrite, quiet);
 
 			if (!valid)

+ 4 - 1
spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs

@@ -525,7 +525,10 @@ namespace Spine.Unity {
 
 		public void Initialize (bool overwrite) {
 			if (this.IsValid && !overwrite) return;
-
+#if UNITY_EDITOR
+			if (BuildUtilities.IsInSkeletonAssetBuildPreProcessing)
+				return;
+#endif
 			if (this.skeletonDataAsset == null) return;
 			var skeletonData = this.skeletonDataAsset.GetSkeletonData(false);
 			if (skeletonData == null) return;

+ 4 - 1
spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonMecanim.cs

@@ -75,7 +75,10 @@ namespace Spine.Unity {
 		public override void Initialize (bool overwrite, bool quiet = false) {
 			if (valid && !overwrite)
 				return;
-
+#if UNITY_EDITOR
+			if (BuildUtilities.IsInSkeletonAssetBuildPreProcessing)
+				return;
+#endif
 			base.Initialize(overwrite, quiet);
 
 			if (!valid)

+ 4 - 1
spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs

@@ -367,7 +367,10 @@ namespace Spine.Unity {
 		public virtual void Initialize (bool overwrite, bool quiet = false) {
 			if (valid && !overwrite)
 				return;
-
+#if UNITY_EDITOR
+			if (BuildUtilities.IsInSkeletonAssetBuildPreProcessing)
+				return;
+#endif
 			// Clear
 			{
 				// Note: do not reset meshFilter.sharedMesh or meshRenderer.sharedMaterial to null,

+ 42 - 0
spine-unity/Assets/Spine/Runtime/spine-unity/Utility/BuildUtilities.cs

@@ -0,0 +1,42 @@
+/******************************************************************************
+ * Spine Runtimes License Agreement
+ * Last updated January 1, 2020. Replaces all prior versions.
+ *
+ * Copyright (c) 2013-2022, Esoteric Software LLC
+ *
+ * Integration of the Spine Runtimes into software or otherwise creating
+ * derivative works of the Spine Runtimes is permitted under the terms and
+ * conditions of Section 2 of the Spine Editor License Agreement:
+ * http://esotericsoftware.com/spine-editor-license
+ *
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
+ * "Products"), provided that each user of the Products must obtain their own
+ * Spine Editor license and redistribution of the Products in any form must
+ * include this license and copyright notice.
+ *
+ * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
+ * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *****************************************************************************/
+
+#if UNITY_EDITOR
+
+namespace Spine.Unity {
+
+	public static class BuildUtilities {
+		public static bool IsInSkeletonAssetBuildPreProcessing = false;
+		public static bool IsInSkeletonAssetBuildPostProcessing = false;
+		public static bool IsInSpriteAtlasBuildPreProcessing = false;
+		public static bool IsInSpriteAtlasBuildPostProcessing = false;
+	}
+}
+
+#endif

+ 11 - 0
spine-unity/Assets/Spine/Runtime/spine-unity/Utility/BuildUtilities.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a2f1169aaf0063f4da1c2b6033bbc13f
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: