Example #1
0
        public GameObject SpawnBone(Bone bone, Transform parent, SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca)
        {
            GameObject gameObject = new GameObject(bone.Data.Name);

            gameObject.transform.parent = parent;
            SkeletonUtilityBone skeletonUtilityBone = gameObject.AddComponent <SkeletonUtilityBone>();

            skeletonUtilityBone.skeletonUtility = this;
            skeletonUtilityBone.position        = pos;
            skeletonUtilityBone.rotation        = rot;
            skeletonUtilityBone.scale           = sca;
            skeletonUtilityBone.mode            = mode;
            skeletonUtilityBone.zPosition       = true;
            skeletonUtilityBone.Reset();
            skeletonUtilityBone.bone     = bone;
            skeletonUtilityBone.boneName = bone.Data.Name;
            skeletonUtilityBone.valid    = true;
            if (mode == SkeletonUtilityBone.Mode.Override)
            {
                if (rot)
                {
                    gameObject.transform.localRotation = Quaternion.Euler(0f, 0f, skeletonUtilityBone.bone.AppliedRotation);
                }
                if (pos)
                {
                    gameObject.transform.localPosition = new Vector3(skeletonUtilityBone.bone.X, skeletonUtilityBone.bone.Y, 0f);
                }
                gameObject.transform.localScale = new Vector3(skeletonUtilityBone.bone.scaleX, skeletonUtilityBone.bone.scaleY, 0f);
            }
            return(gameObject);
        }
        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)
                {
                    skeletonUtility.skeletonRenderer = skeletonUtility.GetComponent <SkeletonRenderer>();
                }

                if (skeletonUtility.boneRoot != null)
                {
                    return;
                }

                skeletonUtility.SpawnHierarchy(mode, pos, rot, sca);

                SkeletonUtilityBone[] boneComps = skeletonUtility.GetComponentsInChildren <SkeletonUtilityBone>();
                foreach (SkeletonUtilityBone b in boneComps)
                {
                    AttachIcon(b);
                }
            }
        }
Example #3
0
        public GameObject SpawnBone(Bone bone, Transform parent, SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca)
        {
            GameObject go          = new GameObject(bone.Data.Name);
            var        goTransform = go.transform;

            goTransform.parent = parent;

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

            b.hierarchy = 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)
                {
                    goTransform.localRotation = Quaternion.Euler(0, 0, b.bone.AppliedRotation);
                }
                if (pos)
                {
                    goTransform.localPosition = new Vector3(b.bone.X, b.bone.Y, 0);
                }
                goTransform.localScale = new Vector3(b.bone.scaleX, b.bone.scaleY, 0);
            }

            return(go);
        }
        public GameObject SpawnBone(Bone bone, Transform parent, SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca)
        {
            GameObject obj2 = new GameObject(bone.Data.Name)
            {
                transform = { parent = parent }
            };
            SkeletonUtilityBone bone2 = obj2.AddComponent <SkeletonUtilityBone>();

            bone2.skeletonUtility = this;
            bone2.position        = pos;
            bone2.rotation        = rot;
            bone2.scale           = sca;
            bone2.mode            = mode;
            bone2.zPosition       = true;
            bone2.Reset();
            bone2.bone     = bone;
            bone2.boneName = bone.Data.Name;
            bone2.valid    = true;
            if (mode == SkeletonUtilityBone.Mode.Override)
            {
                if (rot)
                {
                    obj2.transform.localRotation = Quaternion.Euler(0f, 0f, bone2.bone.AppliedRotation);
                }
                if (pos)
                {
                    obj2.transform.localPosition = new Vector3(bone2.bone.X, bone2.bone.Y, 0f);
                }
                obj2.transform.localScale = new Vector3(bone2.bone.scaleX, bone2.bone.scaleY, 0f);
            }
            return(obj2);
        }
Example #5
0
 void SetBoneMode(SkeletonUtilityEyeConstraint eye, SkeletonUtilityBone.Mode mode)
 {
     foreach (var eyeTransform in eye.eyes)
     {
         var bone = eyeTransform.GetComponent <SkeletonUtilityBone>();
         bone.mode = mode;
     }
 }
Example #6
0
        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);
        }
Example #7
0
        public GameObject SpawnRoot(SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca)
        {
            this.GetBoneRoot();
            Skeleton   skeleton = this.skeletonRenderer.skeleton;
            GameObject result   = this.SpawnBone(skeleton.RootBone, this.boneRoot, mode, pos, rot, sca);

            this.CollectBones();
            return(result);
        }
Example #8
0
        public GameObject SpawnRoot(SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca)
        {
            GetBoneRoot();
            Skeleton skeleton = this.skeletonComponent.Skeleton;

            GameObject go = SpawnBone(skeleton.RootBone, boneRoot, mode, pos, rot, sca);

            CollectBones();
            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);

        foreach (Bone child in bone.Children)
        {
            SpawnBoneRecursively(child, go.transform, mode, pos, rot, sca);
        }

        return(go);
    }
Example #10
0
        public GameObject SpawnBoneRecursively(Bone bone, Transform parent, SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca)
        {
            GameObject         gameObject = SpawnBone(bone, parent, mode, pos, rot, sca);
            ExposedList <Bone> children   = bone.Children;
            int i = 0;

            for (int count = children.Count; i < count; i++)
            {
                Bone bone2 = children.Items[i];
                SpawnBoneRecursively(bone2, gameObject.transform, mode, pos, rot, sca);
            }
            return(gameObject);
        }
Example #11
0
        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 SpawnBoneRecursively(Bone bone, Transform parent, SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca)
        {
            GameObject         obj2     = this.SpawnBone(bone, parent, mode, pos, rot, sca);
            ExposedList <Bone> children = bone.Children;
            int index = 0;
            int count = children.Count;

            while (index < count)
            {
                Bone bone2 = children.Items[index];
                this.SpawnBoneRecursively(bone2, obj2.transform, mode, pos, rot, sca);
                index++;
            }
            return(obj2);
        }
Example #13
0
        public GameObject SpawnBone(Bone bone, Transform parent, SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca)
        {
            GameObject go = new GameObject(bone.Data.Name);

#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                UnityEditor.Undo.RegisterCreatedObjectUndo(go, "Spawn Bone");
            }
#endif
            if (skeletonGraphic != null)
            {
                go.AddComponent <RectTransform>();
            }

            var goTransform = go.transform;
            goTransform.SetParent(parent);

            SkeletonUtilityBone b = go.AddComponent <SkeletonUtilityBone>();
            b.hierarchy = 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)
                {
                    goTransform.localRotation = Quaternion.Euler(0, 0, b.bone.AppliedRotation);
                }
                if (pos)
                {
                    goTransform.localPosition = new Vector3(b.bone.X * positionScale, b.bone.Y * positionScale, 0);
                }
                goTransform.localScale = new Vector3(b.bone.ScaleX, b.bone.ScaleY, 0);
            }

            return(go);
        }