Merge remote-tracking branch 'origin/master'

This commit is contained in:
NathanSweet 2016-02-17 03:54:11 +01:00
commit 0b56367409
7 changed files with 56 additions and 5 deletions

View File

@ -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));
}
}
}

View File

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

View File

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

View File

@ -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 System.Collections;
using UnityEditor; using UnityEditor;
@ -9,6 +13,7 @@ public class SkeletonGraphicInspector : Editor {
SerializedProperty material_, color_; SerializedProperty material_, color_;
SerializedProperty skeletonDataAsset_, initialSkinName_; SerializedProperty skeletonDataAsset_, initialSkinName_;
SerializedProperty startingAnimation_, startingLoop_, timeScale_, freeze_; SerializedProperty startingAnimation_, startingLoop_, timeScale_, freeze_;
#if !PREUNITY_5_2
SerializedProperty raycastTarget_; SerializedProperty raycastTarget_;
SkeletonGraphic thisSkeletonGraphic; SkeletonGraphic thisSkeletonGraphic;
@ -201,4 +206,5 @@ public class SkeletonGraphicInspector : Editor {
return go; return go;
} }
#endregion #endregion
#endif
} }

View File

@ -29,6 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/ *****************************************************************************/
#if (UNITY_5_0 || UNITY_5_1 || UNITY_4)
#define PREUNITY_5_2
#endif
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
using UnityEngine.UI; using UnityEngine.UI;
@ -54,8 +58,7 @@ public class SkeletonGraphic : MaskableGraphic {
protected override void OnValidate () { protected override void OnValidate () {
// This handles Scene View preview. // This handles Scene View preview.
base.OnValidate (); base.OnValidate ();
this.raycastTarget = false; #if !PREUNITY_5_2
if (this.IsValid) { if (this.IsValid) {
if (skeletonDataAsset == null) { if (skeletonDataAsset == null) {
Clear(); Clear();
@ -78,6 +81,9 @@ public class SkeletonGraphic : MaskableGraphic {
if (skeletonDataAsset != null) if (skeletonDataAsset != null)
Initialize(true); 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 #endif
#endregion #endregion
#if !PREUNITY_5_2
#region Internals #region Internals
// This is used by the UI system to determine what to put in the MaterialPropertyBlock. // This is used by the UI system to determine what to put in the MaterialPropertyBlock.
public override Texture mainTexture { public override Texture mainTexture {
@ -200,10 +207,11 @@ public class SkeletonGraphic : MaskableGraphic {
skeleton.SetColor(this.color); skeleton.SetColor(this.color);
if (canvas != null) if (canvas != null)
spineMeshGenerator.Scale = canvas.referencePixelsPerUnit; // TODO: move this to a listener to of the canvas? spineMeshGenerator.Scale = canvas.referencePixelsPerUnit; // TODO: move this to a listener to of the canvas?
canvasRenderer.SetMesh(spineMeshGenerator.GenerateMesh(skeleton)); canvasRenderer.SetMesh(spineMeshGenerator.GenerateMesh(skeleton));
this.UpdateMaterial(); this.UpdateMaterial();
} }
} }
#endregion #endregion
#endif
} }