Browse Source

Formatted source, committed formatter policy.

NathanSweet 10 năm trước cách đây
mục cha
commit
2902fb2ec9
38 tập tin đã thay đổi với 1184 bổ sung1278 xóa
  1. 114 142
      spine-unity/Assets/Examples/Scripts/BasicPlatformerController.cs
  2. 0 2
      spine-unity/Assets/Examples/Scripts/ConstrainedCamera.cs
  3. 24 34
      spine-unity/Assets/Examples/Scripts/SpineboyController.cs
  4. 2 1
      spine-unity/Assets/Examples/Spine/Dragon/dragon.png.meta
  5. 2 1
      spine-unity/Assets/Examples/Spine/Dragon/dragon2.png.meta
  6. BIN
      spine-unity/Assets/Examples/Spine/Dragon/dragon_dragon.mat
  7. BIN
      spine-unity/Assets/Examples/Spine/Dragon/dragon_dragon2.mat
  8. 1 1
      spine-unity/Assets/Examples/Spine/Eyes/eyes.png.meta
  9. BIN
      spine-unity/Assets/Examples/Spine/Eyes/eyes_Material.mat
  10. 2 0
      spine-unity/Assets/Examples/Spine/Goblins/goblins-mesh.png.meta
  11. BIN
      spine-unity/Assets/Examples/Spine/Goblins/goblins-mesh_Material.mat
  12. BIN
      spine-unity/Assets/Examples/Spine/Hero/Hero_Material.mat
  13. 3 1
      spine-unity/Assets/Examples/Spine/Raptor/raptor.png.meta
  14. BIN
      spine-unity/Assets/Examples/Spine/Raptor/raptor_Material.mat
  15. 2 1
      spine-unity/Assets/Examples/Spine/Spineboy/spineboy.png.meta
  16. BIN
      spine-unity/Assets/Examples/Spine/Spineboy/spineboy_Material.mat
  17. 19 21
      spine-unity/Assets/spine-unity/BoneFollower.cs
  18. 0 1
      spine-unity/Assets/spine-unity/Editor/AtlasAssetInspector.cs
  19. 12 14
      spine-unity/Assets/spine-unity/Editor/BoneFollowerInspector.cs
  20. 2 2
      spine-unity/Assets/spine-unity/Editor/Menus.cs
  21. 10 10
      spine-unity/Assets/spine-unity/Editor/SkeletonAnimationInspector.cs
  22. 311 332
      spine-unity/Assets/spine-unity/Editor/SkeletonDataAssetInspector.cs
  23. 4 3
      spine-unity/Assets/spine-unity/Editor/SkeletonRendererInspector.cs
  24. 136 155
      spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs
  25. 13 8
      spine-unity/Assets/spine-unity/SkeletonAnimation.cs
  26. 2 1
      spine-unity/Assets/spine-unity/SkeletonDataAsset.cs
  27. 10 10
      spine-unity/Assets/spine-unity/SkeletonExtensions.cs
  28. 61 50
      spine-unity/Assets/spine-unity/SkeletonRenderer.cs
  29. 82 89
      spine-unity/Assets/spine-unity/SkeletonUtility/Editor/SkeletonUtilityBoneInspector.cs
  30. 65 70
      spine-unity/Assets/spine-unity/SkeletonUtility/Editor/SkeletonUtilityInspector.cs
  31. 63 69
      spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtility.cs
  32. 133 153
      spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilityBone.cs
  33. 3 3
      spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilityConstraint.cs
  34. 13 18
      spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilityEyeConstraint.cs
  35. 31 42
      spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilityGroundConstraint.cs
  36. 17 19
      spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilityKinematicShadow.cs
  37. 19 25
      spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilitySubmeshRenderer.cs
  38. 28 0
      spine-unity/Spine.mdpolicy

+ 114 - 142
spine-unity/Assets/Examples/Scripts/BasicPlatformerController.cs

