コード例 #1
0
ファイル: IkUtils.cs プロジェクト: CarlosMeloStuff/Arx
        static void BuildIkList(Bone2D bone, List <Bone2D> boneList, List <Ik2D> ikList)
        {
            if (!bone)
            {
                return;
            }

            if (boneList.Contains(bone))
            {
                return;
            }

            boneList.Add(bone);

            Ik2D ik2D = bone.attachedIK;

            List <Bone2D> childBones = new List <Bone2D>(25);

            if (ik2D)
            {
                if (!ikList.Contains(ik2D))
                {
                    ikList.Add(ik2D);
                }

                for (int i = 0; i < ik2D.solver.solverPoses.Count; i++)
                {
                    IkSolver2D.SolverPose pose = ik2D.solver.solverPoses [i];

                    if (pose.bone)
                    {
                        pose.bone.GetComponentsInChildren <Bone2D>(childBones);

                        for (int j = 0; j < childBones.Count; j++)
                        {
                            Bone2D l_bone = childBones[j];

                            if (l_bone && !boneList.Contains(l_bone))
                            {
                                BuildIkList(l_bone, boneList, ikList);
                            }
                        }
                    }
                }
            }
            else
            {
                bone.GetComponentsInChildren <Bone2D>(childBones);

                for (int j = 0; j < childBones.Count; j++)
                {
                    Bone2D l_bone = childBones[j];

                    if (l_bone && !boneList.Contains(l_bone))
                    {
                        BuildIkList(l_bone, boneList, ikList);
                    }
                }
            }
        }
コード例 #2
0
        public static string GetUniqueBoneName(Bone2D root)
        {
            string boneName = "bone";

            Bone2D[] bones = null;

            if (root)
            {
                bones    = root.GetComponentsInChildren <Bone2D>(true);
                boneName = boneName + " " + (bones.Length + 1).ToString();
            }

            return(boneName);
        }
コード例 #3
0
ファイル: BoneUtils.cs プロジェクト: Kundara/project1
		public static string GetUniqueBoneName(Bone2D root)
		{
			string boneName = "bone";
			
			Bone2D[] bones = null;
			
			if(root)
			{
				bones = root.GetComponentsInChildren<Bone2D>(true);
				boneName = boneName + " " + (bones.Length + 1).ToString();
			}
			
			return boneName;
		}
コード例 #4
0
        public override void OnInspectorGUI()
        {
            if (DrawDefaultInspector())
            {
                mSpriteMeshInstance.UpdateRenderer();

                if (mSpriteMeshInstance.cachedRenderer)
                {
                    EditorUtility.SetDirty(mSpriteMeshInstance.cachedRenderer);
                }

                if (mSpriteMeshInstance.cachedSkinnedRenderer)
                {
                    EditorUtility.SetDirty(mSpriteMeshInstance.cachedSkinnedRenderer);
                }
            }

            serializedObject.Update();

            Transform root = EditorGUILayout.ObjectField("Set bones", null, typeof(Transform), true) as Transform;

            Bone2D childBone = null;

            if (root)
            {
                childBone = root.GetComponent <Bone2D>();
            }

            if (root && !childBone)
            {
                childBone = root.GetComponentInChildren <Bone2D>();
                childBone = childBone.root;
            }

            if (childBone)
            {
                Undo.RegisterCompleteObjectUndo(mSpriteMeshInstance, "set bones");

                childBone.GetComponentsInChildren <Bone2D>(true, mSpriteMeshInstance.bones);

                EditorUtility.SetDirty(mSpriteMeshInstance);
            }

            if (mBoneList != null)
            {
                mBoneList.DoLayoutList();
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            EditorGUI.BeginDisabledGroup(HasNullBones() ||
                                         mSpriteMeshInstance.bones.Count == 0 ||
                                         mSpriteMeshInstance.spriteMesh.bindPoses.Count != mSpriteMeshInstance.bones.Count);

            if (GUILayout.Button("Set skinned renderer", GUILayout.MaxWidth(150f)))
            {
                EditorApplication.delayCall += DoSetSkinnedRenderer;
            }

            EditorGUI.EndDisabledGroup();

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();


            if (GUILayout.Button("Set mesh renderer", GUILayout.MaxWidth(150f)))
            {
                EditorApplication.delayCall += DoSetMeshRenderer;
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            if (HasNullBones())
            {
                EditorGUILayout.HelpBox("Warning:\nBone list contains null references.", MessageType.Warning);
            }

            if (mSpriteMeshInstance.spriteMesh.bindPoses.Count != mSpriteMeshInstance.bones.Count)
            {
                EditorGUILayout.HelpBox("Warning:\nNumber of SpriteMesh Bind Poses and number of Bones does not match.", MessageType.Warning);
            }

            serializedObject.ApplyModifiedProperties();
        }