Browse Source

[unity] Update SkeletonExtensions.

pharan 8 years ago
parent
commit
4b3710abae
1 changed files with 10 additions and 0 deletions
  1. 10 0
      spine-unity/Assets/spine-unity/SkeletonExtensions.cs

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

@@ -144,6 +144,12 @@ namespace Spine.Unity {
 			return new Quaternion(0, 0, Mathf.Sin(halfRotation), Mathf.Cos(halfRotation));
 		}
 
+		/// <summary>Gets a bone-local space UnityEngine.Quaternion representation of bone.rotation.</summary>
+		public static Quaternion GetLocalQuaternion (this Bone bone) {
+			var halfRotation = bone.rotation * Mathf.Deg2Rad * 0.5f;
+			return new Quaternion(0, 0, Mathf.Sin(halfRotation), Mathf.Cos(halfRotation));
+		}
+
 		/// <summary>Gets the PointAttachment's Unity World position using its Spine GameObject Transform.</summary>
 		public static Vector3 GetWorldPosition (this PointAttachment attachment, Slot slot, Transform spineGameObjectTransform) {
 			Vector3 skeletonSpacePosition;
@@ -288,6 +294,10 @@ namespace Spine {
 			return va.bones != null && va.bones.Length > 0;
 		}
 
+		public static bool IsRenderable (this Attachment a) {
+			return a is RegionAttachment || a is MeshAttachment;
+		}
+
 		#region Transform Modes
 		public static bool InheritsRotation (this TransformMode mode) {
 			const int RotationBit = 0;