@@ -39,196 +39,168 @@ using System.Collections;
 [RequireComponent(typeof(CharacterController))]
 public class BasicPlatformerController : MonoBehaviour {
 
-#if !UNITY_4_3 && !UNITY_4_4
+#if UNITY_4_5
     [Header("Controls")]
 #endif
-    public string XAxis = "Horizontal";
-    public string YAxis = "Vertical";
-    public string JumpButton = "Jump";
+	public string XAxis = "Horizontal";
+	public string YAxis = "Vertical";
+	public string JumpButton = "Jump";
 
-#if !UNITY_4_3 && !UNITY_4_4
+#if UNITY_4_5
 	[Header("Moving")]
 #endif
 	public float walkSpeed = 4;
-    public float runSpeed = 10;
-    public float gravity = 65;
+	public float runSpeed = 10;
+	public float gravity = 65;
 
-#if !UNITY_4_3 && !UNITY_4_4
+#if UNITY_4_5
 	[Header("Jumping")]
 #endif
 	public float jumpSpeed = 25;
-    public float jumpDuration = 0.5f;
-    public float jumpInterruptFactor = 100;
-    public float forceCrouchVelocity = 25;
-    public float forceCrouchDuration = 0.5f;
+	public float jumpDuration = 0.5f;
+	public float jumpInterruptFactor = 100;
+	public float forceCrouchVelocity = 25;
+	public float forceCrouchDuration = 0.5f;
 
-#if !UNITY_4_3 && !UNITY_4_4
+#if UNITY_4_5
 	[Header("Graphics")]
 #endif
 	public Transform graphicsRoot;
-    public SkeletonAnimation skeletonAnimation;
+	public SkeletonAnimation skeletonAnimation;
 
-#if !UNITY_4_3 && !UNITY_4_4
+#if UNITY_4_5
 	[Header("Animation")]
 #endif
 	public string walkName = "Walk";
-    public string runName = "Run";
-    public string idleName = "Idle";
-    public string jumpName = "Jump";
-    public string fallName = "Fall";
-    public string crouchName = "Crouch";
+	public string runName = "Run";
+	public string idleName = "Idle";
+	public string jumpName = "Jump";
+	public string fallName = "Fall";
+	public string crouchName = "Crouch";
 
-#if !UNITY_4_3 && !UNITY_4_4
+#if UNITY_4_5
 	[Header("Audio")]
 #endif
 	public AudioSource jumpAudioSource;
 	public AudioSource hardfallAudioSource;
 	public AudioSource footstepAudioSource;
 	public string footstepEventName = "Footstep";
-
-    
-    
-    CharacterController controller;
-    Vector2 velocity = Vector2.zero;
-    Vector2 lastVelocity = Vector2.zero;
-    bool lastGrounded = false;
-    float jumpEndTime = 0;
-    bool jumpInterrupt = false;
-    float forceCrouchEndTime;
-    
-
-    Quaternion flippedRotation = Quaternion.Euler(0, 180, 0);
-
-    void Awake() 
-    {
-        controller = GetComponent<CharacterController>();
+	CharacterController controller;
+	Vector2 velocity = Vector2.zero;
+	Vector2 lastVelocity = Vector2.zero;
+	bool lastGrounded = false;
+	float jumpEndTime = 0;
+	bool jumpInterrupt = false;
+	float forceCrouchEndTime;
+	Quaternion flippedRotation = Quaternion.Euler(0, 180, 0);
+
+	void Awake () {
+		controller = GetComponent<CharacterController>();
 	}
 
-	void Start(){
+	void Start () {
 		//register a callback for Spine Events (in this case, Footstep)
 		skeletonAnimation.state.Event += HandleEvent;
 	}
 
-    void HandleEvent (Spine.AnimationState state, int trackIndex, Spine.Event e)
-    {
+	void HandleEvent (Spine.AnimationState state, int trackIndex, Spine.Event e) {
 		//play some sound if footstep event fired
-		if(e.Data.Name == footstepEventName){
+		if (e.Data.Name == footstepEventName) {
 			footstepAudioSource.Stop();
 			footstepAudioSource.Play();
 		}
-    }
-
-    void Update()
-    {
-        //control inputs
-        float x = Input.GetAxis(XAxis);
-        float y = Input.GetAxis(YAxis);
-        //check for force crouch
-        bool crouching = (controller.isGrounded && y < -0.5f) || (forceCrouchEndTime > Time.time);
-        velocity.x = 0;
-
-        //Calculate control velocity
-        if (!crouching) { 
-            if (Input.GetButtonDown(JumpButton) && controller.isGrounded)
-            {
-                //jump
+	}
+
+	void Update () {
+		//control inputs
+		float x = Input.GetAxis(XAxis);
+		float y = Input.GetAxis(YAxis);
+		//check for force crouch
+		bool crouching = (controller.isGrounded && y < -0.5f) || (forceCrouchEndTime > Time.time);
+		velocity.x = 0;
+
+		//Calculate control velocity
+		if (!crouching) { 
+			if (Input.GetButtonDown(JumpButton) && controller.isGrounded) {
+				//jump
 				jumpAudioSource.Stop();
 				jumpAudioSource.Play();
-                velocity.y = jumpSpeed;
-                jumpEndTime = Time.time + jumpDuration;
-            }
-            else if (Time.time < jumpEndTime && Input.GetButtonUp(JumpButton))
-            {
-                jumpInterrupt = true;
-            }
+				velocity.y = jumpSpeed;
+				jumpEndTime = Time.time + jumpDuration;
+			} else if (Time.time < jumpEndTime && Input.GetButtonUp(JumpButton)) {
+					jumpInterrupt = true;
+				}
 
             
-            if (x != 0)
-            {
-                //walk or run
-                velocity.x = Mathf.Abs(x) > 0.6f ? runSpeed : walkSpeed;
-                velocity.x *= Mathf.Sign(x);
-            }
-
-            if (jumpInterrupt)
-            {
-                //interrupt jump and smoothly cut Y velocity
-                if (velocity.y > 0)
-                {
-                    velocity.y = Mathf.MoveTowards(velocity.y, 0, Time.deltaTime * 100);
-                }
-                else 
-                { 
-                    jumpInterrupt = false;
-                }
-            }
-        }
-
-        //apply gravity F = mA (Learn it, love it, live it)
-        velocity.y -= gravity * Time.deltaTime;
-
-        //move
-        controller.Move(new Vector3(velocity.x, velocity.y, 0) * Time.deltaTime);
+			if (x != 0) {
+				//walk or run
+				velocity.x = Mathf.Abs(x) > 0.6f ? runSpeed : walkSpeed;
+				velocity.x *= Mathf.Sign(x);
+			}
+
+			if (jumpInterrupt) {
+				//interrupt jump and smoothly cut Y velocity
+				if (velocity.y > 0) {
+					velocity.y = Mathf.MoveTowards(velocity.y, 0, Time.deltaTime * 100);
+				} else { 
+					jumpInterrupt = false;
+				}
+			}
+		}
+
+		//apply gravity F = mA (Learn it, love it, live it)
+		velocity.y -= gravity * Time.deltaTime;
+
+		//move
+		controller.Move(new Vector3(velocity.x, velocity.y, 0) * Time.deltaTime);
         
-        if (controller.isGrounded)
-        {
-            //cancel out Y velocity if on ground
-            velocity.y = -gravity * Time.deltaTime;
-            jumpInterrupt = false;
-        }
+		if (controller.isGrounded) {
+			//cancel out Y velocity if on ground
+			velocity.y = -gravity * Time.deltaTime;
+			jumpInterrupt = false;
+		}
 
         
-        Vector2 deltaVelocity = lastVelocity - velocity;
-
-        if (!lastGrounded && controller.isGrounded)
-        {
-            //detect hard fall
-            if ((gravity*Time.deltaTime) - deltaVelocity.y > forceCrouchVelocity)
-            {
-                forceCrouchEndTime = Time.time + forceCrouchDuration;
+		Vector2 deltaVelocity = lastVelocity - velocity;
+
+		if (!lastGrounded && controller.isGrounded) {
+			//detect hard fall
+			if ((gravity * Time.deltaTime) - deltaVelocity.y > forceCrouchVelocity) {
+				forceCrouchEndTime = Time.time + forceCrouchDuration;
 				hardfallAudioSource.Play();
-            }
-			else{
+			} else {
 				//play footstep audio if light fall because why not
 				footstepAudioSource.Play();
 			}
             
-        }
-
-        //graphics updates
-        if (controller.isGrounded)
-        {
-            if (crouching) //crouch
-            {
-                skeletonAnimation.AnimationName = crouchName;
-            }
-            else
-            {
-
-                if (x == 0) //idle
-                    skeletonAnimation.AnimationName = idleName;
-                else //move
-                    skeletonAnimation.AnimationName = Mathf.Abs(x) > 0.6f ? runName : walkName;
-            }
-        }
-        else
-        {
-            if (velocity.y > 0) //jump
-                skeletonAnimation.AnimationName = jumpName;
-            else //fall
-                skeletonAnimation.AnimationName = fallName;
-            
-        }
+		}
 
-        //flip left or right
-        if (x > 0)
-            graphicsRoot.localRotation = Quaternion.identity;
-        else if (x < 0)
-            graphicsRoot.localRotation = flippedRotation;
+		//graphics updates
+		if (controller.isGrounded) {
+			if (crouching) { //crouch
+				skeletonAnimation.AnimationName = crouchName;
+			} else {
+				if (x == 0) //idle
+					skeletonAnimation.AnimationName = idleName;
+				else //move
+					skeletonAnimation.AnimationName = Mathf.Abs(x) > 0.6f ? runName : walkName;
+			}
+		} else {
+			if (velocity.y > 0) //jump
+				skeletonAnimation.AnimationName = jumpName;
+			else //fall
+				skeletonAnimation.AnimationName = fallName;
+		}
 
+		//flip left or right
+		if (x > 0)
+			graphicsRoot.localRotation = Quaternion.identity;
+		else if (x < 0)
+				graphicsRoot.localRotation = flippedRotation;
 
-        //store previous state
-        lastVelocity = velocity;
-        lastGrounded = controller.isGrounded;
-    }
+
+		//store previous state
+		lastVelocity = velocity;
+		lastGrounded = controller.isGrounded;
+	}
 }

+ 0 - 2
spine-unity/Assets/Examples/Scripts/ConstrainedCamera.cs

@@ -39,10 +39,8 @@ using System.Collections;
 public class ConstrainedCamera : MonoBehaviour {
 	public Transform target;
 	public Vector3 offset;
-
 	public Vector3 min;
 	public Vector3 max;
-
 	public float smoothing = 5f;
 	
 	// Use this for initialization

+ 24 - 34
spine-unity/Assets/Examples/Scripts/SpineboyController.cs

@@ -5,19 +5,15 @@ using System.Collections;
 public class SpineboyController : MonoBehaviour {
 
 	SkeletonAnimation skeletonAnimation;
-
 	public string idleAnimation = "idle";
 	public string walkAnimation = "walk";
 	public string runAnimation = "run";
 	public string hitAnimation = "hit";
 	public string deathAnimation = "death";
-
 	public float walkVelocity = 1;
 	public float runVelocity = 3;
 	public int hp = 10;
-
 	string currentAnimation = "";
-
 	bool hit = false;
 	bool dead = false;
 
@@ -25,59 +21,53 @@ public class SpineboyController : MonoBehaviour {
 		skeletonAnimation = GetComponent<SkeletonAnimation>();
 	}
 
-
-	void Update(){
-		if(!dead){
+	void Update () {
+		if (!dead) {
 			float x = Input.GetAxis("Horizontal");
 			float absX = Mathf.Abs(x);
 
-			if(!hit){
-				if(x > 0)
+			if (!hit) {
+				if (x > 0)
 					skeletonAnimation.skeleton.FlipX = false;
-				else if(x < 0)
-					skeletonAnimation.skeleton.FlipX = true;
+				else if (x < 0)
+						skeletonAnimation.skeleton.FlipX = true;
 
-				if(absX > 0.7f){
+				if (absX > 0.7f) {
 					SetAnimation(runAnimation, true);
-					rigidbody2D.velocity = new Vector2( runVelocity * Mathf.Sign(x), rigidbody2D.velocity.y);
-				}
-				else if(absX > 0){
-					SetAnimation(walkAnimation, true);
-					rigidbody2D.velocity = new Vector2( walkVelocity * Mathf.Sign(x), rigidbody2D.velocity.y);
-				}
-				else{
-					SetAnimation(idleAnimation, true);
-					rigidbody2D.velocity = new Vector2( 0, rigidbody2D.velocity.y);
-				}
-			}
-			else{
-				if(skeletonAnimation.state.GetCurrent(0).Animation.Name != hitAnimation)
+					rigidbody2D.velocity = new Vector2(runVelocity * Mathf.Sign(x), rigidbody2D.velocity.y);
+				} else if (absX > 0) {
+						SetAnimation(walkAnimation, true);
+						rigidbody2D.velocity = new Vector2(walkVelocity * Mathf.Sign(x), rigidbody2D.velocity.y);
+					} else {
+						SetAnimation(idleAnimation, true);
+						rigidbody2D.velocity = new Vector2(0, rigidbody2D.velocity.y);
+					}
+			} else {
+				if (skeletonAnimation.state.GetCurrent(0).Animation.Name != hitAnimation)
 					hit = false;
 			}
 		}
 	}
 
-
-	void SetAnimation(string anim, bool loop){
-		if(currentAnimation != anim){
+	void SetAnimation (string anim, bool loop) {
+		if (currentAnimation != anim) {
 			skeletonAnimation.state.SetAnimation(0, anim, loop);
 			currentAnimation = anim;
 		}
 	}
 
-	void OnMouseUp(){
+	void OnMouseUp () {
 
-		if(hp > 0){
+		if (hp > 0) {
 			hp--;
 
-			if(hp == 0){
+			if (hp == 0) {
 				SetAnimation(deathAnimation, false);
 				dead = true;
-			}
-			else{
+			} else {
 				skeletonAnimation.state.SetAnimation(0, hitAnimation, false);
 				skeletonAnimation.state.AddAnimation(0, currentAnimation, true, 0);
-				rigidbody2D.velocity = new Vector2( 0, rigidbody2D.velocity.y);
+				rigidbody2D.velocity = new Vector2(0, rigidbody2D.velocity.y);
 				hit = true;
 			}
 

+ 2 - 1
spine-unity/Assets/Examples/Spine/Dragon/dragon.png.meta

@@ -1,6 +1,7 @@
 fileFormatVersion: 2
 guid: 6bc52290ef03f2846ba38d67e2823598
 TextureImporter:
+  fileIDToRecycleName: {}
   serializedVersion: 2
   mipmaps:
     mipMapMode: 0
@@ -21,7 +22,7 @@ TextureImporter:
   generateCubemap: 0
   seamlessCubemap: 0
   textureFormat: -3
-  maxTextureSize: 1024
+  maxTextureSize: 2048
   textureSettings:
     filterMode: -1
     aniso: -1

+ 2 - 1
spine-unity/Assets/Examples/Spine/Dragon/dragon2.png.meta

@@ -1,6 +1,7 @@
 fileFormatVersion: 2
 guid: 12c126994123f12468cf4c5a2684078a
 TextureImporter:
+  fileIDToRecycleName: {}
   serializedVersion: 2
   mipmaps:
     mipMapMode: 0
@@ -21,7 +22,7 @@ TextureImporter:
   generateCubemap: 0
   seamlessCubemap: 0
   textureFormat: -3
-  maxTextureSize: 1024
+  maxTextureSize: 2048
   textureSettings:
     filterMode: -1
     aniso: -1

BIN
spine-unity/Assets/Examples/Spine/Dragon/dragon_dragon.mat


BIN
spine-unity/Assets/Examples/Spine/Dragon/dragon_dragon2.mat


+ 1 - 1
spine-unity/Assets/Examples/Spine/Eyes/eyes.png.meta

@@ -22,7 +22,7 @@ TextureImporter:
   generateCubemap: 0
   seamlessCubemap: 0
   textureFormat: -3
-  maxTextureSize: 1024
+  maxTextureSize: 2048
   textureSettings:
     filterMode: -1
     aniso: -1

BIN
spine-unity/Assets/Examples/Spine/Eyes/eyes_Material.mat


+ 2 - 0
spine-unity/Assets/Examples/Spine/Goblins/goblins-mesh.png.meta

@@ -1,6 +1,7 @@
 fileFormatVersion: 2
 guid: 803c2e614a63081439fde6276d110661
 TextureImporter:
+  fileIDToRecycleName: {}
   serializedVersion: 2
   mipmaps:
     mipMapMode: 0
@@ -35,6 +36,7 @@ TextureImporter:
   spriteMeshType: 1
   alignment: 0
   spritePivot: {x: .5, y: .5}
+  spriteBorder: {x: 0, y: 0, z: 0, w: 0}
   spritePixelsToUnits: 100
   alphaIsTransparency: 0
   textureType: -1

BIN
spine-unity/Assets/Examples/Spine/Goblins/goblins-mesh_Material.mat


BIN
spine-unity/Assets/Examples/Spine/Hero/Hero_Material.mat


+ 3 - 1
spine-unity/Assets/Examples/Spine/Raptor/raptor.png.meta

@@ -1,6 +1,7 @@
 fileFormatVersion: 2
 guid: 4261719a8f729a644b2dab6113d1b0ea
 TextureImporter:
+  fileIDToRecycleName: {}
   serializedVersion: 2
   mipmaps:
     mipMapMode: 0
@@ -21,7 +22,7 @@ TextureImporter:
   generateCubemap: 0
   seamlessCubemap: 0
   textureFormat: -3
-  maxTextureSize: 1024
+  maxTextureSize: 2048
   textureSettings:
     filterMode: -1
     aniso: -1
@@ -35,6 +36,7 @@ TextureImporter:
   spriteMeshType: 1
   alignment: 0
   spritePivot: {x: .5, y: .5}
+  spriteBorder: {x: 0, y: 0, z: 0, w: 0}
   spritePixelsToUnits: 100
   alphaIsTransparency: 0
   textureType: -1

BIN
spine-unity/Assets/Examples/Spine/Raptor/raptor_Material.mat


+ 2 - 1
spine-unity/Assets/Examples/Spine/Spineboy/spineboy.png.meta

@@ -1,6 +1,7 @@
 fileFormatVersion: 2
 guid: 49bb65eefe08e424bbf7a38bc98ec638
 TextureImporter:
+  fileIDToRecycleName: {}
   serializedVersion: 2
   mipmaps:
     mipMapMode: 0
@@ -21,7 +22,7 @@ TextureImporter:
   generateCubemap: 0
   seamlessCubemap: 0
   textureFormat: -3
-  maxTextureSize: 1024
+  maxTextureSize: 2048
   textureSettings:
     filterMode: -1
     aniso: -1

BIN
spine-unity/Assets/Examples/Spine/Spineboy/spineboy_Material.mat


+ 19 - 21
spine-unity/Assets/spine-unity/BoneFollower.cs

@@ -40,11 +40,10 @@ using Spine;
 public class BoneFollower : MonoBehaviour {
 
 	[System.NonSerialized]
-	public bool valid;
-
+	public bool
+		valid;
 	public SkeletonRenderer skeletonRenderer;
 	public Bone bone;
-
 	public bool followZPosition = true;
 	public bool followBoneRotation = true;
 
@@ -52,20 +51,18 @@ public class BoneFollower : MonoBehaviour {
 		get { return skeletonRenderer; }
 		set {
 			skeletonRenderer = value;
-			Reset ();
+			Reset();
 		}
 	}
 
 
 	/// <summary>If a bone isn't set, boneName is used to find the bone.</summary>
 	public String boneName;
-
 	public bool resetOnAwake = true;
-
 	protected Transform cachedTransform;
 	protected Transform skeletonTransform;
 
-	public void HandleResetRenderer(SkeletonRenderer skeletonRenderer){
+	public void HandleResetRenderer (SkeletonRenderer skeletonRenderer) {
 		Reset();
 	}
 
@@ -73,32 +70,32 @@ public class BoneFollower : MonoBehaviour {
 		bone = null;
 		cachedTransform = transform;
 		valid = skeletonRenderer != null && skeletonRenderer.valid;
-		if (!valid) return;
+		if (!valid)
+			return;
 		skeletonTransform = skeletonRenderer.transform;
 
 		skeletonRenderer.OnReset -= HandleResetRenderer;
 		skeletonRenderer.OnReset += HandleResetRenderer;
 
-		if(Application.isEditor)
+		if (Application.isEditor)
 			DoUpdate();
 	}
 
-	void OnDestroy(){
+	void OnDestroy () {
 		//cleanup
-		if(skeletonRenderer != null)
+		if (skeletonRenderer != null)
 			skeletonRenderer.OnReset -= HandleResetRenderer;
 	}
 
 	public void Awake () {
-		if(resetOnAwake)
+		if (resetOnAwake)
 			Reset();
 	}
 
-	void LateUpdate(){
+	void LateUpdate () {
 		DoUpdate();
 	}
 
-
 	public void DoUpdate () {
 		if (!valid) {
 			Reset();
@@ -106,13 +103,13 @@ public class BoneFollower : MonoBehaviour {
 		}
 
 		if (bone == null) {
-			if (boneName == null || boneName.Length == 0) return;
+			if (boneName == null || boneName.Length == 0)
+				return;
 			bone = skeletonRenderer.skeleton.FindBone(boneName);
 			if (bone == null) {
 				Debug.LogError("Bone not found: " + boneName, this);
 				return;
-			}
-			else{
+			} else {
 
 			}
 		}
@@ -123,21 +120,22 @@ public class BoneFollower : MonoBehaviour {
 		if (cachedTransform.parent == skeletonTransform) {
 			cachedTransform.localPosition = new Vector3(bone.worldX, bone.worldY, followZPosition ? 0f : cachedTransform.localPosition.z);
 
-			if(followBoneRotation) {
+			if (followBoneRotation) {
 				Vector3 rotation = cachedTransform.localRotation.eulerAngles;
 				cachedTransform.localRotation = Quaternion.Euler(rotation.x, rotation.y, bone.worldRotation * flipRotation);
 			}
 
 		} else {
 			Vector3 targetWorldPosition = skeletonTransform.TransformPoint(new Vector3(bone.worldX, bone.worldY, 0f));
-			if(!followZPosition) targetWorldPosition.z = cachedTransform.position.z;
+			if (!followZPosition)
+				targetWorldPosition.z = cachedTransform.position.z;
 
 			cachedTransform.position = targetWorldPosition;
 
-			if(followBoneRotation) {
+			if (followBoneRotation) {
 				Vector3 rotation = skeletonTransform.rotation.eulerAngles;
 
-				cachedTransform.rotation = Quaternion.Euler(rotation.x, rotation.y, skeletonTransform.rotation.eulerAngles.z + (bone.worldRotation * flipRotation) );
+				cachedTransform.rotation = Quaternion.Euler(rotation.x, rotation.y, skeletonTransform.rotation.eulerAngles.z + (bone.worldRotation * flipRotation));
 			}
 		}
 

+ 0 - 1
spine-unity/Assets/spine-unity/Editor/AtlasAssetInspector.cs

@@ -27,7 +27,6 @@
  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
-
 using System;
 using UnityEditor;
 using UnityEngine;

+ 12 - 14
spine-unity/Assets/spine-unity/Editor/BoneFollowerInspector.cs

@@ -27,7 +27,6 @@
  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
-
 using System;
 using UnityEditor;
 using UnityEngine;
@@ -36,6 +35,7 @@ using UnityEngine;
 public class BoneFollowerInspector : Editor {
 	private SerializedProperty boneName, skeletonRenderer, followZPosition, followBoneRotation;
 	BoneFollower component;
+
 	void OnEnable () {
 		skeletonRenderer = serializedObject.FindProperty("skeletonRenderer");
 		boneName = serializedObject.FindProperty("boneName");
@@ -45,20 +45,20 @@ public class BoneFollowerInspector : Editor {
 		ForceReload();
 	}
 
-	void FindRenderer(){
-		if(skeletonRenderer.objectReferenceValue == null){
-			SkeletonRenderer parentRenderer = SkeletonUtility.GetInParent<SkeletonRenderer>( component.transform );
+	void FindRenderer () {
+		if (skeletonRenderer.objectReferenceValue == null) {
+			SkeletonRenderer parentRenderer = SkeletonUtility.GetInParent<SkeletonRenderer>(component.transform);
 
-			if(parentRenderer != null){
+			if (parentRenderer != null) {
 				skeletonRenderer.objectReferenceValue = (UnityEngine.Object)parentRenderer;
 			}
 
 		}
 	}
 
-	void ForceReload(){
-		if(component.skeletonRenderer != null){
-			if(component.skeletonRenderer.valid == false)
+	void ForceReload () {
+		if (component.skeletonRenderer != null) {
+			if (component.skeletonRenderer.valid == false)
 				component.skeletonRenderer.Reset();
 		}
 	}
@@ -72,10 +72,9 @@ public class BoneFollowerInspector : Editor {
 
 		if (component.valid) {
 			String[] bones = new String[1];
-			try{
+			try {
 				bones = new String[component.skeletonRenderer.skeleton.Data.Bones.Count + 1];
-			}
-			catch{
+			} catch {
 
 			}
 
@@ -94,13 +93,12 @@ public class BoneFollowerInspector : Editor {
 			boneName.stringValue = boneIndex == 0 ? null : bones[boneIndex];
 			EditorGUILayout.PropertyField(followBoneRotation);
 			EditorGUILayout.PropertyField(followZPosition);
-		}
-		else{
+		} else {
 			GUILayout.Label("INVALID");
 		}
 
 		if (serializedObject.ApplyModifiedProperties() ||
-	    	(Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
+			(Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
 	    ) {
 			component.Reset();
 		}

+ 2 - 2
spine-unity/Assets/spine-unity/Editor/Menus.cs

@@ -27,7 +27,6 @@
  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
-
 using System;
 using System.IO;
 using UnityEditor;
@@ -50,7 +49,8 @@ public class Menus {
 		var selected = Selection.activeObject;
 		if (selected != null) {
 			var assetDir = AssetDatabase.GetAssetPath(selected.GetInstanceID());
-			if (assetDir.Length > 0 && Directory.Exists(assetDir)) dir = assetDir + "/";
+			if (assetDir.Length > 0 && Directory.Exists(assetDir))
+				dir = assetDir + "/";
 		}
 		ScriptableObject asset = ScriptableObject.CreateInstance<T>();
 		AssetDatabase.CreateAsset(asset, dir + name + ".asset");

+ 10 - 10
spine-unity/Assets/spine-unity/Editor/SkeletonAnimationInspector.cs

@@ -27,7 +27,6 @@
  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
-
 using System;
 using UnityEditor;
 using UnityEngine;
@@ -44,7 +43,7 @@ public class SkeletonAnimationInspector : SkeletonRendererInspector {
 		loop = serializedObject.FindProperty("loop");
 		timeScale = serializedObject.FindProperty("timeScale");
 
-		if(PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab)
+		if (PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab)
 			isPrefab = true;
 
 
@@ -54,13 +53,14 @@ public class SkeletonAnimationInspector : SkeletonRendererInspector {
 		base.gui();
 
 		SkeletonAnimation component = (SkeletonAnimation)target;
-		if (!component.valid) return;
+		if (!component.valid)
+			return;
 
 		//catch case where SetAnimation was used to set track 0 without using AnimationName
-		if(Application.isPlaying){
+		if (Application.isPlaying) {
 			TrackEntry currentState = component.state.GetCurrent(0);
-			if(currentState != null){
-				if(component.AnimationName != animationName.stringValue){
+			if (currentState != null) {
+				if (component.AnimationName != animationName.stringValue) {
 					animationName.stringValue = currentState.Animation.Name;
 				}
 			}
@@ -86,7 +86,7 @@ public class SkeletonAnimationInspector : SkeletonRendererInspector {
 			EditorGUILayout.EndHorizontal();
 
 			String selectedAnimationName = animationIndex == 0 ? null : animations[animationIndex];
-			if(component.AnimationName != selectedAnimationName){
+			if (component.AnimationName != selectedAnimationName) {
 				component.AnimationName = selectedAnimationName;
 				animationName.stringValue = selectedAnimationName;
 			}
@@ -100,9 +100,9 @@ public class SkeletonAnimationInspector : SkeletonRendererInspector {
 
 		EditorGUILayout.Space();
 
-		if(!isPrefab){
-			if(component.GetComponent<SkeletonUtility>() == null){
-				if(GUILayout.Button(new GUIContent("Add Skeleton Utility", SpineEditorUtilities.Icons.skeletonUtility), GUILayout.Height(30))){
+		if (!isPrefab) {
+			if (component.GetComponent<SkeletonUtility>() == null) {
+				if (GUILayout.Button(new GUIContent("Add Skeleton Utility", SpineEditorUtilities.Icons.skeletonUtility), GUILayout.Height(30))) {
 					component.gameObject.AddComponent<SkeletonUtility>();
 				}
 			}

+ 311 - 332
spine-unity/Assets/spine-unity/Editor/SkeletonDataAssetInspector.cs

@@ -32,10 +32,10 @@
  * Automatic import and advanced preview added by Mitch Thompson
  * Full irrevocable rights and permissions granted to Esoteric Software
 *****************************************************************************/
-
 using System;
 using System.Collections.Generic;
 using UnityEditor;
+
 #if !UNITY_4_3
 using UnityEditor.AnimatedValues;
 #endif
@@ -58,7 +58,7 @@ public class SkeletonDataAssetInspector : Editor {
 	private string m_skeletonDataAssetGUID;
 	
 	void OnEnable () {
-		try{
+		try {
 
 			atlasAsset = serializedObject.FindProperty("atlasAsset");
 			skeletonJSON = serializedObject.FindProperty("skeletonJSON");
@@ -69,23 +69,21 @@ public class SkeletonDataAssetInspector : Editor {
 			defaultMix = serializedObject.FindProperty("defaultMix");
 			
 			m_skeletonDataAsset = (SkeletonDataAsset)target;
-			m_skeletonDataAssetGUID = AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath(m_skeletonDataAsset) );
+			m_skeletonDataAssetGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m_skeletonDataAsset));
 			
 			EditorApplication.update += Update;
 
-		}
-		catch{
+		} catch {
 
 
 		}
 	}
 	
-	void OnDestroy(){
+	void OnDestroy () {
 		m_initialized = false;
 		EditorApplication.update -= Update;
 		this.DestroyPreviewInstances();
-		if (this.m_previewUtility != null)
-		{
+		if (this.m_previewUtility != null) {
 			this.m_previewUtility.Cleanup();
 			this.m_previewUtility = null;
 		}
@@ -99,8 +97,8 @@ public class SkeletonDataAssetInspector : Editor {
 		EditorGUILayout.PropertyField(atlasAsset);
 		EditorGUILayout.PropertyField(skeletonJSON);
 		EditorGUILayout.PropertyField(scale);
-		if(EditorGUI.EndChangeCheck()){
-			if(m_previewUtility != null){
+		if (EditorGUI.EndChangeCheck()) {
+			if (m_previewUtility != null) {
 				m_previewUtility.Cleanup();
 				m_previewUtility = null;
 			}
@@ -143,7 +141,7 @@ public class SkeletonDataAssetInspector : Editor {
 				EditorGUILayout.EndHorizontal();
 			}
 			
-			if(GUILayout.Button(new GUIContent("Setup Pose", SpineEditorUtilities.Icons.skeleton),  GUILayout.Width(105), GUILayout.Height(18))){
+			if (GUILayout.Button(new GUIContent("Setup Pose", SpineEditorUtilities.Icons.skeleton), GUILayout.Width(105), GUILayout.Height(18))) {
 				StopAnimation();
 				m_skeletonAnimation.skeleton.SetToSetupPose();
 				m_requireRefresh = true;
@@ -152,357 +150,342 @@ public class SkeletonDataAssetInspector : Editor {
 			#if UNITY_4_3
 			m_showAnimationList = EditorGUILayout.Foldout(m_showAnimationList, new GUIContent("Animations", SpineEditorUtilities.Icons.animationRoot));
 			if(m_showAnimationList){
-				#else
-				m_showAnimationList.target = EditorGUILayout.Foldout(m_showAnimationList.target, new GUIContent("Animations", SpineEditorUtilities.Icons.animationRoot));
-				if(EditorGUILayout.BeginFadeGroup(m_showAnimationList.faded)){
-					#endif
+			#else
+			m_showAnimationList.target = EditorGUILayout.Foldout(m_showAnimationList.target, new GUIContent("Animations", SpineEditorUtilities.Icons.animationRoot));
+			if (EditorGUILayout.BeginFadeGroup(m_showAnimationList.faded)) {
+				#endif
 					
 					
 					
 					
-					EditorGUILayout.LabelField("Name", "Duration");
-					foreach(Spine.Animation a in skeletonData.Animations){
-						GUILayout.BeginHorizontal();
+				EditorGUILayout.LabelField("Name", "Duration");
+				foreach (Spine.Animation a in skeletonData.Animations) {
+					GUILayout.BeginHorizontal();
 						
-						if(m_skeletonAnimation != null && m_skeletonAnimation.state != null){
-							if(m_skeletonAnimation.state.GetCurrent(0) != null && m_skeletonAnimation.state.GetCurrent(0).Animation == a){
-								GUI.contentColor = Color.black;
-								if(GUILayout.Button("\u25BA", GUILayout.Width(24))){
-									StopAnimation();
-								}
-								GUI.contentColor = Color.white;
+					if (m_skeletonAnimation != null && m_skeletonAnimation.state != null) {
+						if (m_skeletonAnimation.state.GetCurrent(0) != null && m_skeletonAnimation.state.GetCurrent(0).Animation == a) {
+							GUI.contentColor = Color.black;
+							if (GUILayout.Button("\u25BA", GUILayout.Width(24))) {
+								StopAnimation();
 							}
-							else{
-								if(GUILayout.Button("\u25BA", GUILayout.Width(24))){
-									PlayAnimation(a.Name, true);
-								}
+							GUI.contentColor = Color.white;
+						} else {
+							if (GUILayout.Button("\u25BA", GUILayout.Width(24))) {
+								PlayAnimation(a.Name, true);
 							}
 						}
-						else{
-							GUILayout.Label("?", GUILayout.Width(24));
-						}
-						EditorGUILayout.LabelField(new GUIContent(a.Name, SpineEditorUtilities.Icons.animation), new GUIContent(a.Duration.ToString("f3") + "s" +  ("(" + (Mathf.RoundToInt(a.Duration * 30)) + ")").PadLeft(12, ' ')));
-						GUILayout.EndHorizontal();
+					} else {
+						GUILayout.Label("?", GUILayout.Width(24));
 					}
+					EditorGUILayout.LabelField(new GUIContent(a.Name, SpineEditorUtilities.Icons.animation), new GUIContent(a.Duration.ToString("f3") + "s" + ("(" + (Mathf.RoundToInt(a.Duration * 30)) + ")").PadLeft(12, ' ')));
+					GUILayout.EndHorizontal();
 				}
-				#if !UNITY_4_3
-				EditorGUILayout.EndFadeGroup();
-				#endif
 			}
+			#if !UNITY_4_3
+			EditorGUILayout.EndFadeGroup();
+			#endif
+		}
 			
-			if (!Application.isPlaying) {
-				if (serializedObject.ApplyModifiedProperties() ||
-				    (UnityEngine.Event.current.type == EventType.ValidateCommand && UnityEngine.Event.current.commandName == "UndoRedoPerformed")
+		if (!Application.isPlaying) {
+			if (serializedObject.ApplyModifiedProperties() ||
+				(UnityEngine.Event.current.type == EventType.ValidateCommand && UnityEngine.Event.current.commandName == "UndoRedoPerformed")
 				    ) {
-					asset.Reset();
-				}
+				asset.Reset();
 			}
 		}
+	}
 		
-		//preview window stuff
-		private PreviewRenderUtility m_previewUtility;
-		private GameObject m_previewInstance;
-		private Vector2 previewDir;
-		private SkeletonAnimation m_skeletonAnimation;
-		private SkeletonData m_skeletonData;
-		
-		private static int sliderHash = "Slider".GetHashCode();
-		private float m_lastTime;
-		private bool m_playing;
-		private bool m_requireRefresh;
-		
-		private Color m_originColor = new Color(0.3f,0.3f,0.3f, 1);
-		
-		private void StopAnimation(){
-			m_skeletonAnimation.state.ClearTrack(0);
-			m_playing = false;
-		}
+	//preview window stuff
+	private PreviewRenderUtility m_previewUtility;
+	private GameObject m_previewInstance;
+	private Vector2 previewDir;
+	private SkeletonAnimation m_skeletonAnimation;
+	private SkeletonData m_skeletonData;
+	private static int sliderHash = "Slider".GetHashCode();
+	private float m_lastTime;
+	private bool m_playing;
+	private bool m_requireRefresh;
+	private Color m_originColor = new Color(0.3f, 0.3f, 0.3f, 1);
 		
+	private void StopAnimation () {
+		m_skeletonAnimation.state.ClearTrack(0);
+		m_playing = false;
+	}
 		
-		List<Spine.Event> m_animEvents = new List<Spine.Event>();
-		List<float> m_animEventFrames = new List<float>();
-		private void PlayAnimation(string animName, bool loop){
-			m_animEvents.Clear();
-			m_animEventFrames.Clear();
-			
-			m_skeletonAnimation.state.SetAnimation(0, animName, loop);
-			
-			Spine.Animation a = m_skeletonAnimation.state.GetCurrent(0).Animation;
-			foreach(Timeline t in a.Timelines){
-				if(t.GetType() == typeof(EventTimeline)){
-					EventTimeline et = (EventTimeline)t;
-					
-					for(int i = 0; i < et.Events.Length; i++){
-						m_animEvents.Add(et.Events[i]);
-						m_animEventFrames.Add(et.Frames[i]);
-					}
+	List<Spine.Event> m_animEvents = new List<Spine.Event>();
+	List<float> m_animEventFrames = new List<float>();
+
+	private void PlayAnimation (string animName, bool loop) {
+		m_animEvents.Clear();
+		m_animEventFrames.Clear();
+			
+		m_skeletonAnimation.state.SetAnimation(0, animName, loop);
+			
+		Spine.Animation a = m_skeletonAnimation.state.GetCurrent(0).Animation;
+		foreach (Timeline t in a.Timelines) {
+			if (t.GetType() == typeof(EventTimeline)) {
+				EventTimeline et = (EventTimeline)t;
 					
+				for (int i = 0; i < et.Events.Length; i++) {
+					m_animEvents.Add(et.Events[i]);
+					m_animEventFrames.Add(et.Frames[i]);
 				}
+					
 			}
-			
-			m_playing = true;
 		}
+			
+		m_playing = true;
+	}
 		
-		private void InitPreview()
-		{
-			if (this.m_previewUtility == null)
-			{
-				this.m_lastTime = Time.realtimeSinceStartup;
-				this.m_previewUtility = new PreviewRenderUtility(true);
-				this.m_previewUtility.m_Camera.isOrthoGraphic = true;
-				this.m_previewUtility.m_Camera.orthographicSize = 1;
-				this.m_previewUtility.m_Camera.cullingMask = -2147483648;
-				this.CreatePreviewInstances();
-			}
+	private void InitPreview () {
+		if (this.m_previewUtility == null) {
+			this.m_lastTime = Time.realtimeSinceStartup;
+			this.m_previewUtility = new PreviewRenderUtility(true);
+			this.m_previewUtility.m_Camera.isOrthoGraphic = true;
+			this.m_previewUtility.m_Camera.orthographicSize = 1;
+			this.m_previewUtility.m_Camera.cullingMask = -2147483648;
+			this.CreatePreviewInstances();
 		}
+	}
 		
-		private void CreatePreviewInstances()
-		{
-			this.DestroyPreviewInstances();
-			if (this.m_previewInstance == null)
-			{
-				string skinName = EditorPrefs.GetString(m_skeletonDataAssetGUID + "_lastSkin", "");
+	private void CreatePreviewInstances () {
+		this.DestroyPreviewInstances();
+		if (this.m_previewInstance == null) {
+			string skinName = EditorPrefs.GetString(m_skeletonDataAssetGUID + "_lastSkin", "");
 				
-				m_previewInstance = SpineEditorUtilities.SpawnAnimatedSkeleton( (SkeletonDataAsset)target, skinName ).gameObject;
-				m_previewInstance.hideFlags = HideFlags.HideAndDontSave;
-				m_previewInstance.layer = 0x1f;
+			m_previewInstance = SpineEditorUtilities.SpawnAnimatedSkeleton((SkeletonDataAsset)target, skinName).gameObject;
+			m_previewInstance.hideFlags = HideFlags.HideAndDontSave;
+			m_previewInstance.layer = 0x1f;
 				
 				
-				m_skeletonAnimation = m_previewInstance.GetComponent<SkeletonAnimation>();
-				m_skeletonAnimation.initialSkinName = skinName;
-				m_skeletonAnimation.LateUpdate();
+			m_skeletonAnimation = m_previewInstance.GetComponent<SkeletonAnimation>();
+			m_skeletonAnimation.initialSkinName = skinName;
+			m_skeletonAnimation.LateUpdate();
 				
-				m_skeletonData = m_skeletonAnimation.skeletonDataAsset.GetSkeletonData(true);
+			m_skeletonData = m_skeletonAnimation.skeletonDataAsset.GetSkeletonData(true);
 				
-				m_previewInstance.renderer.enabled = false;
+			m_previewInstance.renderer.enabled = false;
 				
-				m_initialized = true;
-				AdjustCameraGoals(true);
-			}
+			m_initialized = true;
+			AdjustCameraGoals(true);
 		}
+	}
 		
-		private void DestroyPreviewInstances()
-		{
-			if (this.m_previewInstance != null)
-			{
-				DestroyImmediate(this.m_previewInstance);
-				m_previewInstance = null;
-			}
-			m_initialized = false;
+	private void DestroyPreviewInstances () {
+		if (this.m_previewInstance != null) {
+			DestroyImmediate(this.m_previewInstance);
+			m_previewInstance = null;
 		}
+		m_initialized = false;
+	}
 		
-		public override bool HasPreviewGUI ()
-		{
-			//TODO: validate json data
-			return skeletonJSON.objectReferenceValue != null;
-		}
+	public override bool HasPreviewGUI () {
+		//TODO: validate json data
+		return skeletonJSON.objectReferenceValue != null;
+	}
 		
-		Texture m_previewTex = new Texture();
-		public override void OnInteractivePreviewGUI(Rect r, GUIStyle background)
-		{
-			this.InitPreview();
-			
-			if (UnityEngine.Event.current.type == EventType.Repaint)
-			{
-				if(m_requireRefresh){
-					this.m_previewUtility.BeginPreview(r, background);
-					this.DoRenderPreview(true);
-					this.m_previewTex = this.m_previewUtility.EndPreview();
-					m_requireRefresh = false;
-				}
-				if(this.m_previewTex != null)
-					GUI.DrawTexture(r, m_previewTex, ScaleMode.StretchToFill, false);
+	Texture m_previewTex = new Texture();
+
+	public override void OnInteractivePreviewGUI (Rect r, GUIStyle background) {
+		this.InitPreview();
+			
+		if (UnityEngine.Event.current.type == EventType.Repaint) {
+			if (m_requireRefresh) {
+				this.m_previewUtility.BeginPreview(r, background);
+				this.DoRenderPreview(true);
+				this.m_previewTex = this.m_previewUtility.EndPreview();
+				m_requireRefresh = false;
 			}
-			
-			DrawSkinToolbar(r);
-			NormalizedTimeBar(r);
-			//TODO: implement panning
-			//		this.previewDir = Drag2D(this.previewDir, r);
-			MouseScroll(r);
+			if (this.m_previewTex != null)
+				GUI.DrawTexture(r, m_previewTex, ScaleMode.StretchToFill, false);
 		}
+			
+		DrawSkinToolbar(r);
+		NormalizedTimeBar(r);
+		//TODO: implement panning
+		//		this.previewDir = Drag2D(this.previewDir, r);
+		MouseScroll(r);
+	}
 		
-		float m_orthoGoal = 1;
-		Vector3 m_posGoal = new Vector3(0,0,-10);
-		double m_adjustFrameEndTime = 0;
-		private void AdjustCameraGoals(bool calculateMixTime){
-			if(calculateMixTime){
-				if(m_skeletonAnimation.state.GetCurrent(0) != null){
-					m_adjustFrameEndTime = EditorApplication.timeSinceStartup + m_skeletonAnimation.state.GetCurrent(0).Mix;
-				}
+	float m_orthoGoal = 1;
+	Vector3 m_posGoal = new Vector3(0, 0, -10);
+	double m_adjustFrameEndTime = 0;
+
+	private void AdjustCameraGoals (bool calculateMixTime) {
+		if (calculateMixTime) {
+			if (m_skeletonAnimation.state.GetCurrent(0) != null) {
+				m_adjustFrameEndTime = EditorApplication.timeSinceStartup + m_skeletonAnimation.state.GetCurrent(0).Mix;
 			}
+		}
 			
 			
-			GameObject go = this.m_previewInstance;
-			Bounds bounds = go.renderer.bounds;
-			m_orthoGoal = bounds.size.y;
+		GameObject go = this.m_previewInstance;
+		Bounds bounds = go.renderer.bounds;
+		m_orthoGoal = bounds.size.y;
 			
-			m_posGoal = bounds.center + new Vector3(0,0,-10);
-		}
+		m_posGoal = bounds.center + new Vector3(0, 0, -10);
+	}
 		
-		private void AdjustCameraGoals(){
-			AdjustCameraGoals(false);
-		}
+	private void AdjustCameraGoals () {
+		AdjustCameraGoals(false);
+	}
 		
-		private void AdjustCamera(){
-			if(m_previewUtility == null)
-				return;
+	private void AdjustCamera () {
+		if (m_previewUtility == null)
+			return;
 			
 			
-			if(EditorApplication.timeSinceStartup < m_adjustFrameEndTime){
-				AdjustCameraGoals();
-			}
+		if (EditorApplication.timeSinceStartup < m_adjustFrameEndTime) {
+			AdjustCameraGoals();
+		}
 			
-			float orthoSet = Mathf.Lerp(this.m_previewUtility.m_Camera.orthographicSize, m_orthoGoal, 0.1f);
+		float orthoSet = Mathf.Lerp(this.m_previewUtility.m_Camera.orthographicSize, m_orthoGoal, 0.1f);
 			
-			this.m_previewUtility.m_Camera.orthographicSize = orthoSet;
+		this.m_previewUtility.m_Camera.orthographicSize = orthoSet;
 			
-			float dist = Vector3.Distance(m_previewUtility.m_Camera.transform.position, m_posGoal);
-			if(dist > 60f * ((SkeletonDataAsset)target).scale){
-				Vector3 pos = Vector3.Lerp(this.m_previewUtility.m_Camera.transform.position, m_posGoal, 0.1f);
-				pos.x = 0;
-				this.m_previewUtility.m_Camera.transform.position = pos;
-				this.m_previewUtility.m_Camera.transform.rotation = Quaternion.identity;
-				m_requireRefresh = true;
-			}
+		float dist = Vector3.Distance(m_previewUtility.m_Camera.transform.position, m_posGoal);
+		if (dist > 60f * ((SkeletonDataAsset)target).scale) {
+			Vector3 pos = Vector3.Lerp(this.m_previewUtility.m_Camera.transform.position, m_posGoal, 0.1f);
+			pos.x = 0;
+			this.m_previewUtility.m_Camera.transform.position = pos;
+			this.m_previewUtility.m_Camera.transform.rotation = Quaternion.identity;
+			m_requireRefresh = true;
 		}
+	}
 		
-		private void DoRenderPreview(bool drawHandles)
-		{
-			GameObject go = this.m_previewInstance;
+	private void DoRenderPreview (bool drawHandles) {
+		GameObject go = this.m_previewInstance;
 			
-			if(m_requireRefresh){
-				go.renderer.enabled = true;
+		if (m_requireRefresh) {
+			go.renderer.enabled = true;
 				
-				if(EditorApplication.isPlaying){
-					//do nothing
-				}
-				else{
-					m_skeletonAnimation.Update((Time.realtimeSinceStartup - m_lastTime));
-				}
+			if (EditorApplication.isPlaying) {
+				//do nothing
+			} else {
+				m_skeletonAnimation.Update((Time.realtimeSinceStartup - m_lastTime));
+			}
 				
-				m_lastTime = Time.realtimeSinceStartup;
+			m_lastTime = Time.realtimeSinceStartup;
 				
-				if(!EditorApplication.isPlaying)
-					m_skeletonAnimation.LateUpdate();
+			if (!EditorApplication.isPlaying)
+				m_skeletonAnimation.LateUpdate();
 				
-				if(drawHandles){
-					Handles.SetCamera(m_previewUtility.m_Camera);
-					Handles.color = m_originColor;
+			if (drawHandles) {
+				Handles.SetCamera(m_previewUtility.m_Camera);
+				Handles.color = m_originColor;
 					
-					Handles.DrawLine(new Vector3(-1000 * m_skeletonDataAsset.scale,0,0), new Vector3(1000 * m_skeletonDataAsset.scale,0,0));
-					Handles.DrawLine(new Vector3(0,1000 * m_skeletonDataAsset.scale,0), new Vector3(0,-1000 * m_skeletonDataAsset.scale,0));
-				}
-				
-				this.m_previewUtility.m_Camera.Render();
-				go.renderer.enabled = false;
+				Handles.DrawLine(new Vector3(-1000 * m_skeletonDataAsset.scale, 0, 0), new Vector3(1000 * m_skeletonDataAsset.scale, 0, 0));
+				Handles.DrawLine(new Vector3(0, 1000 * m_skeletonDataAsset.scale, 0), new Vector3(0, -1000 * m_skeletonDataAsset.scale, 0));
 			}
+				
+			this.m_previewUtility.m_Camera.Render();
+			go.renderer.enabled = false;
+		}
 			
 			
-		}
+	}
 		
-		void Update(){
-			AdjustCamera();
+	void Update () {
+		AdjustCamera();
 			
-			if (m_playing) {
-				m_requireRefresh = true;
+		if (m_playing) {
+			m_requireRefresh = true;
+			Repaint();
+		} else if (m_requireRefresh) {
 				Repaint();
-			}
-			else if (m_requireRefresh) {
-				Repaint ();
-			}
-			else{
+			} else {
 				#if !UNITY_4_3
-				if(m_showAnimationList.isAnimating)
+				if (m_showAnimationList.isAnimating)
 					Repaint();
 				#endif
 			}
-		}
+	}
 		
-		void DrawSkinToolbar(Rect r){
-			if(m_skeletonAnimation == null)
-				return;
+	void DrawSkinToolbar (Rect r) {
+		if (m_skeletonAnimation == null)
+			return;
 			
-			if(m_skeletonAnimation.skeleton != null){
-				string label = (m_skeletonAnimation.skeleton != null && m_skeletonAnimation.skeleton.Skin != null) ? m_skeletonAnimation.skeleton.Skin.Name : "default";
+		if (m_skeletonAnimation.skeleton != null) {
+			string label = (m_skeletonAnimation.skeleton != null && m_skeletonAnimation.skeleton.Skin != null) ? m_skeletonAnimation.skeleton.Skin.Name : "default";
 				
-				Rect popRect = new Rect(r);
-				popRect.y += 32;
-				popRect.x += 4;
-				popRect.height = 24;
-				popRect.width = 40;
-				EditorGUI.DropShadowLabel(popRect, new GUIContent("Skin", SpineEditorUtilities.Icons.skinsRoot));
+			Rect popRect = new Rect(r);
+			popRect.y += 32;
+			popRect.x += 4;
+			popRect.height = 24;
+			popRect.width = 40;
+			EditorGUI.DropShadowLabel(popRect, new GUIContent("Skin", SpineEditorUtilities.Icons.skinsRoot));
 				
-				popRect.y += 11;
-				popRect.width = 150;
-				popRect.x += 44;
+			popRect.y += 11;
+			popRect.width = 150;
+			popRect.x += 44;
 				
-				if(GUI.Button( popRect, label, EditorStyles.popup)){
-					SelectSkinContext();
-				}
+			if (GUI.Button(popRect, label, EditorStyles.popup)) {
+				SelectSkinContext();
 			}
 		}
+	}
 		
-		void SelectSkinContext(){
-			GenericMenu menu = new GenericMenu();
+	void SelectSkinContext () {
+		GenericMenu menu = new GenericMenu();
 			
-			foreach(Skin s in m_skeletonData.Skins){
-				menu.AddItem( new GUIContent(s.Name), this.m_skeletonAnimation.skeleton.Skin == s, SetSkin, (object)s);
-			}
-			
-			menu.ShowAsContext();
+		foreach (Skin s in m_skeletonData.Skins) {
+			menu.AddItem(new GUIContent(s.Name), this.m_skeletonAnimation.skeleton.Skin == s, SetSkin, (object)s);
 		}
+			
+		menu.ShowAsContext();
+	}
 		
-		void SetSkin(object o){
-			Skin skin = (Skin)o;
+	void SetSkin (object o) {
+		Skin skin = (Skin)o;
 			
-			m_skeletonAnimation.initialSkinName = skin.Name;
-			m_skeletonAnimation.Reset();
-			m_requireRefresh = true;
+		m_skeletonAnimation.initialSkinName = skin.Name;
+		m_skeletonAnimation.Reset();
+		m_requireRefresh = true;
 			
-			EditorPrefs.SetString(m_skeletonDataAssetGUID + "_lastSkin", skin.Name);
-		}
+		EditorPrefs.SetString(m_skeletonDataAssetGUID + "_lastSkin", skin.Name);
+	}
 		
-		void NormalizedTimeBar(Rect r){
-			Rect barRect = new Rect(r);
-			barRect.height = 32;
-			barRect.x += 4;
-			barRect.width -=4;
+	void NormalizedTimeBar (Rect r) {
+		Rect barRect = new Rect(r);
+		barRect.height = 32;
+		barRect.x += 4;
+		barRect.width -= 4;
 			
-			GUI.Box(barRect, "");
+		GUI.Box(barRect, "");
 			
-			Rect lineRect = new Rect(barRect);
-			float width = lineRect.width;
-			TrackEntry t = m_skeletonAnimation.state.GetCurrent(0);
+		Rect lineRect = new Rect(barRect);
+		float width = lineRect.width;
+		TrackEntry t = m_skeletonAnimation.state.GetCurrent(0);
 			
-			if(t != null){
-				int loopCount = (int)(t.Time / t.EndTime);
-				float currentTime = t.Time - (t.EndTime * loopCount);
+		if (t != null) {
+			int loopCount = (int)(t.Time / t.EndTime);
+			float currentTime = t.Time - (t.EndTime * loopCount);
 				
-				float normalizedTime = currentTime / t.Animation.Duration;
+			float normalizedTime = currentTime / t.Animation.Duration;
 				
-				lineRect.x = barRect.x + (width * normalizedTime) - 0.5f;
-				lineRect.width = 2;
+			lineRect.x = barRect.x + (width * normalizedTime) - 0.5f;
+			lineRect.width = 2;
 				
-				GUI.color = Color.red;
-				GUI.DrawTexture(lineRect, EditorGUIUtility.whiteTexture);
-				GUI.color = Color.white;
+			GUI.color = Color.red;
+			GUI.DrawTexture(lineRect, EditorGUIUtility.whiteTexture);
+			GUI.color = Color.white;
 				
-				for(int i = 0; i < m_animEvents.Count; i++){
-					//TODO: Tooltip
-					//Spine.Event spev = animEvents[i];
+			for (int i = 0; i < m_animEvents.Count; i++) {
+				//TODO: Tooltip
+				//Spine.Event spev = animEvents[i];
 					
-					float fr = m_animEventFrames[i];
+				float fr = m_animEventFrames[i];
 					
-					Rect evRect = new Rect(barRect);
-					evRect.x = Mathf.Clamp(((fr / t.Animation.Duration) * width) - (SpineEditorUtilities.Icons._event.width/2), barRect.x, float.MaxValue);
-					evRect.width = SpineEditorUtilities.Icons._event.width;
-					evRect.height = SpineEditorUtilities.Icons._event.height;
-					evRect.y += SpineEditorUtilities.Icons._event.height;
-					GUI.DrawTexture(evRect, SpineEditorUtilities.Icons._event);
+				Rect evRect = new Rect(barRect);
+				evRect.x = Mathf.Clamp(((fr / t.Animation.Duration) * width) - (SpineEditorUtilities.Icons._event.width / 2), barRect.x, float.MaxValue);
+				evRect.width = SpineEditorUtilities.Icons._event.width;
+				evRect.height = SpineEditorUtilities.Icons._event.height;
+				evRect.y += SpineEditorUtilities.Icons._event.height;
+				GUI.DrawTexture(evRect, SpineEditorUtilities.Icons._event);
 					
 					
-					//TODO:  Tooltip
-					/*
+				//TODO:  Tooltip
+				/*
 				UnityEngine.Event ev = UnityEngine.Event.current;
 				if(ev.isMouse){
 					if(evRect.Contains(ev.mousePosition)){
@@ -514,29 +497,29 @@ public class SkeletonDataAssetInspector : Editor {
 					}
 				}
 				*/
-				}
 			}
 		}
+	}
 		
-		void MouseScroll(Rect position){
-			UnityEngine.Event current = UnityEngine.Event.current;
-			int controlID = GUIUtility.GetControlID(sliderHash, FocusType.Passive);
+	void MouseScroll (Rect position) {
+		UnityEngine.Event current = UnityEngine.Event.current;
+		int controlID = GUIUtility.GetControlID(sliderHash, FocusType.Passive);
 			
-			switch(current.GetTypeForControl(controlID)){
-			case EventType.ScrollWheel:
-				if(position.Contains(current.mousePosition)){
+		switch (current.GetTypeForControl(controlID)) {
+		case EventType.ScrollWheel:
+			if (position.Contains(current.mousePosition)) {
 					
-					m_orthoGoal += current.delta.y * ((SkeletonDataAsset)target).scale * 10;
-					GUIUtility.hotControl = controlID;
-					current.Use();
-				}
-				break;
+				m_orthoGoal += current.delta.y * ((SkeletonDataAsset)target).scale * 10;
+				GUIUtility.hotControl = controlID;
+				current.Use();
 			}
-			
+			break;
 		}
+			
+	}
 		
-		//TODO:  Implement preview panning
-		/*
+	//TODO:  Implement preview panning
+	/*
 	static Vector2 Drag2D(Vector2 scrollPosition, Rect position)
 	{
 		int controlID = GUIUtility.GetControlID(sliderHash, FocusType.Passive);
@@ -577,56 +560,52 @@ public class SkeletonDataAssetInspector : Editor {
 	}
 	*/
 		
-		public override GUIContent GetPreviewTitle ()
-		{
-			return new GUIContent ("Preview");
-		}
+	public override GUIContent GetPreviewTitle () {
+		return new GUIContent("Preview");
+	}
 		
-		public override void OnPreviewSettings ()
-		{
-			if(!m_initialized){
-				GUILayout.HorizontalSlider(0,0,2, GUILayout.MaxWidth(64));
-			}
-			else{
-				float speed = GUILayout.HorizontalSlider( m_skeletonAnimation.timeScale, 0, 2, GUILayout.MaxWidth(64));
+	public override void OnPreviewSettings () {
+		if (!m_initialized) {
+			GUILayout.HorizontalSlider(0, 0, 2, GUILayout.MaxWidth(64));
+		} else {
+			float speed = GUILayout.HorizontalSlider(m_skeletonAnimation.timeScale, 0, 2, GUILayout.MaxWidth(64));
 				
-				//snap to nearest 0.25
-				float y = speed / 0.25f;
-				int q = Mathf.RoundToInt(y);
-				speed = q * 0.25f;
+			//snap to nearest 0.25
+			float y = speed / 0.25f;
+			int q = Mathf.RoundToInt(y);
+			speed = q * 0.25f;
 				
-				m_skeletonAnimation.timeScale = speed;
-			}
+			m_skeletonAnimation.timeScale = speed;
 		}
+	}
 		
-		//TODO:  Fix first-import error
-		//TODO:  Update preview without thumbnail
-		public override Texture2D RenderStaticPreview (string assetPath, UnityEngine.Object[] subAssets, int width, int height)
-		{
-			Texture2D tex = new Texture2D(width, height, TextureFormat.ARGB32, false);
-			
-			this.InitPreview();
-			
-			if(this.m_previewUtility.m_Camera == null)
-				return null;
-			
-			m_requireRefresh = true;
-			this.DoRenderPreview(false);
-			AdjustCameraGoals(false);
-			
-			this.m_previewUtility.m_Camera.orthographicSize = m_orthoGoal/2;
-			this.m_previewUtility.m_Camera.transform.position = m_posGoal;
-			this.m_previewUtility.BeginStaticPreview(new Rect(0,0,width,height));
-			this.DoRenderPreview(false);
-			
-			//TODO:  Figure out why this is throwing errors on first attempt
-			//		if(m_previewUtility != null){
-			//			Handles.SetCamera(this.m_previewUtility.m_Camera);
-			//			Handles.BeginGUI();
-			//			GUI.DrawTexture(new Rect(40,60,width,height), SpineEditorUtilities.Icons.spine, ScaleMode.StretchToFill);
-			//			Handles.EndGUI();
-			//		}
-			tex = this.m_previewUtility.EndStaticPreview();
-			return tex;
-		}
-	}
+	//TODO:  Fix first-import error
+	//TODO:  Update preview without thumbnail
+	public override Texture2D RenderStaticPreview (string assetPath, UnityEngine.Object[] subAssets, int width, int height) {
+		Texture2D tex = new Texture2D(width, height, TextureFormat.ARGB32, false);
+			
+		this.InitPreview();
+			
+		if (this.m_previewUtility.m_Camera == null)
+			return null;
+			
+		m_requireRefresh = true;
+		this.DoRenderPreview(false);
+		AdjustCameraGoals(false);
+			
+		this.m_previewUtility.m_Camera.orthographicSize = m_orthoGoal / 2;
+		this.m_previewUtility.m_Camera.transform.position = m_posGoal;
+		this.m_previewUtility.BeginStaticPreview(new Rect(0, 0, width, height));
+		this.DoRenderPreview(false);
+			
+		//TODO:  Figure out why this is throwing errors on first attempt
+		//		if(m_previewUtility != null){
+		//			Handles.SetCamera(this.m_previewUtility.m_Camera);
+		//			Handles.BeginGUI();
+		//			GUI.DrawTexture(new Rect(40,60,width,height), SpineEditorUtilities.Icons.spine, ScaleMode.StretchToFill);
+		//			Handles.EndGUI();
+		//		}
+		tex = this.m_previewUtility.EndStaticPreview();
+		return tex;
+	}
+}

+ 4 - 3
spine-unity/Assets/spine-unity/Editor/SkeletonRendererInspector.cs

@@ -27,7 +27,6 @@
  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
-
 using System;
 using UnityEditor;
 using UnityEngine;
@@ -64,7 +63,8 @@ public class SkeletonRendererInspector : Editor {
 		if (!component.valid) {
 			component.Reset();
 			component.LateUpdate();
-			if (!component.valid) return;
+			if (!component.valid)
+				return;
 		}
 
 		// Initial skin name.
@@ -100,7 +100,8 @@ public class SkeletonRendererInspector : Editor {
 		if (serializedObject.ApplyModifiedProperties() ||
 			(Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
 		) {
-			if (!Application.isPlaying) ((SkeletonRenderer)target).Reset();
+			if (!Application.isPlaying)
+				((SkeletonRenderer)target).Reset();
 		}
 	}
 }

+ 136 - 155
spine-unity/Assets/spine-unity/Editor/SpineEditorUtilities.cs

@@ -33,7 +33,6 @@
  * Spine Editor Utilities created by Mitch Thompson
  * Full irrevocable rights and permissions granted to Esoteric Software
 *****************************************************************************/
-
 using UnityEngine;
 using UnityEditor;
 using System.Collections;
@@ -45,7 +44,7 @@ using Spine;
 [InitializeOnLoad]
 public class SpineEditorUtilities : AssetPostprocessor {
 
-	public static class Icons{
+	public static class Icons {
 		public static Texture2D skeleton;
 		public static Texture2D nullBone;
 		public static Texture2D bone;
@@ -68,11 +67,16 @@ public class SpineEditorUtilities : AssetPostprocessor {
 		public static Texture2D hingeChain;
 		public static Texture2D subMeshRenderer;
 
-		public static Mesh boneMesh{
-			get{
-				if(_boneMesh == null){
+		public static Mesh boneMesh {
+			get {
+				if (_boneMesh == null) {
 					_boneMesh = new Mesh();
-					_boneMesh.vertices = new Vector3[4]{Vector3.zero, new Vector3(-0.1f,0.1f,0), Vector3.up, new Vector3(0.1f,0.1f,0)};
+					_boneMesh.vertices = new Vector3[4] {
+						Vector3.zero,
+						new Vector3(-0.1f, 0.1f, 0),
+						Vector3.up,
+						new Vector3(0.1f, 0.1f, 0)
+					};
 					_boneMesh.uv = new Vector2[4];
 					_boneMesh.triangles = new int[6]{0,1,2,2,3,0};
 					_boneMesh.RecalculateBounds();
@@ -82,12 +86,12 @@ public class SpineEditorUtilities : AssetPostprocessor {
 				return _boneMesh;
 			}
 		}
-		internal static Mesh _boneMesh;
 
+		internal static Mesh _boneMesh;
 
-		public static Material boneMaterial{
-			get{
-				if(_boneMaterial == null){
+		public static Material boneMaterial {
+			get {
+				if (_boneMaterial == null) {
 #if UNITY_4_3
 					_boneMaterial = new Material(Shader.Find("Particles/Alpha Blended"));
 					_boneMaterial.SetColor("_TintColor", new Color(0.4f, 0.4f, 0.4f, 0.25f));
@@ -101,48 +105,43 @@ public class SpineEditorUtilities : AssetPostprocessor {
 				return _boneMaterial;
 			}
 		}
-		internal static Material _boneMaterial;
 
-		public static void Initialize(){
-			skeleton = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-skeleton.png");
-			nullBone = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-null.png");
-			bone = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-bone.png");
-			poseBones = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-poseBones.png");
-			boneNib = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-boneNib.png");
-			slot = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-slot.png");
-			skinPlaceholder = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-skinPlaceholder.png");
-			image = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-image.png");
-			boundingBox = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-boundingBox.png");
-			mesh = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-mesh.png");
-			skin = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-skinPlaceholder.png");
-			skinsRoot = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-skinsRoot.png");
-			animation = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-animation.png");
-			animationRoot = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-animationRoot.png");
-			spine = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-spine.png");
-			_event = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-event.png");
-			constraintNib = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-constraintNib.png");
-			warning = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-warning.png");
-			skeletonUtility = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-skeletonUtility.png");
-			hingeChain = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-hingeChain.png");
-			subMeshRenderer = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-subMeshRenderer.png");
+		internal static Material _boneMaterial;
 
+		public static void Initialize () {
+			skeleton = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-skeleton.png");
+			nullBone = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-null.png");
+			bone = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-bone.png");
+			poseBones = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-poseBones.png");
+			boneNib = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-boneNib.png");
+			slot = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-slot.png");
+			skinPlaceholder = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-skinPlaceholder.png");
+			image = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-image.png");
+			boundingBox = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-boundingBox.png");
+			mesh = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-mesh.png");
+			skin = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-skinPlaceholder.png");
+			skinsRoot = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-skinsRoot.png");
+			animation = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-animation.png");
+			animationRoot = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-animationRoot.png");
+			spine = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-spine.png");
+			_event = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-event.png");
+			constraintNib = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-constraintNib.png");
+			warning = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-warning.png");
+			skeletonUtility = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-skeletonUtility.png");
+			hingeChain = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-hingeChain.png");
+			subMeshRenderer = (Texture2D)AssetDatabase.LoadMainAssetAtPath(SpineEditorUtilities.editorGUIPath + "/icon-subMeshRenderer.png");
 		}
-
 	}
 
-
-
 	public static string editorPath = "";
 	public static string editorGUIPath = "";
-	
 	static Dictionary<int, GameObject> skeletonRendererTable;
 	static Dictionary<int, SkeletonUtilityBone> skeletonUtilityBoneTable;
-
 	public static float defaultScale = 0.01f;
 	public static float defaultMix = 0.2f;
 	public static string defaultShader = "Spine/Skeleton";
 	
-	static SpineEditorUtilities(){
+	static SpineEditorUtilities () {
 		DirectoryInfo rootDir = new DirectoryInfo(Application.dataPath);
 		FileInfo[] files = rootDir.GetFiles("SpineEditorUtilities.cs", SearchOption.AllDirectories);
 		editorPath = Path.GetDirectoryName(files[0].FullName.Replace("\\", "/").Replace(Application.dataPath, "Assets"));
@@ -159,81 +158,79 @@ public class SpineEditorUtilities : AssetPostprocessor {
 		HierarchyWindowChanged();
 	}
 
-	static void HierarchyWindowChanged(){
+	static void HierarchyWindowChanged () {
 		skeletonRendererTable.Clear();
 		skeletonUtilityBoneTable.Clear();
 
 		SkeletonRenderer[] arr = Object.FindObjectsOfType<SkeletonRenderer>();
 
-		foreach(SkeletonRenderer r in arr)
-			skeletonRendererTable.Add( r.gameObject.GetInstanceID(), r.gameObject );
+		foreach (SkeletonRenderer r in arr)
+			skeletonRendererTable.Add(r.gameObject.GetInstanceID(), r.gameObject);
 
 		SkeletonUtilityBone[] boneArr = Object.FindObjectsOfType<SkeletonUtilityBone>();
-		foreach(SkeletonUtilityBone b in boneArr)
+		foreach (SkeletonUtilityBone b in boneArr)
 			skeletonUtilityBoneTable.Add(b.gameObject.GetInstanceID(), b);
 	}
 
-	static void HierarchyWindowItemOnGUI(int instanceId, Rect selectionRect){
-		if(skeletonRendererTable.ContainsKey(instanceId)){
-			Rect r = new Rect (selectionRect); 
+	static void HierarchyWindowItemOnGUI (int instanceId, Rect selectionRect) {
+		if (skeletonRendererTable.ContainsKey(instanceId)) {
+			Rect r = new Rect(selectionRect); 
 			r.x = r.width - 15;
 			r.width = 15;
 
 			GUI.Label(r, Icons.spine);
-		}
-		else if(skeletonUtilityBoneTable.ContainsKey(instanceId)){
-			Rect r = new Rect (selectionRect); 
-			r.x -= 26;
+		} else if (skeletonUtilityBoneTable.ContainsKey(instanceId)) {
+				Rect r = new Rect(selectionRect); 
+				r.x -= 26;
 
-			if(skeletonUtilityBoneTable[instanceId] != null){
-				if( skeletonUtilityBoneTable[instanceId].transform.childCount == 0 )
-					r.x += 13;
+				if (skeletonUtilityBoneTable[instanceId] != null) {
+					if (skeletonUtilityBoneTable[instanceId].transform.childCount == 0)
+						r.x += 13;
 				
-				r.y += 2;
+					r.y += 2;
 
-				r.width = 13;
-				r.height = 13;
+					r.width = 13;
+					r.height = 13;
 
-				if( skeletonUtilityBoneTable[instanceId].mode == SkeletonUtilityBone.Mode.Follow ){
-					GUI.DrawTexture(r, Icons.bone);
-				}
-				else{
-					GUI.DrawTexture(r, Icons.poseBones);
+					if (skeletonUtilityBoneTable[instanceId].mode == SkeletonUtilityBone.Mode.Follow) {
+						GUI.DrawTexture(r, Icons.bone);
+					} else {
+						GUI.DrawTexture(r, Icons.poseBones);
+					}
 				}
-			}
 
-		}
+			}
 
 	}
 	
 	[MenuItem("Assets/Spine/Ingest")]
-	static void IngestSpineProjectFromSelection(){
+	static void IngestSpineProjectFromSelection () {
 		TextAsset spineJson = null;
 		TextAsset atlasText = null;
 
 		List<TextAsset> spineJsonList = new List<TextAsset>();
 
-		foreach(UnityEngine.Object o in Selection.objects){
-			if(o.GetType() != typeof(TextAsset))
+		foreach (UnityEngine.Object o in Selection.objects) {
+			if (o.GetType() != typeof(TextAsset))
 				continue;
 			
 			string fileName = Path.GetFileName(AssetDatabase.GetAssetPath(o));
 			
-			if(fileName.EndsWith(".json"))
+			if (fileName.EndsWith(".json"))
 				spineJson = (TextAsset)o;
-			else if(fileName.EndsWith(".atlas.txt"))
-				atlasText = (TextAsset)o;
+			else if (fileName.EndsWith(".atlas.txt"))
+					atlasText = (TextAsset)o;
 		}
 		
-		if(spineJson == null){
+		if (spineJson == null) {
 			EditorUtility.DisplayDialog("Error!", "Spine JSON file not found in selection!", "OK");
 			return;
 		}
 		
 		string primaryName = Path.GetFileNameWithoutExtension(spineJson.name);
-		string assetPath = Path.GetDirectoryName( AssetDatabase.GetAssetPath(spineJson));
+		string assetPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(spineJson));
 		
-		if(atlasText == null){
+		if (atlasText == null) {
 			string atlasPath = assetPath + "/" + primaryName + ".atlas.txt";
 			atlasText = (TextAsset)AssetDatabase.LoadAssetAtPath(atlasPath, typeof(TextAsset));
 		}
@@ -243,7 +240,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
 		IngestSpineProject(spineJson, atlasAsset);
 	}
 
-	static void OnPostprocessAllAssets(string[] imported, string[] deleted, string[] moved, string[] movedFromAssetPaths){
+	static void OnPostprocessAllAssets (string[] imported, string[] deleted, string[] moved, string[] movedFromAssetPaths) {
 		//debug
 //		return;
 
@@ -251,20 +248,20 @@ public class SpineEditorUtilities : AssetPostprocessor {
 
 		System.Array.Sort<string>(imported);
 
-		foreach(string str in imported){
-			if(Path.GetExtension(str).ToLower() == ".json"){
+		foreach (string str in imported) {
+			if (Path.GetExtension(str).ToLower() == ".json") {
 				TextAsset spineJson = (TextAsset)AssetDatabase.LoadAssetAtPath(str, typeof(TextAsset));
-				if(IsSpineJSON(spineJson)){
+				if (IsSpineJSON(spineJson)) {
 
-					if(sharedAtlas != null){
+					if (sharedAtlas != null) {
 						string spinePath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(spineJson));
 						string atlasPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(sharedAtlas));
-						if(spinePath != atlasPath)
+						if (spinePath != atlasPath)
 							sharedAtlas = null;
 					}
 
 					SkeletonDataAsset data = AutoIngestSpineProject(spineJson, sharedAtlas);
-					if(data == null)
+					if (data == null)
 						continue;
 
 					sharedAtlas = data.atlasAsset;
@@ -273,15 +270,14 @@ public class SpineEditorUtilities : AssetPostprocessor {
 					string dir = Path.GetDirectoryName(Path.GetDirectoryName(AssetDatabase.GetAssetPath(data)));
 					string prefabPath = Path.Combine(dir, data.skeletonJSON.name + ".prefab").Replace("\\", "/");
 
-					if(File.Exists(prefabPath) == false){
+					if (File.Exists(prefabPath) == false) {
 						SkeletonAnimation anim = SpawnAnimatedSkeleton(data);
 						PrefabUtility.CreatePrefab(prefabPath, anim.gameObject, ReplacePrefabOptions.ReplaceNameBased);
-						if(EditorApplication.isPlaying)
+						if (EditorApplication.isPlaying)
 							GameObject.Destroy(anim.gameObject);
 						else
 							GameObject.DestroyImmediate(anim.gameObject);
-					}
-					else{
+					} else {
 
 					}
 
@@ -291,58 +287,54 @@ public class SpineEditorUtilities : AssetPostprocessor {
 		}
 	}
 
-	static bool IsSpineJSON(TextAsset asset){
-		object obj = Json.Deserialize( new StringReader(asset.text));
-		if(obj == null){
+	static bool IsSpineJSON (TextAsset asset) {
+		object obj = Json.Deserialize(new StringReader(asset.text));
+		if (obj == null) {
 			Debug.LogError("Is not valid JSON");
 			return false;
 		}
 
 		Dictionary<string, object> root = (Dictionary<string, object>)obj;
 
-		if(!root.ContainsKey("skeleton"))
+		if (!root.ContainsKey("skeleton"))
 			return false;
 
 		Dictionary<string, object> skeletonInfo = (Dictionary<string, object>)root["skeleton"];
 
 		string spineVersion = (string)skeletonInfo["spine"];
-
 		//TODO:  reject old versions
 
 		return true;
-
 	}
 
-	static SkeletonDataAsset AutoIngestSpineProject(TextAsset spineJson, Object atlasSource = null){
+	static SkeletonDataAsset AutoIngestSpineProject (TextAsset spineJson, Object atlasSource = null) {
 		TextAsset atlasText = null;
 		AtlasAsset atlasAsset = null;
 
-		if(atlasSource != null){
-			if(atlasSource.GetType() == typeof(TextAsset)){
+		if (atlasSource != null) {
+			if (atlasSource.GetType() == typeof(TextAsset)) {
 				atlasText = (TextAsset)atlasSource;
-			}
-			else if(atlasSource.GetType() == typeof(AtlasAsset)){
-				atlasAsset = (AtlasAsset)atlasSource;
-			}
+			} else if (atlasSource.GetType() == typeof(AtlasAsset)) {
+					atlasAsset = (AtlasAsset)atlasSource;
+				}
 		}
 
-		if(atlasText == null && atlasAsset == null){
+		if (atlasText == null && atlasAsset == null) {
 			string primaryName = Path.GetFileNameWithoutExtension(spineJson.name);
-			string assetPath = Path.GetDirectoryName( AssetDatabase.GetAssetPath(spineJson));
+			string assetPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(spineJson));
 			
-			if(atlasText == null){
+			if (atlasText == null) {
 				string atlasPath = assetPath + "/" + primaryName + ".atlas.txt";
 				atlasText = (TextAsset)AssetDatabase.LoadAssetAtPath(atlasPath, typeof(TextAsset));
 
-				if(atlasText == null){
+				if (atlasText == null) {
 					//can't find atlas, likely because using a shared atlas
 					bool abort = !EditorUtility.DisplayDialog("Atlas not Found", "Expecting " + spineJson.name + ".atlas\n" + "Press OK to select Atlas", "OK", "Abort");
-					if(abort){
+					if (abort) {
 						//do nothing, let it error later
-					}
-					else{
-						string path = EditorUtility.OpenFilePanel( "Find Atlas source...", Path.GetDirectoryName(Application.dataPath) + "/" + assetPath, "txt");
-						if(path != ""){
+					} else {
+						string path = EditorUtility.OpenFilePanel("Find Atlas source...", Path.GetDirectoryName(Application.dataPath) + "/" + assetPath, "txt");
+						if (path != "") {
 							path = path.Replace("\\", "/");
 							path = path.Replace(Application.dataPath.Replace("\\", "/"), "Assets");
 							atlasText = (TextAsset)AssetDatabase.LoadAssetAtPath(path, typeof(TextAsset));
@@ -353,52 +345,52 @@ public class SpineEditorUtilities : AssetPostprocessor {
 			}
 		}
 
-		if(atlasAsset == null)
+		if (atlasAsset == null)
 			atlasAsset = IngestSpineAtlas(atlasText);
 
 		return IngestSpineProject(spineJson, atlasAsset);
 	}
 
-	static AtlasAsset IngestSpineAtlas(TextAsset atlasText){
-		if(atlasText == null){
+	static AtlasAsset IngestSpineAtlas (TextAsset atlasText) {
+		if (atlasText == null) {
 			Debug.LogWarning("Atlas source cannot be null!");
 			return null;
 		}
 
 		string primaryName = Path.GetFileNameWithoutExtension(atlasText.name).Replace(".atlas", "");
-		string assetPath = Path.GetDirectoryName( AssetDatabase.GetAssetPath(atlasText));
+		string assetPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(atlasText));
 
 		string atlasPath = assetPath + "/" + primaryName + "_Atlas.asset";
 
 		AtlasAsset atlasAsset = (AtlasAsset)AssetDatabase.LoadAssetAtPath(atlasPath, typeof(AtlasAsset));
 
 
-		if(atlasAsset == null)
+		if (atlasAsset == null)
 			atlasAsset = AtlasAsset.CreateInstance<AtlasAsset>();
 
 		atlasAsset.atlasFile = atlasText;
 
-        //strip CR
-        string atlasStr = atlasText.text;
-        atlasStr = atlasStr.Replace("\r", "");
+		//strip CR
+		string atlasStr = atlasText.text;
+		atlasStr = atlasStr.Replace("\r", "");
 
 		string[] atlasLines = atlasStr.Split('\n');
 		List<string> pageFiles = new List<string>();
-		for(int i = 0; i < atlasLines.Length-1; i++){
-			if(atlasLines[i].Length == 0)
-				pageFiles.Add(atlasLines[i+1]);
+		for (int i = 0; i < atlasLines.Length-1; i++) {
+			if (atlasLines[i].Length == 0)
+				pageFiles.Add(atlasLines[i + 1]);
 		}
 		
 		atlasAsset.materials = new Material[pageFiles.Count];
 		
-		for(int i = 0; i < pageFiles.Count; i++){
+		for (int i = 0; i < pageFiles.Count; i++) {
 			string texturePath = assetPath + "/" + pageFiles[i];
 			Texture2D texture = (Texture2D)AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D));
 			
 			TextureImporter texImporter = (TextureImporter)TextureImporter.GetAtPath(texturePath);
 			texImporter.textureFormat = TextureImporterFormat.AutomaticTruecolor;
 			texImporter.mipmapEnabled = false;
-            texImporter.maxTextureSize = 2048;
+			texImporter.maxTextureSize = 2048;
 
 			EditorUtility.SetDirty(texImporter);
 			AssetDatabase.ImportAsset(texturePath);
@@ -407,14 +399,14 @@ public class SpineEditorUtilities : AssetPostprocessor {
 			string pageName = Path.GetFileNameWithoutExtension(pageFiles[i]);
 			
 			//because this looks silly
-			if(pageName == primaryName && pageFiles.Count == 1)
+			if (pageName == primaryName && pageFiles.Count == 1)
 				pageName = "Material";
 			
 			string materialPath = assetPath + "/" + primaryName + "_" + pageName + ".mat";
 			Material mat = (Material)AssetDatabase.LoadAssetAtPath(materialPath, typeof(Material));
 
-			if(mat == null){
-			 	mat = new Material(Shader.Find(defaultShader));
+			if (mat == null) {
+				mat = new Material(Shader.Find(defaultShader));
 				AssetDatabase.CreateAsset(mat, materialPath);
 			}
 			
@@ -426,7 +418,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
 			atlasAsset.materials[i] = mat;
 		}
 
-		if(AssetDatabase.GetAssetPath( atlasAsset ) == "")
+		if (AssetDatabase.GetAssetPath(atlasAsset) == "")
 			AssetDatabase.CreateAsset(atlasAsset, atlasPath);
 		else
 			atlasAsset.Reset();
@@ -436,17 +428,15 @@ public class SpineEditorUtilities : AssetPostprocessor {
 		return (AtlasAsset)AssetDatabase.LoadAssetAtPath(atlasPath, typeof(AtlasAsset));
 	}
 
-
-	static SkeletonDataAsset IngestSpineProject(TextAsset spineJson, AtlasAsset atlasAsset = null){
-
+	static SkeletonDataAsset IngestSpineProject (TextAsset spineJson, AtlasAsset atlasAsset = null) {
 		string primaryName = Path.GetFileNameWithoutExtension(spineJson.name);
-		string assetPath = Path.GetDirectoryName( AssetDatabase.GetAssetPath(spineJson));
+		string assetPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(spineJson));
 		string filePath = assetPath + "/" + primaryName + "_SkeletonData.asset";
 
-		if(spineJson != null && atlasAsset != null){
+		if (spineJson != null && atlasAsset != null) {
 
 			SkeletonDataAsset skelDataAsset = (SkeletonDataAsset)AssetDatabase.LoadAssetAtPath(filePath, typeof(SkeletonDataAsset));
-			if(skelDataAsset == null){
+			if (skelDataAsset == null) {
 				skelDataAsset = SkeletonDataAsset.CreateInstance<SkeletonDataAsset>();
 				skelDataAsset.atlasAsset = atlasAsset;
 				skelDataAsset.skeletonJSON = spineJson;
@@ -458,27 +448,23 @@ public class SpineEditorUtilities : AssetPostprocessor {
 				
 				AssetDatabase.CreateAsset(skelDataAsset, filePath);
 				AssetDatabase.SaveAssets();
-			}
-			else{
+			} else {
 				skelDataAsset.Reset();
 				skelDataAsset.GetSkeletonData(true);
 			}
 
 			return skelDataAsset;
-		}
-		else{
+		} else {
 			EditorUtility.DisplayDialog("Error!", "Must specify both Spine JSON and Atlas TextAsset", "OK");
 			return null;
 		}
 	}
 
 	[MenuItem("Assets/Spine/Spawn")]
-	static void SpawnAnimatedSkeleton(){
+	static void SpawnAnimatedSkeleton () {
 		Object[] arr = Selection.objects;
-
-		foreach(Object o in arr){
-
-			string guid = AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath( o ) );
+		foreach (Object o in arr) {
+			string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(o));
 			string skinName = EditorPrefs.GetString(guid + "_lastSkin", "");
 
 			SpawnAnimatedSkeleton((SkeletonDataAsset)o, skinName);
@@ -487,34 +473,33 @@ public class SpineEditorUtilities : AssetPostprocessor {
 	}
 
 	[MenuItem("Assets/Spine/Spawn", true)]
-	static bool ValidateSpawnAnimatedSkeleton(){
+	static bool ValidateSpawnAnimatedSkeleton () {
 		Object[] arr = Selection.objects;
 		
-		if(arr.Length == 0)
+		if (arr.Length == 0)
 			return false;
 		
-		foreach(Object o in arr){
-			if(o.GetType() != typeof(SkeletonDataAsset))
+		foreach (Object o in arr) {
+			if (o.GetType() != typeof(SkeletonDataAsset))
 				return false;
 		}
 		
 		return true;
 	}
 
-	public static SkeletonAnimation SpawnAnimatedSkeleton(SkeletonDataAsset skeletonDataAsset, string skinName){
+	public static SkeletonAnimation SpawnAnimatedSkeleton (SkeletonDataAsset skeletonDataAsset, string skinName) {
 		return SpawnAnimatedSkeleton(skeletonDataAsset, skeletonDataAsset.GetSkeletonData(true).FindSkin(skinName));
 	}
 
-		public static SkeletonAnimation SpawnAnimatedSkeleton(SkeletonDataAsset skeletonDataAsset, Skin skin = null){
-		
+	public static SkeletonAnimation SpawnAnimatedSkeleton (SkeletonDataAsset skeletonDataAsset, Skin skin = null) {
 		GameObject go = new GameObject(skeletonDataAsset.name.Replace("_SkeletonData", ""), typeof(MeshFilter), typeof(MeshRenderer), typeof(SkeletonAnimation));
 		SkeletonAnimation anim = go.GetComponent<SkeletonAnimation>();
 		anim.skeletonDataAsset = skeletonDataAsset;
 
 		bool requiresNormals = false;
 
-		foreach(Material m in anim.skeletonDataAsset.atlasAsset.materials){
-			if(m.shader.name.Contains("Lit")){
+		foreach (Material m in anim.skeletonDataAsset.atlasAsset.materials) {
+			if (m.shader.name.Contains("Lit")) {
 				requiresNormals = true;
 				break;
 			}
@@ -524,16 +509,16 @@ public class SpineEditorUtilities : AssetPostprocessor {
 
 		SkeletonData data = skeletonDataAsset.GetSkeletonData(true);
 
-		if(data == null){
-			string reloadAtlasPath = AssetDatabase.GetAssetPath( skeletonDataAsset.atlasAsset );
-			skeletonDataAsset.atlasAsset = (AtlasAsset)AssetDatabase.LoadAssetAtPath( reloadAtlasPath, typeof(AtlasAsset));
+		if (data == null) {
+			string reloadAtlasPath = AssetDatabase.GetAssetPath(skeletonDataAsset.atlasAsset);
+			skeletonDataAsset.atlasAsset = (AtlasAsset)AssetDatabase.LoadAssetAtPath(reloadAtlasPath, typeof(AtlasAsset));
 			data = skeletonDataAsset.GetSkeletonData(true);
 		}
 
-		if(skin == null)
+		if (skin == null)
 			skin = data.DefaultSkin;
 			
-		if(skin == null)
+		if (skin == null)
 			skin = data.Skins[0];
 
 		anim.Reset();
@@ -548,8 +533,4 @@ public class SpineEditorUtilities : AssetPostprocessor {
 
 		return anim;
 	}
-
-
 }
-
-

+ 13 - 8
spine-unity/Assets/spine-unity/SkeletonAnimation.cs

@@ -41,20 +41,23 @@ public class SkeletonAnimation : SkeletonRenderer {
 	public bool loop;
 	public Spine.AnimationState state;
 
-	public delegate void UpdateBonesDelegate(SkeletonAnimation skeleton);
+	public delegate void UpdateBonesDelegate (SkeletonAnimation skeleton);
+
 	public UpdateBonesDelegate UpdateLocal;
 	public UpdateBonesDelegate UpdateWorld;
 	public UpdateBonesDelegate UpdateComplete;
-
 	[SerializeField]
-	private String _animationName;
+	private String
+		_animationName;
+
 	public String AnimationName {
 		get {
 			TrackEntry entry = state.GetCurrent(0);
 			return entry == null ? null : entry.Animation.Name;
 		}
 		set {
-			if (_animationName == value) return;
+			if (_animationName == value)
+				return;
 			_animationName = value;
 			if (value == null || value.Length == 0)
 				state.ClearTrack(0);
@@ -65,7 +68,8 @@ public class SkeletonAnimation : SkeletonRenderer {
 
 	public override void Reset () {
 		base.Reset();
-		if (!valid) return;
+		if (!valid)
+			return;
 
 		state = new Spine.AnimationState(skeletonDataAsset.GetAnimationStateData());
 		if (_animationName != null && _animationName.Length > 0) {
@@ -79,7 +83,8 @@ public class SkeletonAnimation : SkeletonRenderer {
 	}
 
 	public virtual void Update (float deltaTime) {
-		if (!valid) return;
+		if (!valid)
+			return;
 
 		deltaTime *= timeScale;
 		skeleton.Update(deltaTime);
@@ -91,12 +96,12 @@ public class SkeletonAnimation : SkeletonRenderer {
 
 		skeleton.UpdateWorldTransform();
 
-		if (UpdateWorld != null){ 
+		if (UpdateWorld != null) { 
 			UpdateWorld(this);
 			skeleton.UpdateWorldTransform();
 		}
 
-		if (UpdateComplete != null){ 
+		if (UpdateComplete != null) { 
 			UpdateComplete(this);
 		}
 	}

+ 2 - 1
spine-unity/Assets/spine-unity/SkeletonDataAsset.cs

@@ -87,7 +87,8 @@ public class SkeletonDataAsset : ScriptableObject {
 		stateData = new AnimationStateData(skeletonData);
 		stateData.DefaultMix = defaultMix;
 		for (int i = 0, n = fromAnimation.Length; i < n; i++) {
-			if (fromAnimation[i].Length == 0 || toAnimation[i].Length == 0) continue;
+			if (fromAnimation[i].Length == 0 || toAnimation[i].Length == 0)
+				continue;
 			stateData.SetMix(fromAnimation[i], toAnimation[i], duration[i]);
 		}
 

+ 10 - 10
spine-unity/Assets/spine-unity/SkeletonExtensions.cs

@@ -39,68 +39,68 @@ using Spine;
 
 public static class SkeletonExtensions {
 	
-	public static void SetColor(this Slot slot, Color color){
+	public static void SetColor (this Slot slot, Color color) {
 		slot.A = color.a;
 		slot.R = color.r;
 		slot.G = color.g;
 		slot.B = color.b;
 	}
 
-	public static void SetColor(this Slot slot, Color32 color){
+	public static void SetColor (this Slot slot, Color32 color) {
 		slot.A = color.a / 255f;
 		slot.R = color.r / 255f;
 		slot.G = color.g / 255f;
 		slot.B = color.b / 255f;
 	}
 
-	public static void SetColor(this RegionAttachment attachment, Color color){
+	public static void SetColor (this RegionAttachment attachment, Color color) {
 		attachment.A = color.a;
 		attachment.R = color.r;
 		attachment.G = color.g;
 		attachment.B = color.b;
 	}
 
-	public static void SetColor(this RegionAttachment attachment, Color32 color){
+	public static void SetColor (this RegionAttachment attachment, Color32 color) {
 		attachment.A = color.a / 255f;
 		attachment.R = color.r / 255f;
 		attachment.G = color.g / 255f;
 		attachment.B = color.b / 255f;
 	}
 
-	public static void SetColor(this MeshAttachment attachment, Color color){
+	public static void SetColor (this MeshAttachment attachment, Color color) {
 		attachment.A = color.a;
 		attachment.R = color.r;
 		attachment.G = color.g;
 		attachment.B = color.b;
 	}
 
-	public static void SetColor(this MeshAttachment attachment, Color32 color){
+	public static void SetColor (this MeshAttachment attachment, Color32 color) {
 		attachment.A = color.a / 255f;
 		attachment.R = color.r / 255f;
 		attachment.G = color.g / 255f;
 		attachment.B = color.b / 255f;
 	}
 
-	public static void SetColor(this SkinnedMeshAttachment attachment, Color color){
+	public static void SetColor (this SkinnedMeshAttachment attachment, Color color) {
 		attachment.A = color.a;
 		attachment.R = color.r;
 		attachment.G = color.g;
 		attachment.B = color.b;
 	}
 
-	public static void SetColor(this SkinnedMeshAttachment attachment, Color32 color){
+	public static void SetColor (this SkinnedMeshAttachment attachment, Color32 color) {
 		attachment.A = color.a / 255f;
 		attachment.R = color.r / 255f;
 		attachment.G = color.g / 255f;
 		attachment.B = color.b / 255f;
 	}
 
-	public static void SetPosition(this Bone bone, Vector2 position){
+	public static void SetPosition (this Bone bone, Vector2 position) {
 		bone.X = position.x;
 		bone.Y = position.y;
 	}
 
-	public static void SetPosition(this Bone bone, Vector3 position){
+	public static void SetPosition (this Bone bone, Vector3 position) {
 		bone.X = position.x;
 		bone.Y = position.y;
 	}

+ 61 - 50
spine-unity/Assets/spine-unity/SkeletonRenderer.cs

@@ -38,21 +38,19 @@ using Spine;
 [ExecuteInEditMode, RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
 public class SkeletonRenderer : MonoBehaviour {
 
-	public delegate void SkeletonRendererDelegate(SkeletonRenderer skeletonRenderer);
+	public delegate void SkeletonRendererDelegate (SkeletonRenderer skeletonRenderer);
+
 	public SkeletonRendererDelegate OnReset;
-	
 	[System.NonSerialized]
 	public bool valid;
 	[System.NonSerialized]
 	public Skeleton skeleton;
-	
 	public SkeletonDataAsset skeletonDataAsset;
 	public String initialSkinName;
 	public bool calculateNormals, calculateTangents;
 	public float zSpacing;
 	public bool renderMeshes = true, immutableTriangles;
 	public bool logErrors = false;
-	
 	private MeshFilter meshFilter;
 	private Mesh mesh, mesh1, mesh2;
 	private bool useMesh1;
@@ -66,9 +64,12 @@ public class SkeletonRenderer : MonoBehaviour {
 	private readonly List<Submesh> submeshes = new List<Submesh>();
 
 	public virtual void Reset () {
-		if (meshFilter != null) meshFilter.sharedMesh = null;
-		if (mesh != null) DestroyImmediate(mesh);
-		if (renderer != null) renderer.sharedMaterial = null;
+		if (meshFilter != null)
+			meshFilter.sharedMesh = null;
+		if (mesh != null)
+			DestroyImmediate(mesh);
+		if (renderer != null)
+			renderer.sharedMaterial = null;
 		mesh = null;
 		mesh1 = null;
 		mesh2 = null;
@@ -83,13 +84,14 @@ public class SkeletonRenderer : MonoBehaviour {
 
 		valid = false;
 		if (!skeletonDataAsset) {
-			if(logErrors)
+			if (logErrors)
 				Debug.LogError("Missing SkeletonData asset.", this);
 
 			return;
 		}
 		SkeletonData skeletonData = skeletonDataAsset.GetSkeletonData(false);
-		if (skeletonData == null) return;
+		if (skeletonData == null)
+			return;
 		valid = true;
 		
 		meshFilter = GetComponent<MeshFilter>();
@@ -100,7 +102,8 @@ public class SkeletonRenderer : MonoBehaviour {
 		skeleton = new Skeleton(skeletonData);
 		if (initialSkinName != null && initialSkinName.Length > 0 && initialSkinName != "default")
 			skeleton.SetSkin(initialSkinName);
-		if(OnReset != null) OnReset(this);
+		if (OnReset != null)
+			OnReset(this);
 	}
 	
 	public void Awake () {
@@ -116,7 +119,8 @@ public class SkeletonRenderer : MonoBehaviour {
 	}
 	
 	public virtual void LateUpdate () {
-		if (!valid) return;
+		if (!valid)
+			return;
 		// Count vertices and submesh triangles.
 		int vertexCount = 0;
 		int submeshTriangleCount = 0, submeshFirstVertex = 0, submeshStartSlotIndex = 0;
@@ -137,19 +141,20 @@ public class SkeletonRenderer : MonoBehaviour {
 				attachmentVertexCount = 4;
 				attachmentTriangleCount = 6;
 			} else {
-				if (!renderMeshes) continue;
+				if (!renderMeshes)
+					continue;
 				if (attachment is MeshAttachment) {
 					MeshAttachment meshAttachment = (MeshAttachment)attachment;
 					rendererObject = meshAttachment.RendererObject;
 					attachmentVertexCount = meshAttachment.vertices.Length >> 1;
 					attachmentTriangleCount = meshAttachment.triangles.Length;
 				} else if (attachment is SkinnedMeshAttachment) {
-					SkinnedMeshAttachment meshAttachment = (SkinnedMeshAttachment)attachment;
-					rendererObject = meshAttachment.RendererObject;
-					attachmentVertexCount = meshAttachment.uvs.Length >> 1;
-					attachmentTriangleCount = meshAttachment.triangles.Length;
-				} else
-					continue;
+						SkinnedMeshAttachment meshAttachment = (SkinnedMeshAttachment)attachment;
+						rendererObject = meshAttachment.RendererObject;
+						attachmentVertexCount = meshAttachment.uvs.Length >> 1;
+						attachmentTriangleCount = meshAttachment.triangles.Length;
+					} else
+						continue;
 			}
 
 			// Populate submesh when material changes.
@@ -217,7 +222,8 @@ public class SkeletonRenderer : MonoBehaviour {
 				color.r = (byte)(r * slot.r * regionAttachment.r * color.a);
 				color.g = (byte)(g * slot.g * regionAttachment.g * color.a);
 				color.b = (byte)(b * slot.b * regionAttachment.b * color.a);
-				if (slot.data.additiveBlending) color.a = 0;
+				if (slot.data.additiveBlending)
+					color.a = 0;
 				colors[vertexIndex] = color;
 				colors[vertexIndex + 1] = color;
 				colors[vertexIndex + 2] = color;
@@ -231,18 +237,21 @@ public class SkeletonRenderer : MonoBehaviour {
 				
 				vertexIndex += 4;
 			} else {
-				if (!renderMeshes) continue;
+				if (!renderMeshes)
+					continue;
 				if (attachment is MeshAttachment) {
 					MeshAttachment meshAttachment = (MeshAttachment)attachment;
 					int meshVertexCount = meshAttachment.vertices.Length;
-					if (tempVertices.Length < meshVertexCount) tempVertices = new float[meshVertexCount];
+					if (tempVertices.Length < meshVertexCount)
+						tempVertices = new float[meshVertexCount];
 					meshAttachment.ComputeWorldVertices(slot, tempVertices);
 					
 					color.a = (byte)(a * slot.a * meshAttachment.a);
 					color.r = (byte)(r * slot.r * meshAttachment.r * color.a);
 					color.g = (byte)(g * slot.g * meshAttachment.g * color.a);
 					color.b = (byte)(b * slot.b * meshAttachment.b * color.a);
-					if (slot.data.additiveBlending) color.a = 0;
+					if (slot.data.additiveBlending)
+						color.a = 0;
 					
 					float[] meshUVs = meshAttachment.uvs;
 					float z = i * zSpacing;
@@ -252,25 +261,27 @@ public class SkeletonRenderer : MonoBehaviour {
 						uvs[vertexIndex] = new Vector2(meshUVs[ii], meshUVs[ii + 1]);
 					}
 				} else if (attachment is SkinnedMeshAttachment) {
-					SkinnedMeshAttachment meshAttachment = (SkinnedMeshAttachment)attachment;
-					int meshVertexCount = meshAttachment.uvs.Length;
-					if (tempVertices.Length < meshVertexCount) tempVertices = new float[meshVertexCount];
-					meshAttachment.ComputeWorldVertices(slot, tempVertices);
+						SkinnedMeshAttachment meshAttachment = (SkinnedMeshAttachment)attachment;
+						int meshVertexCount = meshAttachment.uvs.Length;
+						if (tempVertices.Length < meshVertexCount)
+							tempVertices = new float[meshVertexCount];
+						meshAttachment.ComputeWorldVertices(slot, tempVertices);
 					
-					color.a = (byte)(a * slot.a * meshAttachment.a);
-					color.r = (byte)(r * slot.r * meshAttachment.r * color.a);
-					color.g = (byte)(g * slot.g * meshAttachment.g * color.a);
-					color.b = (byte)(b * slot.b * meshAttachment.b * color.a);
-					if (slot.data.additiveBlending) color.a = 0;
+						color.a = (byte)(a * slot.a * meshAttachment.a);
+						color.r = (byte)(r * slot.r * meshAttachment.r * color.a);
+						color.g = (byte)(g * slot.g * meshAttachment.g * color.a);
+						color.b = (byte)(b * slot.b * meshAttachment.b * color.a);
+						if (slot.data.additiveBlending)
+							color.a = 0;
 					
-					float[] meshUVs = meshAttachment.uvs;
-					float z = i * zSpacing;
-					for (int ii = 0; ii < meshVertexCount; ii += 2, vertexIndex++) {
-						vertices[vertexIndex] = new Vector3(tempVertices[ii], tempVertices[ii + 1], z);
-						colors[vertexIndex] = color;
-						uvs[vertexIndex] = new Vector2(meshUVs[ii], meshUVs[ii + 1]);
+						float[] meshUVs = meshAttachment.uvs;
+						float z = i * zSpacing;
+						for (int ii = 0; ii < meshVertexCount; ii += 2, vertexIndex++) {
+							vertices[vertexIndex] = new Vector3(tempVertices[ii], tempVertices[ii + 1], z);
+							colors[vertexIndex] = color;
+							uvs[vertexIndex] = new Vector2(meshUVs[ii], meshUVs[ii + 1]);
+						}
 					}
-				}
 			}
 		}
 		
@@ -318,7 +329,7 @@ public class SkeletonRenderer : MonoBehaviour {
 		if (submeshes.Count <= submeshIndex)
 			submeshes.Add(new Submesh());
 		else if (immutableTriangles)
-			return;
+				return;
 
 		Submesh submesh = submeshes[submeshIndex];
 		
@@ -330,10 +341,10 @@ public class SkeletonRenderer : MonoBehaviour {
 				triangles[i] = 0;
 			submesh.triangleCount = triangleCount;
 		} else if (trianglesCapacity != triangleCount) {
-			// Reallocate triangles when not the exact size needed.
-			submesh.triangles = triangles = new int[triangleCount];
-			submesh.triangleCount = 0;
-		}
+				// Reallocate triangles when not the exact size needed.
+				submesh.triangles = triangles = new int[triangleCount];
+				submesh.triangleCount = 0;
+			}
 
 		if (!renderMeshes) {
 			// Use stored triangles if possible.
@@ -374,18 +385,18 @@ public class SkeletonRenderer : MonoBehaviour {
 				attachmentVertexCount = meshAttachment.vertices.Length >> 1;
 				attachmentTriangles = meshAttachment.triangles;
 			} else if (attachment is SkinnedMeshAttachment) {
-				SkinnedMeshAttachment meshAttachment = (SkinnedMeshAttachment)attachment;
-				attachmentVertexCount = meshAttachment.uvs.Length >> 1;
-				attachmentTriangles = meshAttachment.triangles;
-			} else
-				continue;
+					SkinnedMeshAttachment meshAttachment = (SkinnedMeshAttachment)attachment;
+					attachmentVertexCount = meshAttachment.uvs.Length >> 1;
+					attachmentTriangles = meshAttachment.triangles;
+				} else
+					continue;
 			for (int ii = 0, nn = attachmentTriangles.Length; ii < nn; ii++, triangleIndex++)
 				triangles[triangleIndex] = firstVertex + attachmentTriangles[ii];
 			firstVertex += attachmentVertexCount;
 		}
 	}
 	
-	#if UNITY_EDITOR
+#if UNITY_EDITOR
 	void OnDrawGizmos() {
 		// Make selection easier by drawing a clear gizmo over the skeleton.
 		if (vertices == null) return;
@@ -405,7 +416,7 @@ public class SkeletonRenderer : MonoBehaviour {
 		Gizmos.matrix = transform.localToWorldMatrix;
 		Gizmos.DrawCube(gizmosCenter, gizmosSize);
 	}
-	#endif
+#endif
 }
 
 class Submesh {

+ 82 - 89
spine-unity/Assets/spine-unity/SkeletonUtility/Editor/SkeletonUtilityBoneInspector.cs

@@ -32,7 +32,6 @@
  * Skeleton Utility created by Mitch Thompson
  * Full irrevocable rights and permissions granted to Esoteric Software
 *****************************************************************************/
-
 using UnityEngine;
 using UnityEditor;
 using System.Collections;
@@ -41,7 +40,7 @@ using Spine;
 
 [CustomEditor(typeof(SkeletonUtilityBone)), CanEditMultipleObjects]
 public class SkeletonUtilityBoneInspector : Editor {
-    SerializedProperty mode, boneName, zPosition, position, rotation, scale, overrideAlpha, parentReference, flip, flipX;
+	SerializedProperty mode, boneName, zPosition, position, rotation, scale, overrideAlpha, parentReference, flip, flipX;
 
 	//multi selected flags
 	bool containsFollows, containsOverrides, multiObject;
@@ -51,7 +50,7 @@ public class SkeletonUtilityBoneInspector : Editor {
 	SkeletonUtility skeletonUtility;
 	bool canCreateHingeChain = false;
 	
-	void OnEnable(){
+	void OnEnable () {
 		mode = this.serializedObject.FindProperty("mode");
 		boneName = this.serializedObject.FindProperty("boneName");
 		zPosition = this.serializedObject.FindProperty("zPosition");
@@ -60,72 +59,69 @@ public class SkeletonUtilityBoneInspector : Editor {
 		scale = this.serializedObject.FindProperty("scale");
 		overrideAlpha = this.serializedObject.FindProperty("overrideAlpha");
 		parentReference = this.serializedObject.FindProperty("parentReference");
-        flip = this.serializedObject.FindProperty("flip");
-        flipX = this.serializedObject.FindProperty("flipX");
+		flip = this.serializedObject.FindProperty("flip");
+		flipX = this.serializedObject.FindProperty("flipX");
 
 		EvaluateFlags();
 
-		if(utilityBone.valid == false && skeletonUtility != null && skeletonUtility.skeletonRenderer != null){
+		if (utilityBone.valid == false && skeletonUtility != null && skeletonUtility.skeletonRenderer != null) {
 			skeletonUtility.skeletonRenderer.Reset();
 		}
 
 		canCreateHingeChain = CanCreateHingeChain();
 	}
 
-	/// <summary>
-	/// Evaluates the flags.
-	/// </summary>
-	void EvaluateFlags(){
+	void EvaluateFlags () {
 		utilityBone = (SkeletonUtilityBone)target;
 		skeletonUtility = utilityBone.skeletonUtility;
 
-		if(Selection.objects.Length == 1){
+		if (Selection.objects.Length == 1) {
 			containsFollows = utilityBone.mode == SkeletonUtilityBone.Mode.Follow;
 			containsOverrides = utilityBone.mode == SkeletonUtilityBone.Mode.Override;
-		}
-		else{
+		} else {
 			int boneCount = 0;
-			foreach(Object o in Selection.objects){
-				if(o is GameObject){
+			foreach (Object o in Selection.objects) {
+				if (o is GameObject) {
 					GameObject go = (GameObject)o;
 					SkeletonUtilityBone sub = go.GetComponent<SkeletonUtilityBone>();
-					if(sub != null){
+					if (sub != null) {
 						boneCount++;
-						if(sub.mode == SkeletonUtilityBone.Mode.Follow)
+						if (sub.mode == SkeletonUtilityBone.Mode.Follow)
 							containsFollows = true;
-						if(sub.mode == SkeletonUtilityBone.Mode.Override)
+						if (sub.mode == SkeletonUtilityBone.Mode.Override)
 							containsOverrides = true;
 					}
 				}
 			}
 			
-			if(boneCount > 1)
+			if (boneCount > 1)
 				multiObject = true;
 		}
 	}
 	
-	public override void OnInspectorGUI ()
-	{
+	public override void OnInspectorGUI () {
 		serializedObject.Update();
 
 		EditorGUI.BeginChangeCheck();
 		EditorGUILayout.PropertyField(mode);
-		if(EditorGUI.EndChangeCheck()){
+		if (EditorGUI.EndChangeCheck()) {
 			containsOverrides = mode.enumValueIndex == 1;
 			containsFollows = mode.enumValueIndex == 0;
 		}
 
-		EditorGUI.BeginDisabledGroup( multiObject );
+		EditorGUI.BeginDisabledGroup(multiObject);
 		{
 			string str = boneName.stringValue;
-			if(str == "") str = "<None>";
-			if(multiObject) str = "<Multiple>";
+			if (str == "")
+				str = "<None>";
+			if (multiObject)
+				str = "<Multiple>";
 
 			GUILayout.BeginHorizontal();
 			EditorGUILayout.PrefixLabel("Bone");
 
-			if(GUILayout.Button( str, EditorStyles.popup )){
-				BoneSelectorContextMenu( str, ((SkeletonUtilityBone)target).skeletonUtility.skeletonRenderer.skeleton.Bones, "<None>", TargetBoneSelected );
+			if (GUILayout.Button(str, EditorStyles.popup)) {
+				BoneSelectorContextMenu(str, ((SkeletonUtilityBone)target).skeletonUtility.skeletonRenderer.skeleton.Bones, "<None>", TargetBoneSelected);
 			}
 
 			GUILayout.EndHorizontal();
@@ -136,23 +132,22 @@ public class SkeletonUtilityBoneInspector : Editor {
 		EditorGUILayout.PropertyField(position);
 		EditorGUILayout.PropertyField(rotation);
 		EditorGUILayout.PropertyField(scale);
-        EditorGUILayout.PropertyField(flip);
+		EditorGUILayout.PropertyField(flip);
 
-		EditorGUI.BeginDisabledGroup( containsFollows );
+		EditorGUI.BeginDisabledGroup(containsFollows);
 		{
 			EditorGUILayout.PropertyField(overrideAlpha);
 			EditorGUILayout.PropertyField(parentReference);
 
-            EditorGUI.BeginDisabledGroup(multiObject || !flip.boolValue);
-            {
-                EditorGUI.BeginChangeCheck();
-                EditorGUILayout.PropertyField(flipX);
-                if (EditorGUI.EndChangeCheck())
-                {
-                    FlipX(flipX.boolValue);
-                }
-            }
-            EditorGUI.EndDisabledGroup();
+			EditorGUI.BeginDisabledGroup(multiObject || !flip.boolValue);
+			{
+				EditorGUI.BeginChangeCheck();
+				EditorGUILayout.PropertyField(flipX);
+				if (EditorGUI.EndChangeCheck()) {
+					FlipX(flipX.boolValue);
+				}
+			}
+			EditorGUI.EndDisabledGroup();
 
 		}
 		EditorGUI.EndDisabledGroup();
@@ -161,23 +156,23 @@ public class SkeletonUtilityBoneInspector : Editor {
 
 		GUILayout.BeginHorizontal();
 		{
-			EditorGUI.BeginDisabledGroup( multiObject || !utilityBone.valid || utilityBone.bone == null || utilityBone.bone.Children.Count == 0);
+			EditorGUI.BeginDisabledGroup(multiObject || !utilityBone.valid || utilityBone.bone == null || utilityBone.bone.Children.Count == 0);
 			{
-				if(GUILayout.Button(new GUIContent("Add Child", SpineEditorUtilities.Icons.bone), GUILayout.Width(150), GUILayout.Height(24)))
-					BoneSelectorContextMenu( "", utilityBone.bone.Children, "<Recursively>", SpawnChildBoneSelected);
+				if (GUILayout.Button(new GUIContent("Add Child", SpineEditorUtilities.Icons.bone), GUILayout.Width(150), GUILayout.Height(24)))
+					BoneSelectorContextMenu("", utilityBone.bone.Children, "<Recursively>", SpawnChildBoneSelected);
 			}
 			EditorGUI.EndDisabledGroup();
 
-			EditorGUI.BeginDisabledGroup( multiObject || !utilityBone.valid || utilityBone.bone == null || containsOverrides);
+			EditorGUI.BeginDisabledGroup(multiObject || !utilityBone.valid || utilityBone.bone == null || containsOverrides);
 			{
-				if(GUILayout.Button(new GUIContent("Add Override", SpineEditorUtilities.Icons.poseBones), GUILayout.Width(150), GUILayout.Height(24)))
+				if (GUILayout.Button(new GUIContent("Add Override", SpineEditorUtilities.Icons.poseBones), GUILayout.Width(150), GUILayout.Height(24)))
 					SpawnOverride();
 			}
 			EditorGUI.EndDisabledGroup();
 
-			EditorGUI.BeginDisabledGroup( multiObject || !utilityBone.valid || !canCreateHingeChain );
+			EditorGUI.BeginDisabledGroup(multiObject || !utilityBone.valid || !canCreateHingeChain);
 			{
-				if(GUILayout.Button(new GUIContent("Create Hinge Chain", SpineEditorUtilities.Icons.hingeChain), GUILayout.Width(150), GUILayout.Height(24)))
+				if (GUILayout.Button(new GUIContent("Create Hinge Chain", SpineEditorUtilities.Icons.hingeChain), GUILayout.Width(150), GUILayout.Height(24)))
 					CreateHingeChain();
 			}
 			EditorGUI.EndDisabledGroup();
@@ -188,36 +183,32 @@ public class SkeletonUtilityBoneInspector : Editor {
 		serializedObject.ApplyModifiedProperties();
 	}
 
-    void FlipX(bool state)
-    {
-        utilityBone.FlipX(state);
-        if (Application.isPlaying == false)
-        {
-            skeletonUtility.skeletonAnimation.LateUpdate();
-        }
-    }
+	void FlipX (bool state) {
+		utilityBone.FlipX(state);
+		if (Application.isPlaying == false) {
+			skeletonUtility.skeletonAnimation.LateUpdate();
+		}
+	}
 
-	void BoneSelectorContextMenu(string current, List<Bone> bones, string topValue, GenericMenu.MenuFunction2 callback){
+	void BoneSelectorContextMenu (string current, List<Bone> bones, string topValue, GenericMenu.MenuFunction2 callback) {
 		GenericMenu menu = new GenericMenu();
 
-		if(topValue != "")
-			menu.AddItem( new GUIContent(topValue), current == topValue, callback, null );
+		if (topValue != "")
+			menu.AddItem(new GUIContent(topValue), current == topValue, callback, null);
 
-		for(int i = 0; i < bones.Count; i++){
-			menu.AddItem( new GUIContent(bones[i].Data.Name), bones[i].Data.Name == current, callback, bones[i] );
+		for (int i = 0; i < bones.Count; i++) {
+			menu.AddItem(new GUIContent(bones[i].Data.Name), bones[i].Data.Name == current, callback, bones[i]);
 		}
 
 		menu.ShowAsContext();
 
 	}
 
-
-	void TargetBoneSelected(object obj){
-		if(obj == null){
+	void TargetBoneSelected (object obj) {
+		if (obj == null) {
 			boneName.stringValue = "";
 			serializedObject.ApplyModifiedProperties();
-		}
-		else{
+		} else {
 			Bone bone = (Bone)obj;
 			boneName.stringValue = bone.Data.Name;
 			serializedObject.ApplyModifiedProperties();
@@ -226,56 +217,59 @@ public class SkeletonUtilityBoneInspector : Editor {
 		}
 	}
 
-	void SpawnChildBoneSelected(object obj){
-		if(obj == null){
+	void SpawnChildBoneSelected (object obj) {
+		if (obj == null) {
 			//add recursively
-			foreach(var bone in utilityBone.bone.Children){
-				GameObject go = skeletonUtility.SpawnBoneRecursively( bone, utilityBone.transform, utilityBone.mode, utilityBone.position, utilityBone.rotation, utilityBone.scale );
+			foreach (var bone in utilityBone.bone.Children) {
+				GameObject go = skeletonUtility.SpawnBoneRecursively(bone, utilityBone.transform, utilityBone.mode, utilityBone.position, utilityBone.rotation, utilityBone.scale);
 				SkeletonUtilityBone[] newUtilityBones = go.GetComponentsInChildren<SkeletonUtilityBone>();
-				foreach(SkeletonUtilityBone utilBone in newUtilityBones)
+				foreach (SkeletonUtilityBone utilBone in newUtilityBones)
 					SkeletonUtilityInspector.AttachIcon(utilBone);
 			}
-		}
-		else{
+		} else {
 			Bone bone = (Bone)obj;
-			GameObject go = skeletonUtility.SpawnBone( bone, utilityBone.transform, utilityBone.mode, utilityBone.position, utilityBone.rotation, utilityBone.scale );
+			GameObject go = skeletonUtility.SpawnBone(bone, utilityBone.transform, utilityBone.mode, utilityBone.position, utilityBone.rotation, utilityBone.scale);
 			SkeletonUtilityInspector.AttachIcon(go.GetComponent<SkeletonUtilityBone>());
 			Selection.activeGameObject = go;
 			EditorGUIUtility.PingObject(go);
 		}
 	}
 
-	void SpawnOverride(){
-		GameObject go = skeletonUtility.SpawnBone( utilityBone.bone, utilityBone.transform.parent, SkeletonUtilityBone.Mode.Override, utilityBone.position, utilityBone.rotation, utilityBone.scale);
+	void SpawnOverride () {
+		GameObject go = skeletonUtility.SpawnBone(utilityBone.bone, utilityBone.transform.parent, SkeletonUtilityBone.Mode.Override, utilityBone.position, utilityBone.rotation, utilityBone.scale);
 		go.name = go.name + " [Override]";
 		SkeletonUtilityInspector.AttachIcon(go.GetComponent<SkeletonUtilityBone>());
 		Selection.activeGameObject = go;
 		EditorGUIUtility.PingObject(go);
 	}
 
-	bool CanCreateHingeChain(){
-		if(utilityBone == null) return false;
-		if(utilityBone.rigidbody != null) return false;
-		if(utilityBone.bone != null && utilityBone.bone.Children.Count == 0) return false;
+	bool CanCreateHingeChain () {
+		if (utilityBone == null)
+			return false;
+		if (utilityBone.rigidbody != null)
+			return false;
+		if (utilityBone.bone != null && utilityBone.bone.Children.Count == 0)
+			return false;
 
 		Rigidbody[] rigidbodies = utilityBone.GetComponentsInChildren<Rigidbody>();
 
-		if(rigidbodies.Length > 0) return false;
+		if (rigidbodies.Length > 0)
+			return false;
 
 		return true;
 	}
 
-	void CreateHingeChain(){
+	void CreateHingeChain () {
 		var utilBoneArr = utilityBone.GetComponentsInChildren<SkeletonUtilityBone>();
 
-		foreach(var utilBone in utilBoneArr){
+		foreach (var utilBone in utilBoneArr) {
 			AttachRigidbody(utilBone);
 		}
 
 		utilityBone.rigidbody.isKinematic = true;
 
-		foreach(var utilBone in utilBoneArr){
-			if(utilBone == utilityBone)
+		foreach (var utilBone in utilBoneArr) {
+			if (utilBone == utilityBone)
 				continue;
 
 			utilBone.mode = SkeletonUtilityBone.Mode.Override;
@@ -292,16 +286,15 @@ public class SkeletonUtilityBoneInspector : Editor {
 		}
 	}
 	
-	void AttachRigidbody(SkeletonUtilityBone utilBone){
-		if(utilBone.GetComponent<Collider>() == null){
-			if(utilBone.bone.Data.Length == 0){
+	void AttachRigidbody (SkeletonUtilityBone utilBone) {
+		if (utilBone.GetComponent<Collider>() == null) {
+			if (utilBone.bone.Data.Length == 0) {
 				SphereCollider sphere = utilBone.gameObject.AddComponent<SphereCollider>();
 				sphere.radius = 0.1f;
-			}
-			else{
+			} else {
 				float length = utilBone.bone.Data.Length;
 				BoxCollider box = utilBone.gameObject.AddComponent<BoxCollider>();
-				box.size = new Vector3( length, length / 3, 0.2f);
+				box.size = new Vector3(length, length / 3, 0.2f);
 				box.center = new Vector3(length / 2, 0, 0);
 			}
 		}

+ 65 - 70
spine-unity/Assets/spine-unity/SkeletonUtility/Editor/SkeletonUtilityInspector.cs

@@ -32,9 +32,9 @@
  * Skeleton Utility created by Mitch Thompson
  * Full irrevocable rights and permissions granted to Esoteric Software
 *****************************************************************************/
-
 using UnityEngine;
 using UnityEditor;
+
 #if UNITY_4_3
 //nothing
 #else
@@ -49,16 +49,16 @@ using System.Reflection;
 [CustomEditor(typeof(SkeletonUtility))]
 public class SkeletonUtilityInspector : Editor {
 
-	public static void AttachIcon(SkeletonUtilityBone utilityBone){
+	public static void AttachIcon (SkeletonUtilityBone utilityBone) {
 		Skeleton skeleton = utilityBone.skeletonUtility.skeletonRenderer.skeleton;
 		Texture2D icon;
-		if(utilityBone.bone.Data.Length == 0)
+		if (utilityBone.bone.Data.Length == 0)
 			icon = SpineEditorUtilities.Icons.nullBone;
 		else
 			icon = SpineEditorUtilities.Icons.boneNib;
 		
-		foreach(IkConstraint c in skeleton.IkConstraints){
-			if(c.Target == utilityBone.bone){
+		foreach (IkConstraint c in skeleton.IkConstraints) {
+			if (c.Target == utilityBone.bone) {
 				icon = SpineEditorUtilities.Icons.constraintNib;
 				break;
 			}
@@ -66,21 +66,22 @@ public class SkeletonUtilityInspector : Editor {
 		
 		
 		
-		typeof(EditorGUIUtility).InvokeMember("SetIconForObject", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.NonPublic, null, null, new object[2]{ utilityBone.gameObject, icon});
+		typeof(EditorGUIUtility).InvokeMember("SetIconForObject", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.NonPublic, null, null, new object[2] {
+			utilityBone.gameObject,
+			icon
+		});
 	}
 
-	static void AttachIconsToChildren(Transform root){
-		if(root != null){
+	static void AttachIconsToChildren (Transform root) {
+		if (root != null) {
 			var utilityBones = root.GetComponentsInChildren<SkeletonUtilityBone>();
-			foreach(var utilBone in utilityBones){
+			foreach (var utilBone in utilityBones) {
 				AttachIcon(utilBone);
 			}
 		}
 	}
 
-
-
-	static SkeletonUtilityInspector(){
+	static SkeletonUtilityInspector () {
 		#if UNITY_4_3
 		showSlots = false;
 		#else
@@ -89,13 +90,10 @@ public class SkeletonUtilityInspector : Editor {
 	}
 
 	SkeletonUtility skeletonUtility;
-
 	Skeleton skeleton;
 	SkeletonRenderer skeletonRenderer;
 	Transform transform;
 	bool isPrefab;
-
-
 	Dictionary<Slot, List<Attachment>> attachmentTable = new Dictionary<Slot, List<Attachment>>();
 
 
@@ -106,13 +104,13 @@ public class SkeletonUtilityInspector : Editor {
 	static AnimBool showSlots;
 #endif
 
-	void OnEnable(){
+	void OnEnable () {
 		skeletonUtility = (SkeletonUtility)target;
 		skeletonRenderer = skeletonUtility.GetComponent<SkeletonRenderer>();
 		skeleton = skeletonRenderer.skeleton;
 		transform = skeletonRenderer.transform;
 
-		if(skeleton == null){
+		if (skeleton == null) {
 			skeletonRenderer.Reset();
 			skeletonRenderer.LateUpdate();
 
@@ -121,44 +119,44 @@ public class SkeletonUtilityInspector : Editor {
 
 		UpdateAttachments();
 
-		if(PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab)
+		if (PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab)
 			isPrefab = true;
 
 	}
 
-	void OnDestroy(){
+	void OnDestroy () {
 
 	}
 
-	void OnSceneGUI(){
-		if(skeleton == null){
+	void OnSceneGUI () {
+		if (skeleton == null) {
 			OnEnable();
 			return;
 		}
 
 		float flipRotation = skeleton.FlipX ? -1 : 1;
 
-		foreach(Bone b in skeleton.Bones){
+		foreach (Bone b in skeleton.Bones) {
 			Vector3 vec = transform.TransformPoint(new Vector3(b.WorldX, b.WorldY, 0));
 
-			Quaternion rot = Quaternion.Euler(0,0,b.WorldRotation * flipRotation);
-			Vector3 forward = transform.TransformDirection( rot * Vector3.right);
+			Quaternion rot = Quaternion.Euler(0, 0, b.WorldRotation * flipRotation);
+			Vector3 forward = transform.TransformDirection(rot * Vector3.right);
 			forward *= flipRotation;
 
 			SpineEditorUtilities.Icons.boneMaterial.SetPass(0);
-			Graphics.DrawMeshNow( SpineEditorUtilities.Icons.boneMesh, Matrix4x4.TRS ( vec, Quaternion.LookRotation(transform.forward, forward), Vector3.one * b.Data.Length * b.WorldScaleX));
+			Graphics.DrawMeshNow(SpineEditorUtilities.Icons.boneMesh, Matrix4x4.TRS(vec, Quaternion.LookRotation(transform.forward, forward), Vector3.one * b.Data.Length * b.WorldScaleX));
 		}
 	}
 
-	void UpdateAttachments(){
+	void UpdateAttachments () {
 		attachmentTable = new Dictionary<Slot, List<Attachment>>();
 		Skin skin = skeleton.Skin;
 
-		if(skin == null){
+		if (skin == null) {
 			skin = skeletonRenderer.skeletonDataAsset.GetSkeletonData(true).DefaultSkin;
 		}
 
-		for(int i = skeleton.Slots.Count-1; i >= 0; i--){
+		for (int i = skeleton.Slots.Count-1; i >= 0; i--) {
 			List<Attachment> attachments = new List<Attachment>();
 			skin.FindAttachmentsForSlot(i, attachments);
 
@@ -166,49 +164,48 @@ public class SkeletonUtilityInspector : Editor {
 		}
 	}
 
-	void SpawnHierarchyButton(string label, string tooltip, SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca, params GUILayoutOption[] options){
+	void SpawnHierarchyButton (string label, string tooltip, SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca, params GUILayoutOption[] options) {
 		GUIContent content = new GUIContent(label, tooltip);
-		if(GUILayout.Button(content, options)){
-			if(skeletonUtility.skeletonRenderer == null)
+		if (GUILayout.Button(content, options)) {
+			if (skeletonUtility.skeletonRenderer == null)
 				skeletonUtility.skeletonRenderer = skeletonUtility.GetComponent<SkeletonRenderer>();
 
-			if(skeletonUtility.boneRoot != null){
+			if (skeletonUtility.boneRoot != null) {
 				return;
 			}
 
 			skeletonUtility.SpawnHierarchy(mode, pos, rot, sca);
 
 			SkeletonUtilityBone[] boneComps = skeletonUtility.GetComponentsInChildren<SkeletonUtilityBone>();
-			foreach(SkeletonUtilityBone b in boneComps) 
+			foreach (SkeletonUtilityBone b in boneComps) 
 				AttachIcon(b);
 		}
 	}
 
-	public override void OnInspectorGUI ()
-	{
-		if(isPrefab){
+	public override void OnInspectorGUI () {
+		if (isPrefab) {
 			GUILayout.Label(new GUIContent("Cannot edit Prefabs", SpineEditorUtilities.Icons.warning));
 			return;
 		}
 
-		skeletonUtility.boneRoot = (Transform)EditorGUILayout.ObjectField( "Bone Root", skeletonUtility.boneRoot, typeof(Transform), true);
+		skeletonUtility.boneRoot = (Transform)EditorGUILayout.ObjectField("Bone Root", skeletonUtility.boneRoot, typeof(Transform), true);
 
 		GUILayout.BeginHorizontal();
 		EditorGUI.BeginDisabledGroup(skeletonUtility.boneRoot != null);
 		{
-			if(GUILayout.Button(new GUIContent("Spawn Hierarchy", SpineEditorUtilities.Icons.skeleton), GUILayout.Width(150), GUILayout.Height(24)))
+			if (GUILayout.Button(new GUIContent("Spawn Hierarchy", SpineEditorUtilities.Icons.skeleton), GUILayout.Width(150), GUILayout.Height(24)))
 				SpawnHierarchyContextMenu();
 		}
 		EditorGUI.EndDisabledGroup();
 
-		if(GUILayout.Button(new GUIContent("Spawn Submeshes", SpineEditorUtilities.Icons.subMeshRenderer), GUILayout.Width(150), GUILayout.Height(24)))
+		if (GUILayout.Button(new GUIContent("Spawn Submeshes", SpineEditorUtilities.Icons.subMeshRenderer), GUILayout.Width(150), GUILayout.Height(24)))
 			skeletonUtility.SpawnSubRenderers(true);
 		GUILayout.EndHorizontal();
 
 		EditorGUI.BeginChangeCheck();
 		skeleton.FlipX = EditorGUILayout.ToggleLeft("Flip X", skeleton.FlipX);
 		skeleton.FlipY = EditorGUILayout.ToggleLeft("Flip Y", skeleton.FlipY);
-		if(EditorGUI.EndChangeCheck()){
+		if (EditorGUI.EndChangeCheck()) {
 			skeletonRenderer.LateUpdate();
 			SceneView.RepaintAll();
 		}
@@ -217,9 +214,9 @@ public class SkeletonUtilityInspector : Editor {
 		showSlots = EditorGUILayout.Foldout(showSlots, "Slots");
 #else
 		showSlots.target = EditorGUILayout.Foldout(showSlots.target, "Slots");
-		if(EditorGUILayout.BeginFadeGroup(showSlots.faded)){
+		if (EditorGUILayout.BeginFadeGroup(showSlots.faded)) {
 #endif
-			foreach(KeyValuePair<Slot, List<Attachment>> pair in attachmentTable){
+			foreach (KeyValuePair<Slot, List<Attachment>> pair in attachmentTable) {
 
 				Slot slot = pair.Key;
 
@@ -230,8 +227,8 @@ public class SkeletonUtilityInspector : Editor {
 				EditorGUI.BeginChangeCheck();
 				Color c = EditorGUILayout.ColorField(new Color(slot.R, slot.G, slot.B, slot.A), GUILayout.Width(60));
 
-				if(EditorGUI.EndChangeCheck()){
-					slot.SetColor( c );
+				if (EditorGUI.EndChangeCheck()) {
+					slot.SetColor(c);
 					skeletonRenderer.LateUpdate();
 				}
 
@@ -239,12 +236,11 @@ public class SkeletonUtilityInspector : Editor {
 
 
 
-				foreach(Attachment attachment in pair.Value){
+				foreach (Attachment attachment in pair.Value) {
 
-					if(slot.Attachment == attachment){
+					if (slot.Attachment == attachment) {
 						GUI.contentColor = Color.white;
-					}
-					else{
+					} else {
 						GUI.contentColor = Color.grey;
 					}
 
@@ -253,21 +249,20 @@ public class SkeletonUtilityInspector : Editor {
 
 					Texture2D icon = null;
 
-					if(attachment is MeshAttachment || attachment is SkinnedMeshAttachment)
+					if (attachment is MeshAttachment || attachment is SkinnedMeshAttachment)
 						icon = SpineEditorUtilities.Icons.mesh;
 					else
 						icon = SpineEditorUtilities.Icons.image;
 
-					bool swap = EditorGUILayout.ToggleLeft( new GUIContent( attachment.Name, icon ), attachment == slot.Attachment );
+					bool swap = EditorGUILayout.ToggleLeft(new GUIContent(attachment.Name, icon), attachment == slot.Attachment);
 
-					if(!isAttached && swap){
+					if (!isAttached && swap) {
 						slot.Attachment = attachment;
 						skeletonRenderer.LateUpdate();
-					}
-					else if(isAttached && !swap){
-						slot.Attachment = null;
-						skeletonRenderer.LateUpdate();
-					}
+					} else if (isAttached && !swap) {
+							slot.Attachment = null;
+							skeletonRenderer.LateUpdate();
+						}
 
 					GUI.contentColor = Color.white;
 				}
@@ -277,12 +272,12 @@ public class SkeletonUtilityInspector : Editor {
 #else
 		}
 		EditorGUILayout.EndFadeGroup();
-		if(showSlots.isAnimating)
+		if (showSlots.isAnimating)
 			Repaint();
 #endif
 	}
 
-	void SpawnHierarchyContextMenu(){
+	void SpawnHierarchyContextMenu () {
 		GenericMenu menu = new GenericMenu();
 
 		menu.AddItem(new GUIContent("Follow"), false, SpawnFollowHierarchy);
@@ -294,23 +289,23 @@ public class SkeletonUtilityInspector : Editor {
 		menu.ShowAsContext();
 	}
 
-	void SpawnFollowHierarchy(){
-		Selection.activeGameObject = skeletonUtility.SpawnHierarchy( SkeletonUtilityBone.Mode.Follow, true, true, true );
-		AttachIconsToChildren( skeletonUtility.boneRoot );
+	void SpawnFollowHierarchy () {
+		Selection.activeGameObject = skeletonUtility.SpawnHierarchy(SkeletonUtilityBone.Mode.Follow, true, true, true);
+		AttachIconsToChildren(skeletonUtility.boneRoot);
 	}
 
-	void SpawnFollowHierarchyRootOnly(){
-		Selection.activeGameObject = skeletonUtility.SpawnRoot( SkeletonUtilityBone.Mode.Follow, true, true, true );
-		AttachIconsToChildren( skeletonUtility.boneRoot );
+	void SpawnFollowHierarchyRootOnly () {
+		Selection.activeGameObject = skeletonUtility.SpawnRoot(SkeletonUtilityBone.Mode.Follow, true, true, true);
+		AttachIconsToChildren(skeletonUtility.boneRoot);
 	}
 
-	void SpawnOverrideHierarchy(){
-		Selection.activeGameObject = skeletonUtility.SpawnHierarchy( SkeletonUtilityBone.Mode.Override, true, true, true );
-		AttachIconsToChildren( skeletonUtility.boneRoot );
+	void SpawnOverrideHierarchy () {
+		Selection.activeGameObject = skeletonUtility.SpawnHierarchy(SkeletonUtilityBone.Mode.Override, true, true, true);
+		AttachIconsToChildren(skeletonUtility.boneRoot);
 	}
 	
-	void SpawnOverrideHierarchyRootOnly(){
-		Selection.activeGameObject = skeletonUtility.SpawnRoot( SkeletonUtilityBone.Mode.Override, true, true, true );
-		AttachIconsToChildren( skeletonUtility.boneRoot );
+	void SpawnOverrideHierarchyRootOnly () {
+		Selection.activeGameObject = skeletonUtility.SpawnRoot(SkeletonUtilityBone.Mode.Override, true, true, true);
+		AttachIconsToChildren(skeletonUtility.boneRoot);
 	}
 }

+ 63 - 69
spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtility.cs

@@ -42,7 +42,7 @@ using Spine;
 [ExecuteInEditMode]
 public class SkeletonUtility : MonoBehaviour {
 
-	public static T GetInParent<T>(Transform origin) where T : Component{
+	public static T GetInParent<T> (Transform origin) where T : Component {
 #if UNITY_4_3
 		Transform parent = origin.parent;
 		while(parent.GetComponent<T>() == null){
@@ -58,18 +58,19 @@ public class SkeletonUtility : MonoBehaviour {
 	}
 
 
-	public delegate void SkeletonUtilityDelegate();
+	public delegate void SkeletonUtilityDelegate ();
+
 	public event SkeletonUtilityDelegate OnReset;
 
 	public Transform boneRoot;
 
-	void Update(){
-		if(boneRoot != null && skeletonRenderer.skeleton != null){
+	void Update () {
+		if (boneRoot != null && skeletonRenderer.skeleton != null) {
 			Vector3 flipScale = Vector3.one;
-			if(skeletonRenderer.skeleton.FlipX)
+			if (skeletonRenderer.skeleton.FlipX)
 				flipScale.x = -1;
 
-			if(skeletonRenderer.skeleton.FlipY)
+			if (skeletonRenderer.skeleton.FlipY)
 				flipScale.y = -1;
 
 			boneRoot.localScale = flipScale;
@@ -78,35 +79,31 @@ public class SkeletonUtility : MonoBehaviour {
 
 	[HideInInspector]
 	public SkeletonRenderer skeletonRenderer;
-
 	[HideInInspector]
 	public SkeletonAnimation skeletonAnimation;
-
 	[System.NonSerialized]
 	public List<SkeletonUtilityBone> utilityBones = new List<SkeletonUtilityBone>();
-
 	[System.NonSerialized]
 	public List<SkeletonUtilityConstraint> utilityConstraints = new List<SkeletonUtilityConstraint>();
 //	Dictionary<Bone, SkeletonUtilityBone> utilityBoneTable;
 
-
 	protected bool hasTransformBones;
 	protected bool hasUtilityConstraints;
 	protected bool needToReprocessBones;
 
-	void OnEnable(){
-		if(skeletonRenderer == null){
+	void OnEnable () {
+		if (skeletonRenderer == null) {
 			skeletonRenderer = GetComponent<SkeletonRenderer>();
 		}
 
-		if(skeletonAnimation == null){
+		if (skeletonAnimation == null) {
 			skeletonAnimation = GetComponent<SkeletonAnimation>();
 		}
 
 		skeletonRenderer.OnReset -= HandleRendererReset;
 		skeletonRenderer.OnReset += HandleRendererReset;
 
-		if(skeletonAnimation != null){
+		if (skeletonAnimation != null) {
 			skeletonAnimation.UpdateLocal -= UpdateLocal;
 			skeletonAnimation.UpdateLocal += UpdateLocal;
 		}
@@ -115,147 +112,144 @@ public class SkeletonUtility : MonoBehaviour {
 		CollectBones();
 	}
 
-	void Start(){
+	void Start () {
 		//recollect because order of operations failure when switching between game mode and edit mode...
 //		CollectBones();
 	}
 
-
-
-	void OnDisable(){
+	void OnDisable () {
 		skeletonRenderer.OnReset -= HandleRendererReset;
 
-		if(skeletonAnimation != null){
+		if (skeletonAnimation != null) {
 			skeletonAnimation.UpdateLocal -= UpdateLocal;
 			skeletonAnimation.UpdateWorld -= UpdateWorld;
 			skeletonAnimation.UpdateComplete -= UpdateComplete;
 		}
 	}
 	
-	void HandleRendererReset(SkeletonRenderer r){
-		if(OnReset != null)
+	void HandleRendererReset (SkeletonRenderer r) {
+		if (OnReset != null)
 			OnReset();
 
 		CollectBones();
 	}
 
-	public void RegisterBone(SkeletonUtilityBone bone){
-		if(utilityBones.Contains(bone))
+	public void RegisterBone (SkeletonUtilityBone bone) {
+		if (utilityBones.Contains(bone))
 			return;
-		else{
+		else {
 			utilityBones.Add(bone);
 			needToReprocessBones = true;
 		}
 	}
 
-	public void UnregisterBone(SkeletonUtilityBone bone){
+	public void UnregisterBone (SkeletonUtilityBone bone) {
 		utilityBones.Remove(bone);
 	}
 
-	public void RegisterConstraint(SkeletonUtilityConstraint constraint){
+	public void RegisterConstraint (SkeletonUtilityConstraint constraint) {
 
-		if(utilityConstraints.Contains(constraint))
+		if (utilityConstraints.Contains(constraint))
 			return;
-		else{
+		else {
 			utilityConstraints.Add(constraint);
 			needToReprocessBones = true;
 		}
 	}
 	
-	public void UnregisterConstraint(SkeletonUtilityConstraint constraint){
+	public void UnregisterConstraint (SkeletonUtilityConstraint constraint) {
 		utilityConstraints.Remove(constraint);
 	}
 
-	public void CollectBones(){
-		if(skeletonRenderer.skeleton == null)
+	public void CollectBones () {
+		if (skeletonRenderer.skeleton == null)
 			return;
 
-		if(boneRoot != null){
+		if (boneRoot != null) {
 			List<string> constraintTargetNames = new List<string>();
 
-			foreach(IkConstraint c in skeletonRenderer.skeleton.IkConstraints){
+			foreach (IkConstraint c in skeletonRenderer.skeleton.IkConstraints) {
 				constraintTargetNames.Add(c.Target.Data.Name);
 			}
 
-			foreach(var b in utilityBones){
-				if(b.bone == null){
+			foreach (var b in utilityBones) {
+				if (b.bone == null) {
 					return;
 				}
-				if(b.mode == SkeletonUtilityBone.Mode.Override){
+				if (b.mode == SkeletonUtilityBone.Mode.Override) {
 					hasTransformBones = true;
 				}
 
-				if(constraintTargetNames.Contains( b.bone.Data.Name )){
+				if (constraintTargetNames.Contains(b.bone.Data.Name)) {
 					hasUtilityConstraints = true;
 				}
 			}
 
-			if(utilityConstraints.Count > 0)
+			if (utilityConstraints.Count > 0)
 				hasUtilityConstraints = true;
 
-			if(skeletonAnimation != null){
+			if (skeletonAnimation != null) {
 				skeletonAnimation.UpdateWorld -= UpdateWorld;
 				skeletonAnimation.UpdateComplete -= UpdateComplete;
 
-				if(hasTransformBones || hasUtilityConstraints){
+				if (hasTransformBones || hasUtilityConstraints) {
 					skeletonAnimation.UpdateWorld += UpdateWorld;
 				}
 
-				if(hasUtilityConstraints){
+				if (hasUtilityConstraints) {
 					skeletonAnimation.UpdateComplete += UpdateComplete;
 				}
 			}
 
 			needToReprocessBones = false;
-		}
-		else{
+		} else {
 			utilityBones.Clear();
 			utilityConstraints.Clear();
 		}
 
 	}
 
-	void UpdateLocal(SkeletonAnimation anim){
+	void UpdateLocal (SkeletonAnimation anim) {
 
-		if(needToReprocessBones)
+		if (needToReprocessBones)
 			CollectBones();
 
-		if(utilityBones == null)
+		if (utilityBones == null)
 			return;
 
-		foreach(SkeletonUtilityBone b in utilityBones){
+		foreach (SkeletonUtilityBone b in utilityBones) {
 			b.transformLerpComplete = false;
 		}
 
 		UpdateAllBones();
 	}
 
-	void UpdateWorld(SkeletonAnimation anim){
+	void UpdateWorld (SkeletonAnimation anim) {
 		UpdateAllBones();
 
-		foreach(SkeletonUtilityConstraint c in utilityConstraints)
+		foreach (SkeletonUtilityConstraint c in utilityConstraints)
 			c.DoUpdate();
 	}
 
-	void UpdateComplete(SkeletonAnimation anim){
+	void UpdateComplete (SkeletonAnimation anim) {
 		UpdateAllBones();
 	}
 
-	void UpdateAllBones(){
-		if(boneRoot == null){
+	void UpdateAllBones () {
+		if (boneRoot == null) {
 			CollectBones();
 		}
 
-		if(utilityBones == null)
+		if (utilityBones == null)
 			return;
 
-		foreach(SkeletonUtilityBone b in utilityBones){
+		foreach (SkeletonUtilityBone b in utilityBones) {
 			b.DoUpdate();
 		}
 	}
 
-	public Transform GetBoneRoot(){
-		if(boneRoot != null)
+	public Transform GetBoneRoot () {
+		if (boneRoot != null)
 			return boneRoot;
 
 		boneRoot = new GameObject("SkeletonUtility-Root").transform;
@@ -267,18 +261,18 @@ public class SkeletonUtility : MonoBehaviour {
 		return boneRoot;
 	}
 
-	public GameObject SpawnRoot(SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca){
+	public GameObject SpawnRoot (SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca) {
 		GetBoneRoot();
 		Skeleton skeleton = this.skeletonRenderer.skeleton;
 
-		GameObject go = SpawnBone( skeleton.RootBone, boneRoot, mode, pos, rot, sca );
+		GameObject go = SpawnBone(skeleton.RootBone, boneRoot, mode, pos, rot, sca);
 
 		CollectBones();
 
 		return go;
 	}
 
-	public GameObject SpawnHierarchy(SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca){
+	public GameObject SpawnHierarchy (SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca) {
 		GetBoneRoot();
 
 		Skeleton skeleton = this.skeletonRenderer.skeleton;
@@ -290,17 +284,17 @@ public class SkeletonUtility : MonoBehaviour {
 		return go;
 	}
 
-	public GameObject SpawnBoneRecursively(Bone bone, Transform parent, SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca){
+	public GameObject SpawnBoneRecursively (Bone bone, Transform parent, SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca) {
 		GameObject go = SpawnBone(bone, parent, mode, pos, rot, sca);
 
-		foreach(Bone child in bone.Children){
+		foreach (Bone child in bone.Children) {
 			SpawnBoneRecursively(child, go.transform, mode, pos, rot, sca);
 		}
 
 		return go;
 	}
 	
-	public GameObject SpawnBone(Bone bone, Transform parent, SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca){
+	public GameObject SpawnBone (Bone bone, Transform parent, SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca) {
 		GameObject go = new GameObject(bone.Data.Name);
 		go.transform.parent = parent;
 		
@@ -316,11 +310,11 @@ public class SkeletonUtility : MonoBehaviour {
 		b.boneName = bone.Data.Name;
 		b.valid = true;
 
-		if(mode == SkeletonUtilityBone.Mode.Override){
-			if(rot)
+		if (mode == SkeletonUtilityBone.Mode.Override) {
+			if (rot)
 				go.transform.localRotation = Quaternion.Euler(0, 0, b.bone.RotationIK);
 			
-			if(pos)
+			if (pos)
 				go.transform.localPosition = new Vector3(b.bone.X, b.bone.Y, 0);
 			
 			go.transform.localScale = new Vector3(b.bone.scaleX, b.bone.scaleY, 0);
@@ -329,10 +323,10 @@ public class SkeletonUtility : MonoBehaviour {
 		return go;
 	}
 	
-	public void SpawnSubRenderers(bool disablePrimaryRenderer){
+	public void SpawnSubRenderers (bool disablePrimaryRenderer) {
 		int submeshCount = GetComponent<MeshFilter>().sharedMesh.subMeshCount;
 
-		for(int i = 0; i < submeshCount; i++){
+		for (int i = 0; i < submeshCount; i++) {
 			GameObject go = new GameObject("Submesh " + i, typeof(MeshFilter), typeof(MeshRenderer));
 			go.transform.parent = transform;
 			go.transform.localPosition = Vector3.zero;
@@ -342,11 +336,11 @@ public class SkeletonUtility : MonoBehaviour {
 			SkeletonUtilitySubmeshRenderer s = go.AddComponent<SkeletonUtilitySubmeshRenderer>();
 			s.sortingOrder = i * 10;
 			s.submeshIndex = i;
-			s.Initialize( renderer );
+			s.Initialize(renderer);
 			s.Update();
 		}
 
-		if(disablePrimaryRenderer)
+		if (disablePrimaryRenderer)
 			renderer.enabled = false;
 	}
 }

+ 133 - 153
spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilityBone.cs

@@ -44,52 +44,49 @@ using Spine;
 [AddComponentMenu("Spine/SkeletonUtilityBone")]
 public class SkeletonUtilityBone : MonoBehaviour {
 
-	public enum Mode { Follow, Override }
+	public enum Mode {
+		Follow,
+		Override
+	}
 
 	[System.NonSerialized]
 	public bool valid;
-
 	[System.NonSerialized]
 	public SkeletonUtility skeletonUtility;
-
 	[System.NonSerialized]
 	public Bone bone;
-
 	public Mode mode;
-	
 	public bool zPosition = true;
 	public bool position;
 	public bool rotation;
 	public bool scale;
-    public bool flip;
-    public bool flipX;
-
+	public bool flip;
+	public bool flipX;
 	[Range(0f,1f)]
 	public float overrideAlpha = 1;
 
 	/// <summary>If a bone isn't set, boneName is used to find the bone.</summary>
 	public String boneName;
-
 	public Transform parentReference;
-
 	[HideInInspector]
 	public bool transformLerpComplete;
-
 	protected Transform cachedTransform;
 	protected Transform skeletonTransform;
 
-	public bool NonUniformScaleWarning{
-		get{
+	public bool NonUniformScaleWarning {
+		get {
 			return nonUniformScaleWarning;
 		}
 	}
+
 	private bool nonUniformScaleWarning;
 
 	public void Reset () {
 		bone = null;
 		cachedTransform = transform;
 		valid = skeletonUtility != null && skeletonUtility.skeletonRenderer != null && skeletonUtility.skeletonRenderer.valid;
-		if (!valid) return;
+		if (!valid)
+			return;
 		skeletonTransform = skeletonUtility.transform;
 
 		skeletonUtility.OnReset -= HandleOnReset;
@@ -98,10 +95,10 @@ public class SkeletonUtilityBone : MonoBehaviour {
 		DoUpdate();
 	}
 
-	void OnEnable(){
+	void OnEnable () {
 		skeletonUtility = SkeletonUtility.GetInParent<SkeletonUtility>(transform);
 
-		if(skeletonUtility == null)
+		if (skeletonUtility == null)
 			return;
 
 		skeletonUtility.RegisterBone(this);
@@ -109,13 +106,12 @@ public class SkeletonUtilityBone : MonoBehaviour {
 		skeletonUtility.OnReset += HandleOnReset;
 	}
 
-	void HandleOnReset ()
-	{
-		Reset ();
+	void HandleOnReset () {
+		Reset();
 	}
 
-	void OnDisable(){
-		if(skeletonUtility != null){
+	void OnDisable () {
+		if (skeletonUtility != null) {
 			skeletonUtility.OnReset -= HandleOnReset;
 
 			skeletonUtility.UnregisterBone(this);
@@ -132,7 +128,8 @@ public class SkeletonUtilityBone : MonoBehaviour {
 		Spine.Skeleton skeleton = skeletonUtility.skeletonRenderer.skeleton;
 
 		if (bone == null) {
-			if (boneName == null || boneName.Length == 0) return;
+			if (boneName == null || boneName.Length == 0)
+				return;
 			bone = skeleton.FindBone(boneName);
 			if (bone == null) {
 				Debug.LogError("Bone not found: " + boneName, this);
@@ -144,170 +141,153 @@ public class SkeletonUtilityBone : MonoBehaviour {
 
 		float skeletonFlipRotation = (skeleton.flipX ^ skeleton.flipY) ? -1f : 1f;
         
-        float flipCompensation = 0;
-        if (flip && (flipX || ( flipX != bone.flipX)) && bone.parent != null)
-        {
-            flipCompensation = bone.parent.WorldRotation * -2;
-        }
+		float flipCompensation = 0;
+		if (flip && (flipX || (flipX != bone.flipX)) && bone.parent != null) {
+			flipCompensation = bone.parent.WorldRotation * -2;
+		}
 
-		if(mode == Mode.Follow){
-            if (flip)
-            {
-                flipX = bone.flipX;
-            }
+		if (mode == Mode.Follow) {
+			if (flip) {
+				flipX = bone.flipX;
+			}
 
 
-			if(position){
+			if (position) {
 				cachedTransform.localPosition = new Vector3(bone.x, bone.y, 0);
 			}
 
-			if(rotation){
+			if (rotation) {
 
-				if(bone.Data.InheritRotation){
-                    if (bone.FlipX)
-                    {
-                        cachedTransform.localRotation = Quaternion.Euler(0, 180, bone.rotationIK - flipCompensation);
-                    }
-                    else { 
-					    cachedTransform.localRotation = Quaternion.Euler(0,0,bone.rotationIK);
-                    }
-				}
-				else{
+				if (bone.Data.InheritRotation) {
+					if (bone.FlipX) {
+						cachedTransform.localRotation = Quaternion.Euler(0, 180, bone.rotationIK - flipCompensation);
+					} else { 
+						cachedTransform.localRotation = Quaternion.Euler(0, 0, bone.rotationIK);
+					}
+				} else {
 					Vector3 euler = skeletonTransform.rotation.eulerAngles;
-					cachedTransform.rotation = Quaternion.Euler(euler.x, euler.y, skeletonTransform.rotation.eulerAngles.z + (bone.worldRotation * skeletonFlipRotation) );
+					cachedTransform.rotation = Quaternion.Euler(euler.x, euler.y, skeletonTransform.rotation.eulerAngles.z + (bone.worldRotation * skeletonFlipRotation));
 				}
 
 			}
 
-			if(scale){
+			if (scale) {
 				cachedTransform.localScale = new Vector3(bone.scaleX, bone.scaleY, 1);
 
 				nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
 			}
 
-		}
-		else if(mode == Mode.Override){
+		} else if (mode == Mode.Override) {
 
 
 
-			if(transformLerpComplete)
-				return;            
+				if (transformLerpComplete)
+					return;            
 
-			if(parentReference == null){
-				if(position){
-					bone.x = Mathf.Lerp(bone.x, cachedTransform.localPosition.x, overrideAlpha);
-					bone.y = Mathf.Lerp(bone.y, cachedTransform.localPosition.y, overrideAlpha);
-				}
+				if (parentReference == null) {
+					if (position) {
+						bone.x = Mathf.Lerp(bone.x, cachedTransform.localPosition.x, overrideAlpha);
+						bone.y = Mathf.Lerp(bone.y, cachedTransform.localPosition.y, overrideAlpha);
+					}
 
-				if(rotation){
-                    float angle = Mathf.LerpAngle(bone.Rotation, cachedTransform.localRotation.eulerAngles.z, overrideAlpha) + flipCompensation;
+					if (rotation) {
+						float angle = Mathf.LerpAngle(bone.Rotation, cachedTransform.localRotation.eulerAngles.z, overrideAlpha) + flipCompensation;
 
-                    if (flip) { 
-                        if ((!flipX && bone.flipX))
-                        {
-                            angle -= flipCompensation;
-                        }
+						if (flip) { 
+							if ((!flipX && bone.flipX)) {
+								angle -= flipCompensation;
+							}
                         
-                        //TODO fix this...
-                        if (angle >= 360)
-                            angle -= 360;
-                        else if (angle <= -360)
-                            angle += 360;
-                    }
-
-                    bone.Rotation = angle;
-                }
+							//TODO fix this...
+							if (angle >= 360)
+								angle -= 360;
+							else if (angle <= -360)
+									angle += 360;
+						}
+
+						bone.Rotation = angle;
+					}
+
+					if (scale) {
+						bone.scaleX = Mathf.Lerp(bone.scaleX, cachedTransform.localScale.x, overrideAlpha);
+						bone.scaleY = Mathf.Lerp(bone.scaleY, cachedTransform.localScale.y, overrideAlpha);
+
+						nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
+					}
+
+					if (flip) {
+						bone.flipX = flipX;
+					}
+				} else {
+
+					if (transformLerpComplete)
+						return; 
+
+					if (position) {
+						Vector3 pos = parentReference.InverseTransformPoint(cachedTransform.position);
+						bone.x = Mathf.Lerp(bone.x, pos.x, overrideAlpha);
+						bone.y = Mathf.Lerp(bone.y, pos.y, overrideAlpha);
+					}
+				
+					if (rotation) {
+						float angle = Mathf.LerpAngle(bone.Rotation, Quaternion.LookRotation(flipX ? Vector3.forward * -1 : Vector3.forward, parentReference.InverseTransformDirection(cachedTransform.up)).eulerAngles.z, overrideAlpha) + flipCompensation;
+
+						if (flip) {
+							if ((!flipX && bone.flipX)) {
+								angle -= flipCompensation;
+							}
+
+							//TODO fix this...
+							if (angle >= 360)
+								angle -= 360;
+							else if (angle <= -360)
+									angle += 360;
+						}
+
+						bone.Rotation = angle;
+					}
+
+					//TODO: Something about this
+					if (scale) {
+						bone.scaleX = Mathf.Lerp(bone.scaleX, cachedTransform.localScale.x, overrideAlpha);
+						bone.scaleY = Mathf.Lerp(bone.scaleY, cachedTransform.localScale.y, overrideAlpha);
+					
+						nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
+					}
 
-				if(scale){
-					bone.scaleX = Mathf.Lerp(bone.scaleX, cachedTransform.localScale.x, overrideAlpha);
-					bone.scaleY = Mathf.Lerp(bone.scaleY, cachedTransform.localScale.y, overrideAlpha);
+					if (flip) {
+						bone.flipX = flipX;
+					}
 
-					nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
 				}
 
-                if (flip)
-                {
-                    bone.flipX = flipX;
-                }
-			}
-			else{
-
-                if (transformLerpComplete)
-                    return; 
-
-				if(position){
-					Vector3 pos = parentReference.InverseTransformPoint(cachedTransform.position);
-					bone.x = Mathf.Lerp(bone.x, pos.x, overrideAlpha);
-					bone.y = Mathf.Lerp(bone.y, pos.y, overrideAlpha);
-				}
-				
-				if(rotation){
-                    float angle = Mathf.LerpAngle(bone.Rotation, Quaternion.LookRotation(flipX ? Vector3.forward * -1 : Vector3.forward, parentReference.InverseTransformDirection(cachedTransform.up)).eulerAngles.z, overrideAlpha) + flipCompensation;
-
-                    if (flip)
-                    {
-                        if ((!flipX && bone.flipX))
-                        {
-                            angle -= flipCompensation;
-                        }
-
-                        //TODO fix this...
-                        if (angle >= 360)
-                            angle -= 360;
-                        else if (angle <= -360)
-                            angle += 360;
-                    }
-
-                    bone.Rotation = angle;
-				}
+				transformLerpComplete = true;
+			}		
+	}
 
-				//TODO: Something about this
-				if(scale){
-                    bone.scaleX = Mathf.Lerp(bone.scaleX, cachedTransform.localScale.x, overrideAlpha);
-                    bone.scaleY = Mathf.Lerp(bone.scaleY, cachedTransform.localScale.y, overrideAlpha);
-					
-					nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
+	public void FlipX (bool state) {
+		if (state != flipX) {
+			flipX = state;
+			if (flipX && Mathf.Abs(transform.localRotation.eulerAngles.y) > 90) {
+				skeletonUtility.skeletonAnimation.LateUpdate();
+				return;
+			} else if (!flipX && Mathf.Abs(transform.localRotation.eulerAngles.y) < 90) {
+					skeletonUtility.skeletonAnimation.LateUpdate();
+					return;
 				}
+		}
 
-                if (flip)
-                {
-                    bone.flipX = flipX;
-                }
-
-			}
-
-			transformLerpComplete = true;
-		}		
+		bone.FlipX = state;
+		transform.RotateAround(transform.position, skeletonUtility.transform.up, 180);
+		Vector3 euler = transform.localRotation.eulerAngles;
+		euler.x = 0;
+		euler.y = bone.FlipX ? 180 : 0;
+		transform.localRotation = Quaternion.Euler(euler);
 	}
 
-    public void FlipX(bool state)
-    {
-        if (state != flipX)
-        {
-            flipX = state;
-            if (flipX && Mathf.Abs(transform.localRotation.eulerAngles.y) > 90)
-            {
-                skeletonUtility.skeletonAnimation.LateUpdate();
-                return;
-            }
-            else if (!flipX && Mathf.Abs(transform.localRotation.eulerAngles.y) < 90)
-            {
-                skeletonUtility.skeletonAnimation.LateUpdate();
-                return;
-            }
-        }
-
-        bone.FlipX = state;
-        transform.RotateAround(transform.position, skeletonUtility.transform.up, 180);
-        Vector3 euler = transform.localRotation.eulerAngles;
-        euler.x = 0;
-        euler.y = bone.FlipX ? 180 : 0;
-        transform.localRotation = Quaternion.Euler(euler);
-    }
-
-	void OnDrawGizmos(){
-		if(NonUniformScaleWarning){
-			Gizmos.DrawIcon(transform.position + new Vector3(0,0.128f,0), "icon-warning");
+	void OnDrawGizmos () {
+		if (NonUniformScaleWarning) {
+			Gizmos.DrawIcon(transform.position + new Vector3(0, 0.128f, 0), "icon-warning");
 		}
 	}
 }

+ 3 - 3
spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilityConstraint.cs

@@ -8,15 +8,15 @@ public abstract class SkeletonUtilityConstraint : MonoBehaviour {
 	protected SkeletonUtilityBone utilBone;
 	protected SkeletonUtility skeletonUtility;
 
-	protected virtual void OnEnable(){
+	protected virtual void OnEnable () {
 		utilBone = GetComponent<SkeletonUtilityBone>();
 		skeletonUtility = SkeletonUtility.GetInParent<SkeletonUtility>(transform);
 		skeletonUtility.RegisterConstraint(this);
 	}
 
-	protected virtual void OnDisable(){
+	protected virtual void OnDisable () {
 		skeletonUtility.UnregisterConstraint(this);
 	}
 
-	public abstract void DoUpdate();
+	public abstract void DoUpdate ();
 }

+ 13 - 18
spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilityEyeConstraint.cs

@@ -7,41 +7,36 @@ public class SkeletonUtilityEyeConstraint : SkeletonUtilityConstraint {
 	public float radius = 0.5f;
 	public Transform target;
 	public Vector3 targetPosition;
-
 	public float speed = 10;
-	
 	Vector3[] origins;
 	Vector3 centerPoint;
 	
-	protected override void OnEnable ()
-	{
-		if(!Application.isPlaying)
+	protected override void OnEnable () {
+		if (!Application.isPlaying)
 			return;
 
-		base.OnEnable ();
+		base.OnEnable();
 
-		Bounds centerBounds = new Bounds( eyes[0].localPosition, Vector3.zero );
+		Bounds centerBounds = new Bounds(eyes[0].localPosition, Vector3.zero);
 		origins = new Vector3[eyes.Length];
-		for(int i = 0; i < eyes.Length; i++){
+		for (int i = 0; i < eyes.Length; i++) {
 			origins[i] = eyes[i].localPosition;
-			centerBounds.Encapsulate( origins[i] );
+			centerBounds.Encapsulate(origins[i]);
 		}
 
 		centerPoint = centerBounds.center;
 	}
 	
-	protected override void OnDisable ()
-	{
-		if(!Application.isPlaying)
+	protected override void OnDisable () {
+		if (!Application.isPlaying)
 			return;
 
-		base.OnDisable ();
+		base.OnDisable();
 	}
 	
-	public override void DoUpdate ()
-	{
+	public override void DoUpdate () {
 
-		if(target != null)
+		if (target != null)
 			targetPosition = target.position;
 
 		Vector3 goal = targetPosition;
@@ -49,10 +44,10 @@ public class SkeletonUtilityEyeConstraint : SkeletonUtilityConstraint {
 		Vector3 center = transform.TransformPoint(centerPoint);
 		Vector3 dir = goal - center;
 
-		if(dir.magnitude > 1) 
+		if (dir.magnitude > 1) 
 			dir.Normalize();
 
-		for(int i = 0; i < eyes.Length; i++){
+		for (int i = 0; i < eyes.Length; i++) {
 			center = transform.TransformPoint(origins[i]);
 			eyes[i].position = Vector3.MoveTowards(eyes[i].position, center + (dir * radius), speed * Time.deltaTime);
 		}

+ 31 - 42
spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilityGroundConstraint.cs

@@ -34,71 +34,63 @@ public class SkeletonUtilityGroundConstraint : SkeletonUtilityConstraint {
 
 
 	Vector3 rayOrigin;
-	Vector3 rayDir = new Vector3(0,-1,0);
+	Vector3 rayDir = new Vector3(0, -1, 0);
 	float hitY;
 	float lastHitY;
 
-	protected override void OnEnable ()
-	{
-		base.OnEnable ();
+	protected override void OnEnable () {
+		base.OnEnable();
 	}
 
-	protected override void OnDisable ()
-	{
-		base.OnDisable ();
+	protected override void OnDisable () {
+		base.OnDisable();
 	}
 
-	public override void DoUpdate()
-	{
-		rayOrigin = transform.position + new Vector3(castOffset,castDistance,0);
+	public override void DoUpdate () {
+		rayOrigin = transform.position + new Vector3(castOffset, castDistance, 0);
 
 		hitY = float.MinValue;
-		if(use2D){
+		if (use2D) {
 			RaycastHit2D hit;
 
-			if(useRadius){
+			if (useRadius) {
 #if UNITY_4_3
 				//NOTE:  Unity 4.3.x does not have CircleCast
 				hit = Physics2D.Raycast(rayOrigin , rayDir, castDistance + groundOffset, groundMask);
 #else
-				hit = Physics2D.CircleCast( rayOrigin, castRadius, rayDir, castDistance + groundOffset, groundMask );
+				hit = Physics2D.CircleCast(rayOrigin, castRadius, rayDir, castDistance + groundOffset, groundMask);
 #endif
-			}
-			else{
-				hit = Physics2D.Raycast(rayOrigin , rayDir, castDistance + groundOffset, groundMask);
+			} else {
+				hit = Physics2D.Raycast(rayOrigin, rayDir, castDistance + groundOffset, groundMask);
 			}
 
-			if(hit.collider != null){
+			if (hit.collider != null) {
 				hitY = hit.point.y + groundOffset;
-				if(Application.isPlaying){
-					hitY = Mathf.MoveTowards( lastHitY, hitY, adjustSpeed * Time.deltaTime );
+				if (Application.isPlaying) {
+					hitY = Mathf.MoveTowards(lastHitY, hitY, adjustSpeed * Time.deltaTime);
 				}
+			} else {
+				if (Application.isPlaying)
+					hitY = Mathf.MoveTowards(lastHitY, transform.position.y, adjustSpeed * Time.deltaTime);
 			}
-			else{
-				if(Application.isPlaying)
-					hitY = Mathf.MoveTowards( lastHitY, transform.position.y, adjustSpeed * Time.deltaTime );
-			}
-		}
-		else{
+		} else {
 			RaycastHit hit;
 			bool validHit = false;
 
-			if(useRadius){
-				validHit = Physics.SphereCast( rayOrigin, castRadius, rayDir, out hit, castDistance + groundOffset, groundMask );
-			}
-			else{
-				validHit = Physics.Raycast( rayOrigin, rayDir, out hit, castDistance + groundOffset, groundMask);
+			if (useRadius) {
+				validHit = Physics.SphereCast(rayOrigin, castRadius, rayDir, out hit, castDistance + groundOffset, groundMask);
+			} else {
+				validHit = Physics.Raycast(rayOrigin, rayDir, out hit, castDistance + groundOffset, groundMask);
 			}
 
-			if(validHit){
+			if (validHit) {
 				hitY = hit.point.y + groundOffset;
-				if(Application.isPlaying){
-					hitY = Mathf.MoveTowards( lastHitY, hitY, adjustSpeed * Time.deltaTime );
+				if (Application.isPlaying) {
+					hitY = Mathf.MoveTowards(lastHitY, hitY, adjustSpeed * Time.deltaTime);
 				}
-			}
-			else{
-				if(Application.isPlaying)
-					hitY = Mathf.MoveTowards( lastHitY, transform.position.y, adjustSpeed * Time.deltaTime );
+			} else {
+				if (Application.isPlaying)
+					hitY = Mathf.MoveTowards(lastHitY, transform.position.y, adjustSpeed * Time.deltaTime);
 			}
 		}
 
@@ -110,21 +102,18 @@ public class SkeletonUtilityGroundConstraint : SkeletonUtilityConstraint {
 		utilBone.bone.Y = transform.localPosition.y;
 
 		lastHitY = hitY;
-
 	}
 
-	void OnDrawGizmos(){
+	void OnDrawGizmos () {
 		Vector3 hitEnd = rayOrigin + (rayDir * Mathf.Min(castDistance, rayOrigin.y - hitY));
 		Vector3 clearEnd = rayOrigin + (rayDir * castDistance);
 		Gizmos.DrawLine(rayOrigin, hitEnd);
 
-		if(useRadius){
+		if (useRadius) {
 			Gizmos.DrawLine(new Vector3(hitEnd.x - castRadius, hitEnd.y - groundOffset, hitEnd.z), new Vector3(hitEnd.x + castRadius, hitEnd.y - groundOffset, hitEnd.z));
 			Gizmos.DrawLine(new Vector3(clearEnd.x - castRadius, clearEnd.y, clearEnd.z), new Vector3(clearEnd.x + castRadius, clearEnd.y, clearEnd.z));
 		}
 
-
-
 		Gizmos.color = Color.red;
 		Gizmos.DrawLine(hitEnd, clearEnd);
 	}

+ 17 - 19
spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilityKinematicShadow.cs

@@ -3,15 +3,13 @@ using System.Collections;
 using System.Collections.Generic;
 
 public class SkeletonUtilityKinematicShadow : MonoBehaviour {
-
 	public bool hideShadow = true;
-
 	Dictionary<Transform, Transform> shadowTable;
 	GameObject shadowRoot;
 
-	void Start(){
+	void Start () {
 		shadowRoot = (GameObject)Instantiate(gameObject);
-		if(hideShadow)
+		if (hideShadow)
 			shadowRoot.hideFlags = HideFlags.HideInHierarchy;
 
 		shadowRoot.transform.parent = transform.root;
@@ -28,20 +26,20 @@ public class SkeletonUtilityKinematicShadow : MonoBehaviour {
 		shadowRoot.transform.localScale = Vector3.one;
 
 		var shadowJoints = shadowRoot.GetComponentsInChildren<Joint>();
-		foreach(Joint j in shadowJoints){
+		foreach (Joint j in shadowJoints) {
 			j.connectedAnchor *= scale;
 		}
 
 		var joints = GetComponentsInChildren<Joint>();
-		foreach(var j in joints)
+		foreach (var j in joints)
 			Destroy(j);
 
 		var rbs = GetComponentsInChildren<Rigidbody>();
-		foreach(var rb in rbs)
+		foreach (var rb in rbs)
 			Destroy(rb);
 
 		var colliders = GetComponentsInChildren<Collider>();
-		foreach(var c in colliders)
+		foreach (var c in colliders)
 			Destroy(c);
 
 
@@ -50,30 +48,30 @@ public class SkeletonUtilityKinematicShadow : MonoBehaviour {
 		var bones = GetComponentsInChildren<SkeletonUtilityBone>();
 
 		//build bone lookup
-		foreach(var b in bones){
-			if(b.gameObject == gameObject)
+		foreach (var b in bones) {
+			if (b.gameObject == gameObject)
 				continue;
 
-			foreach(var sb in shadowBones){
-				if(sb.rigidbody == null)
+			foreach (var sb in shadowBones) {
+				if (sb.rigidbody == null)
 					continue;
 
-				if(sb.boneName == b.boneName){
-					shadowTable.Add( sb.transform, b.transform );
+				if (sb.boneName == b.boneName) {
+					shadowTable.Add(sb.transform, b.transform);
 					break;
 				}
 			}
 		}
 
-		foreach(var b in shadowBones)
+		foreach (var b in shadowBones)
 			Destroy(b);
 	}
 
-	void FixedUpdate(){
-		shadowRoot.rigidbody.MovePosition( transform.position );
-		shadowRoot.rigidbody.MoveRotation( transform.rotation );
+	void FixedUpdate () {
+		shadowRoot.rigidbody.MovePosition(transform.position);
+		shadowRoot.rigidbody.MoveRotation(transform.rotation);
 
-		foreach(var pair in shadowTable){
+		foreach (var pair in shadowTable) {
 			pair.Value.localPosition = pair.Key.localPosition;
 			pair.Value.localRotation = pair.Key.localRotation;
 		}

+ 19 - 25
spine-unity/Assets/spine-unity/SkeletonUtility/SkeletonUtilitySubmeshRenderer.cs

@@ -3,46 +3,42 @@ using System.Collections;
 
 [ExecuteInEditMode]
 public class SkeletonUtilitySubmeshRenderer : MonoBehaviour {
-
 	public Renderer parentRenderer;
-
 	[System.NonSerialized]
 	public Mesh mesh;
-
 	public int submeshIndex = 0;
 	public int sortingOrder = 0;
 	public int sortingLayerID = 0;
-
 	public Material hiddenPassMaterial;
 	Renderer cachedRenderer;
 	MeshFilter filter;
 	Material[] sharedMaterials;
 	MeshFilter parentFilter;
 
-	void Awake(){
+	void Awake () {
 		cachedRenderer = renderer;
 		sharedMaterials = cachedRenderer.sharedMaterials;
 		filter = GetComponent<MeshFilter>();
 
-		if(parentRenderer != null)
-			Initialize( parentRenderer );
+		if (parentRenderer != null)
+			Initialize(parentRenderer);
 	}
 
-	void OnEnable(){
+	void OnEnable () {
 		parentRenderer = transform.parent.GetComponent<Renderer>();
 		parentRenderer.GetComponent<SkeletonRenderer>().OnReset += HandleSkeletonReset;
 	}
 
-	void OnDisable(){
+	void OnDisable () {
 		parentRenderer.GetComponent<SkeletonRenderer>().OnReset -= HandleSkeletonReset;
 	}
 
-	void HandleSkeletonReset(SkeletonRenderer r){
-		if(parentRenderer != null)
+	void HandleSkeletonReset (SkeletonRenderer r) {
+		if (parentRenderer != null)
 			Initialize(parentRenderer);
 	}
 
-	public void Initialize(Renderer parentRenderer){
+	public void Initialize (Renderer parentRenderer) {
 		this.parentRenderer = parentRenderer;
 		parentFilter = parentRenderer.GetComponent<MeshFilter>();
 		mesh = parentFilter.sharedMesh;
@@ -50,52 +46,50 @@ public class SkeletonUtilitySubmeshRenderer : MonoBehaviour {
 		Debug.Log("Mesh: " + mesh);
 	}
 
-	public void Update(){
-		if(mesh == null || mesh != parentFilter.sharedMesh){
+	public void Update () {
+		if (mesh == null || mesh != parentFilter.sharedMesh) {
 			mesh = parentFilter.sharedMesh;
 			filter.sharedMesh = mesh;
 		}
 
-		if(cachedRenderer == null)
+		if (cachedRenderer == null)
 			cachedRenderer = renderer;
 
-		if(mesh == null || submeshIndex > mesh.subMeshCount - 1){
+		if (mesh == null || submeshIndex > mesh.subMeshCount - 1) {
 			cachedRenderer.enabled = false;
 			return;
-		}
-		else{
+		} else {
 			renderer.enabled = true;
 		}
 
 		bool changed = false;
 
-		if(sharedMaterials.Length != parentRenderer.sharedMaterials.Length){
+		if (sharedMaterials.Length != parentRenderer.sharedMaterials.Length) {
 			sharedMaterials = parentRenderer.sharedMaterials;
 			changed = true;
 		}
 
 
 
-		for(int i = 0; i < renderer.sharedMaterials.Length; i++){
-			if(i == submeshIndex)
+		for (int i = 0; i < renderer.sharedMaterials.Length; i++) {
+			if (i == submeshIndex)
 				continue;
 
-			if(sharedMaterials[i] != hiddenPassMaterial){
+			if (sharedMaterials[i] != hiddenPassMaterial) {
 				sharedMaterials[i] = hiddenPassMaterial;
 				changed = true;
 			}
 		}
 
-		if(sharedMaterials[submeshIndex] != parentRenderer.sharedMaterials[submeshIndex]){
+		if (sharedMaterials[submeshIndex] != parentRenderer.sharedMaterials[submeshIndex]) {
 			sharedMaterials[submeshIndex] = parentRenderer.sharedMaterials[submeshIndex];
 			changed = true;
 		}
 
-		if(changed){
+		if (changed) {
 			cachedRenderer.sharedMaterials = sharedMaterials;
 		}
 
-
 		cachedRenderer.sortingLayerID = sortingLayerID;
 		cachedRenderer.sortingOrder = sortingOrder;
 	}

+ 28 - 0
spine-unity/Spine.mdpolicy

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<PolicySet name="Spine">
+  <TextStylePolicy inheritsSet="Mono" inheritsScope="text/plain" scope="text/x-csharp">
+    <FileWidth>130</FileWidth>
+    <TabWidth>3</TabWidth>
+    <IndentWidth>3</IndentWidth>
+  </TextStylePolicy>
+  <CSharpFormattingPolicy inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp">
+    <IndentNamespaceBody>False</IndentNamespaceBody>
+    <AlignEmbeddedUsingStatements>False</AlignEmbeddedUsingStatements>
+    <AlignEmbeddedIfStatements>False</AlignEmbeddedIfStatements>
+    <NamespaceBraceStyle>EndOfLine</NamespaceBraceStyle>
+    <ClassBraceStyle>EndOfLine</ClassBraceStyle>
+    <InterfaceBraceStyle>EndOfLine</InterfaceBraceStyle>
+    <StructBraceStyle>EndOfLine</StructBraceStyle>
+    <EnumBraceStyle>EndOfLine</EnumBraceStyle>
+    <MethodBraceStyle>EndOfLine</MethodBraceStyle>
+    <ConstructorBraceStyle>EndOfLine</ConstructorBraceStyle>
+    <DestructorBraceStyle>EndOfLine</DestructorBraceStyle>
+    <ElseIfNewLinePlacement>SameLine</ElseIfNewLinePlacement>
+    <BeforeMethodCallParentheses>False</BeforeMethodCallParentheses>
+    <AfterDelegateDeclarationParameterComma>True</AfterDelegateDeclarationParameterComma>
+    <NewParentheses>False</NewParentheses>
+    <SpacesBeforeBrackets>False</SpacesBeforeBrackets>
+    <BlankLinesBeforeUsings>1</BlankLinesBeforeUsings>
+    <BlankLinesBeforeFirstDeclaration>1</BlankLinesBeforeFirstDeclaration>
+  </CSharpFormattingPolicy>
+</PolicySet>