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

Merge remote-tracking branch 'origin/master'

NathanSweet 9 жил өмнө
parent
commit
0b56367409

BIN
spine-unity/Assets/Examples/Getting Started/1 The Spine GameObject.unity


BIN
spine-unity/Assets/Examples/Getting Started/6 SkeletonGraphic.unity


+ 20 - 0
spine-unity/Assets/Examples/Getting Started/Scripts/SpineBlinkPlayer.cs

@@ -0,0 +1,20 @@
+using UnityEngine;
+using System.Collections;
+
+public class SpineBlinkPlayer : MonoBehaviour {
+	const int BlinkTrack = 1;
+
+	[SpineAnimation]
+	public string blinkAnimation;
+	public float minimumDelay = 0.15f;
+	public float maximumDelay = 3f;
+
+	IEnumerator Start () {
+		var skeletonAnimation = GetComponent<SkeletonAnimation>(); if (skeletonAnimation == null) yield break;
+		while (true) {
+			skeletonAnimation.state.SetAnimation(SpineBlinkPlayer.BlinkTrack, blinkAnimation, false);
+			yield return new WaitForSeconds(Random.Range(minimumDelay, maximumDelay));
+		}
+	}
+
+}

+ 12 - 0
spine-unity/Assets/Examples/Getting Started/Scripts/SpineBlinkPlayer.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 5a5ef44bf3e0d864794c0da71c84363d
+timeCreated: 1455509353
+licenseType: Free
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 6 - 1
spine-unity/Assets/spine-unity/Modules/Mesh Generation Samples/VertexHelperSpineMeshGenerator.cs

@@ -29,10 +29,15 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
 
+#if (UNITY_5_0 || UNITY_5_1 || UNITY_4)
+#define PREUNITY_5_2
+#endif
+
 using UnityEngine;
 using System.Collections.Generic;
 using System.Collections;
 
+#if !(PREUNITY_5_2)
 namespace Spine.Unity {
 	/// <summary>This is for testing and educational purposes only. This takes about 10 times longer to render than ArraySpineMeshGenerator.</summary>
 	public class VertexHelperSpineMeshGenerator : ISimpleMeshGenerator {
@@ -94,7 +99,6 @@ namespace Spine.Unity {
 			mesh.SetUVs(0, uvs);
 			mesh.SetNormals(normals);
 			mesh.SetTriangles(indices, 0);
-
 			mesh.RecalculateBounds();
 		}
 
@@ -233,3 +237,4 @@ namespace Spine.Unity {
 	}
 
 }
+#endif

+ 7 - 1
spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/Editor/SkeletonGraphicInspector.cs

@@ -1,4 +1,8 @@
-using UnityEngine;
+#if (UNITY_5_0 || UNITY_5_1 || UNITY_4)
+#define PREUNITY_5_2
+#endif
+
+using UnityEngine;
 using System.Collections;
 
 using UnityEditor;
@@ -9,6 +13,7 @@ public class SkeletonGraphicInspector : Editor {
 	SerializedProperty material_, color_;
 	SerializedProperty skeletonDataAsset_, initialSkinName_;
 	SerializedProperty startingAnimation_, startingLoop_, timeScale_, freeze_;
+	#if !PREUNITY_5_2
 	SerializedProperty raycastTarget_;
 
 	SkeletonGraphic thisSkeletonGraphic;
@@ -201,4 +206,5 @@ public class SkeletonGraphicInspector : Editor {
 		return go;
 	}
 	#endregion
+	#endif
 }

+ 11 - 3
spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs

@@ -29,6 +29,10 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
 
+#if (UNITY_5_0 || UNITY_5_1 || UNITY_4)
+#define PREUNITY_5_2
+#endif
+
 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
@@ -54,8 +58,7 @@ public class SkeletonGraphic : MaskableGraphic {
 	protected override void OnValidate () {
 		// This handles Scene View preview.
 		base.OnValidate ();
-		this.raycastTarget = false;
-
+		#if !PREUNITY_5_2
 		if (this.IsValid) {
 			if (skeletonDataAsset == null) {
 				Clear();
@@ -78,6 +81,9 @@ public class SkeletonGraphic : MaskableGraphic {
 			if (skeletonDataAsset != null)
 				Initialize(true);
 		}
+		#else
+		Debug.LogWarning("SkeletonGraphic requres Unity 5.2 or higher.\nUnityEngine.UI 5.1 and below does not accept meshes and can't be used to render Spine skeletons. You may delete the SkeletonGraphic folder under `Modules` if you want to exclude it from your project." );
+		#endif
 			
 	}
 
@@ -90,6 +96,7 @@ public class SkeletonGraphic : MaskableGraphic {
 	#endif
 	#endregion
 
+	#if !PREUNITY_5_2
 	#region Internals
 	// This is used by the UI system to determine what to put in the MaterialPropertyBlock.
 	public override Texture mainTexture {
@@ -200,10 +207,11 @@ public class SkeletonGraphic : MaskableGraphic {
 			skeleton.SetColor(this.color);
 			if (canvas != null)
 				spineMeshGenerator.Scale = canvas.referencePixelsPerUnit; // TODO: move this to a listener to of the canvas?
-			
+
 			canvasRenderer.SetMesh(spineMeshGenerator.GenerateMesh(skeleton));
 			this.UpdateMaterial();
 		}
 	}
 	#endregion
+	#endif
 }