diff --git a/spine-unity/Assets/Examples/Getting Started/1 The Spine GameObject.unity b/spine-unity/Assets/Examples/Getting Started/1 The Spine GameObject.unity index 4f5c68049..4b3446d3c 100644 Binary files a/spine-unity/Assets/Examples/Getting Started/1 The Spine GameObject.unity and b/spine-unity/Assets/Examples/Getting Started/1 The Spine GameObject.unity differ diff --git a/spine-unity/Assets/Examples/Getting Started/6 SkeletonGraphic.unity b/spine-unity/Assets/Examples/Getting Started/6 SkeletonGraphic.unity index 62e6fde23..fa4089acd 100644 Binary files a/spine-unity/Assets/Examples/Getting Started/6 SkeletonGraphic.unity and b/spine-unity/Assets/Examples/Getting Started/6 SkeletonGraphic.unity differ diff --git a/spine-unity/Assets/Examples/Getting Started/Scripts/SpineBlinkPlayer.cs b/spine-unity/Assets/Examples/Getting Started/Scripts/SpineBlinkPlayer.cs new file mode 100644 index 000000000..29dcfdfe5 --- /dev/null +++ b/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(); if (skeletonAnimation == null) yield break; + while (true) { + skeletonAnimation.state.SetAnimation(SpineBlinkPlayer.BlinkTrack, blinkAnimation, false); + yield return new WaitForSeconds(Random.Range(minimumDelay, maximumDelay)); + } + } + +} diff --git a/spine-unity/Assets/Examples/Getting Started/Scripts/SpineBlinkPlayer.cs.meta b/spine-unity/Assets/Examples/Getting Started/Scripts/SpineBlinkPlayer.cs.meta new file mode 100644 index 000000000..b92a8ad06 --- /dev/null +++ b/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: diff --git a/spine-unity/Assets/spine-unity/Modules/Mesh Generation Samples/VertexHelperSpineMeshGenerator.cs b/spine-unity/Assets/spine-unity/Modules/Mesh Generation Samples/VertexHelperSpineMeshGenerator.cs index a9e66cbed..dfaff1bc1 100644 --- a/spine-unity/Assets/spine-unity/Modules/Mesh Generation Samples/VertexHelperSpineMeshGenerator.cs +++ b/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 { /// This is for testing and educational purposes only. This takes about 10 times longer to render than ArraySpineMeshGenerator. 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 diff --git a/spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/Editor/SkeletonGraphicInspector.cs b/spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/Editor/SkeletonGraphicInspector.cs index 465266144..5a94fd04d 100644 --- a/spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/Editor/SkeletonGraphicInspector.cs +++ b/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 } \ No newline at end of file diff --git a/spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs b/spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs index 4d9b41cea..17fc73b5a 100644 --- a/spine-unity/Assets/spine-unity/Modules/SkeletonGraphic/SkeletonGraphic.cs +++ b/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 }