Пример #1
0
        public static BoneCache CreateBone(this SkeletonCache skeleton, BoneCache parentBone, Vector3 position, Vector3 endPosition, bool isChained, string name)
        {
            Debug.Assert(skeleton != null);

            if (parentBone != null)
            {
                Debug.Assert(skeleton.Contains(parentBone));
            }

            var bone = skeleton.skinningCache.CreateCache <BoneCache>();

            bone.SetParent(parentBone);
            bone.name          = name;
            bone.bindPoseColor = ModuleUtility.CalculateNiceColor(skeleton.BoneCount, 6);
            bone.position      = position;
            bone.endPosition   = endPosition;

            if (isChained && parentBone != null)
            {
                parentBone.chainedChild = bone;
            }

            skeleton.AddBone(bone);


            return(bone);
        }
Пример #2
0
        public BoneCache[] CreateBoneCacheFromSpriteBones(UnityEngine.U2D.SpriteBone[] spriteBones, float scale)
        {
            var bones = Array.ConvertAll(spriteBones, b => CreateCache <BoneCache>());

            for (var i = 0; i < spriteBones.Length; ++i)
            {
                var spriteBone = spriteBones[i];
                var bone       = bones[i];

                if (spriteBone.parentId >= 0)
                {
                    bone.SetParent(bones[spriteBone.parentId]);
                }

                bone.name          = spriteBone.name;
                bone.localLength   = spriteBone.length * scale;
                bone.depth         = spriteBone.position.z;
                bone.localPosition = (Vector2)spriteBone.position * scale;
                bone.localRotation = spriteBone.rotation;
                bone.bindPoseColor = ModuleUtility.CalculateNiceColor(i, 6);
            }

            foreach (var bone in bones)
            {
                if (bone.parentBone != null && bone.parentBone.localLength > 0f && (bone.position - bone.parentBone.endPosition).sqrMagnitude < 0.005f)
                {
                    bone.parentBone.chainedChild = bone;
                }
            }

            return(bones);
        }
Пример #3
0
 protected override Color GetBoneColorRaw(int index)
 {
     return(ModuleUtility.CalculateNiceColor(index, 6));
 }