Inheritance: UnityEngine.MonoBehaviour
Example #1
0
        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;

            SkeletonUtilityBone b = go.AddComponent <SkeletonUtilityBone>();

            b.skeletonUtility = this;
            b.position        = pos;
            b.rotation        = rot;
            b.scale           = sca;
            b.mode            = mode;
            b.zPosition       = true;
            b.Reset();
            b.bone     = bone;
            b.boneName = bone.Data.Name;
            b.valid    = true;

            if (mode == SkeletonUtilityBone.Mode.Override)
            {
                if (rot)
                {
                    go.transform.localRotation = Quaternion.Euler(0, 0, b.bone.AppliedRotation);
                }

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

            return(go);
        }
Example #2
0
 protected virtual void OnEnable()
 {
     bone      = GetComponent <SkeletonUtilityBone>();
     hierarchy = transform.GetComponentInParent <SkeletonUtility>();
     hierarchy.RegisterConstraint(this);
 }
		protected virtual void OnEnable () {
			utilBone = GetComponent<SkeletonUtilityBone>();
			skeletonUtility = transform.GetComponentInParent<SkeletonUtility>();
			skeletonUtility.RegisterConstraint(this);
		}
Example #4
0
 public void UnregisterBone(SkeletonUtilityBone bone)
 {
     boneComponents.Remove(bone);
 }
Example #5
0
 public void UnregisterBone(SkeletonUtilityBone bone)
 {
     utilityBones.Remove(bone);
 }
 protected virtual void OnEnable()
 {
     utilBone        = GetComponent <SkeletonUtilityBone>();
     skeletonUtility = SkeletonUtility.GetInParent <SkeletonUtility>(transform);
     skeletonUtility.RegisterConstraint(this);
 }
Example #7
0
 public void CollectBones()
 {
     if (this.skeletonRenderer.skeleton == null)
     {
         return;
     }
     if (this.boneRoot != null)
     {
         List <string> list = new List <string>();
         ExposedList <IkConstraint> ikConstraints = this.skeletonRenderer.skeleton.IkConstraints;
         int i     = 0;
         int count = ikConstraints.Count;
         while (i < count)
         {
             list.Add(ikConstraints.Items[i].Target.Data.Name);
             i++;
         }
         List <SkeletonUtilityBone> list2 = this.utilityBones;
         int j      = 0;
         int count2 = list2.Count;
         while (j < count2)
         {
             SkeletonUtilityBone skeletonUtilityBone = list2[j];
             if (skeletonUtilityBone.bone == null)
             {
                 return;
             }
             if (skeletonUtilityBone.mode == SkeletonUtilityBone.Mode.Override)
             {
                 this.hasTransformBones = true;
             }
             if (list.Contains(skeletonUtilityBone.bone.Data.Name))
             {
                 this.hasUtilityConstraints = true;
             }
             j++;
         }
         if (this.utilityConstraints.Count > 0)
         {
             this.hasUtilityConstraints = true;
         }
         if (this.skeletonAnimation != null)
         {
             this.skeletonAnimation.UpdateWorld    -= this.UpdateWorld;
             this.skeletonAnimation.UpdateComplete -= this.UpdateComplete;
             if (this.hasTransformBones || this.hasUtilityConstraints)
             {
                 this.skeletonAnimation.UpdateWorld += this.UpdateWorld;
             }
             if (this.hasUtilityConstraints)
             {
                 this.skeletonAnimation.UpdateComplete += this.UpdateComplete;
             }
         }
         this.needToReprocessBones = false;
     }
     else
     {
         this.utilityBones.Clear();
         this.utilityConstraints.Clear();
     }
 }
		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;

			SkeletonUtilityBone b = go.AddComponent<SkeletonUtilityBone>();
			b.skeletonUtility = this;
			b.position = pos;
			b.rotation = rot;
			b.scale = sca;
			b.mode = mode;
			b.zPosition = true;
			b.Reset();
			b.bone = bone;
			b.boneName = bone.Data.Name;
			b.valid = true;

			if (mode == SkeletonUtilityBone.Mode.Override) {
				if (rot)
					go.transform.localRotation = Quaternion.Euler(0, 0, b.bone.AppliedRotation);

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

			return go;
		}
		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);

			ExposedList<Bone> childrenBones = bone.Children;
			for (int i = 0, n = childrenBones.Count; i < n; i++) {
				Bone child = childrenBones.Items[i];
				SpawnBoneRecursively(child, go.transform, mode, pos, rot, sca);
			}

			return go;
		}
		public GameObject SpawnHierarchy (SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca) {
			GetBoneRoot();
			Skeleton skeleton = this.skeletonRenderer.skeleton;
			GameObject go = SpawnBoneRecursively(skeleton.RootBone, boneRoot, mode, pos, rot, sca);
			CollectBones();
			return go;
		}
		public void UnregisterBone (SkeletonUtilityBone bone) {
			utilityBones.Remove(bone);
		}
		public void RegisterBone (SkeletonUtilityBone bone) {
			if (utilityBones.Contains(bone))
				return;
			else {
				utilityBones.Add(bone);
				needToReprocessBones = true;
			}
		}
        public void CollectBones()
        {
            Skeleton skeleton = this.skeletonRenderer.skeleton;

            if (skeleton != null)
            {
                if (this.boneRoot != null)
                {
                    List <object> list = new List <object>();
                    ExposedList <IkConstraint> ikConstraints = skeleton.IkConstraints;
                    int index = 0;
                    int count = ikConstraints.Count;
                    while (index < count)
                    {
                        list.Add(ikConstraints.Items[index].target);
                        index++;
                    }
                    ExposedList <TransformConstraint> transformConstraints = skeleton.TransformConstraints;
                    int num3 = 0;
                    int num4 = transformConstraints.Count;
                    while (num3 < num4)
                    {
                        list.Add(transformConstraints.Items[num3].target);
                        num3++;
                    }
                    List <SkeletonUtilityBone> utilityBones = this.utilityBones;
                    int num5 = 0;
                    int num6 = utilityBones.Count;
                    while (num5 < num6)
                    {
                        SkeletonUtilityBone bone = utilityBones[num5];
                        if (bone.bone != null)
                        {
                            this.hasTransformBones     |= bone.mode == SkeletonUtilityBone.Mode.Override;
                            this.hasUtilityConstraints |= list.Contains(bone.bone);
                        }
                        num5++;
                    }
                    this.hasUtilityConstraints |= this.utilityConstraints.Count > 0;
                    if (this.skeletonAnimation != null)
                    {
                        this.skeletonAnimation.UpdateWorld    -= new UpdateBonesDelegate(this.UpdateWorld);
                        this.skeletonAnimation.UpdateComplete -= new UpdateBonesDelegate(this.UpdateComplete);
                        if (this.hasTransformBones || this.hasUtilityConstraints)
                        {
                            this.skeletonAnimation.UpdateWorld += new UpdateBonesDelegate(this.UpdateWorld);
                        }
                        if (this.hasUtilityConstraints)
                        {
                            this.skeletonAnimation.UpdateComplete += new UpdateBonesDelegate(this.UpdateComplete);
                        }
                    }
                    this.needToReprocessBones = false;
                }
                else
                {
                    this.utilityBones.Clear();
                    this.utilityConstraints.Clear();
                }
            }
        }
 protected virtual void OnEnable()
 {
     this.utilBone        = base.GetComponent <SkeletonUtilityBone>();
     this.skeletonUtility = base.transform.GetComponentInParent <SkeletonUtility>();
     this.skeletonUtility.RegisterConstraint(this);
 }