Пример #1
0
        protected void DisplayFoldout()
        {
            Dictionary <Transform, bool> modelBones = base.modelBones;

            EditorGUIUtility.SetIconSize(Vector2.one * 16f);
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUI.color = Color.grey;
            GUILayout.Label(AvatarMappingEditor.styles.dotFrameDotted.image, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(false)
            });
            GUI.color = Color.white;
            GUILayout.Label("Optional Bone", new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(true)
            });
            EditorGUILayout.EndHorizontal();
            for (int i = 1; i < this.m_BodyPartToggle.Length; i++)
            {
                if (this.m_BodyPartToggle[i])
                {
                    if (AvatarMappingEditor.s_DirtySelection && !this.m_BodyPartFoldout[i])
                    {
                        for (int j = 0; j < this.m_BodyPartHumanBone[i].Length; j++)
                        {
                            int num = this.m_BodyPartHumanBone[i][j];
                            if (AvatarMappingEditor.s_SelectedBoneIndex == num)
                            {
                                this.m_BodyPartFoldout[i] = true;
                            }
                        }
                    }
                    this.m_BodyPartFoldout[i] = GUILayout.Toggle(this.m_BodyPartFoldout[i], AvatarMappingEditor.styles.BodyPartMapping[i], EditorStyles.foldout, new GUILayoutOption[0]);
                    EditorGUI.indentLevel++;
                    if (this.m_BodyPartFoldout[i])
                    {
                        for (int k = 0; k < this.m_BodyPartHumanBone[i].Length; k++)
                        {
                            int num2 = this.m_BodyPartHumanBone[i][k];
                            if (num2 != -1)
                            {
                                AvatarSetupTool.BoneWrapper boneWrapper = this.m_Bones[num2];
                                string text = boneWrapper.humanBoneName;
                                if (i == 5 || i == 6 || i == 8)
                                {
                                    text = text.Replace("Right", string.Empty);
                                }
                                if (i == 3 || i == 4 || i == 7)
                                {
                                    text = text.Replace("Left", string.Empty);
                                }
                                text = ObjectNames.NicifyVariableName(text);
                                Rect controlRect = EditorGUILayout.GetControlRect(new GUILayoutOption[0]);
                                Rect selectRect  = controlRect;
                                selectRect.width -= 15f;
                                boneWrapper.HandleClickSelection(selectRect, num2);
                                boneWrapper.BoneDotGUI(new Rect(controlRect.x + EditorGUI.indent, controlRect.y - 1f, 19f, 19f), num2, false, false, base.serializedObject, this);
                                controlRect.xMin += 19f;
                                Transform transform = EditorGUI.ObjectField(controlRect, new GUIContent(text), boneWrapper.bone, typeof(Transform), true) as Transform;
                                if (transform != boneWrapper.bone)
                                {
                                    Undo.RegisterCompleteObjectUndo(this, "Avatar mapping modified");
                                    boneWrapper.bone = transform;
                                    boneWrapper.Serialize(base.serializedObject);
                                    if (transform != null && !modelBones.ContainsKey(transform))
                                    {
                                        modelBones[transform] = true;
                                    }
                                }
                                if (!string.IsNullOrEmpty(boneWrapper.error))
                                {
                                    GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                                    GUILayout.Space(EditorGUI.indent + 19f + 4f);
                                    GUILayout.Label(boneWrapper.error, AvatarMappingEditor.s_Styles.errorLabel, new GUILayoutOption[0]);
                                    GUILayout.EndHorizontal();
                                }
                            }
                        }
                    }
                    EditorGUI.indentLevel--;
                }
            }
            AvatarMappingEditor.s_DirtySelection = false;
            EditorGUIUtility.SetIconSize(Vector2.zero);
        }
Пример #2
0
        protected void DisplayFoldout()
        {
            Dictionary <Transform, bool> modelBones = this.modelBones;

            EditorGUIUtility.SetIconSize(Vector2.one * 16f);
            EditorGUILayout.BeginHorizontal();
            GUI.color = Color.grey;
            GUILayout.Label(AvatarMappingEditor.styles.dotFrameDotted.image, new GUILayoutOption[1]
            {
                GUILayout.ExpandWidth(false)
            });
            GUI.color = Color.white;
            GUILayout.Label("Optional Bone", new GUILayoutOption[1]
            {
                GUILayout.ExpandWidth(true)
            });
            EditorGUILayout.EndHorizontal();
            for (int index1 = 1; index1 < this.m_BodyPartToggle.Length; ++index1)
            {
                if (this.m_BodyPartToggle[index1])
                {
                    if (AvatarMappingEditor.s_DirtySelection && !this.m_BodyPartFoldout[index1])
                    {
                        for (int index2 = 0; index2 < this.m_BodyPartHumanBone[index1].Length; ++index2)
                        {
                            int num = this.m_BodyPartHumanBone[index1][index2];
                            if (AvatarMappingEditor.s_SelectedBoneIndex == num)
                            {
                                this.m_BodyPartFoldout[index1] = true;
                            }
                        }
                    }
                    this.m_BodyPartFoldout[index1] = GUILayout.Toggle(this.m_BodyPartFoldout[index1], AvatarMappingEditor.styles.BodyPartMapping[index1], EditorStyles.foldout, new GUILayoutOption[0]);
                    ++EditorGUI.indentLevel;
                    if (this.m_BodyPartFoldout[index1])
                    {
                        for (int index2 = 0; index2 < this.m_BodyPartHumanBone[index1].Length; ++index2)
                        {
                            int boneIndex = this.m_BodyPartHumanBone[index1][index2];
                            if (boneIndex != -1)
                            {
                                AvatarSetupTool.BoneWrapper bone = this.m_Bones[boneIndex];
                                string name = bone.humanBoneName;
                                if (index1 == 5 || index1 == 6 || index1 == 8)
                                {
                                    name = name.Replace("Right", string.Empty);
                                }
                                if (index1 == 3 || index1 == 4 || index1 == 7)
                                {
                                    name = name.Replace("Left", string.Empty);
                                }
                                string text        = ObjectNames.NicifyVariableName(name);
                                Rect   controlRect = EditorGUILayout.GetControlRect();
                                Rect   selectRect  = controlRect;
                                selectRect.width -= 15f;
                                bone.HandleClickSelection(selectRect, boneIndex);
                                bone.BoneDotGUI(new Rect(controlRect.x + EditorGUI.indent, controlRect.y - 1f, 19f, 19f), boneIndex, false, false, this.serializedObject, this);
                                controlRect.xMin += 19f;
                                Transform key = EditorGUI.ObjectField(controlRect, new GUIContent(text), (UnityEngine.Object)bone.bone, typeof(Transform), true) as Transform;
                                if ((UnityEngine.Object)key != (UnityEngine.Object)bone.bone)
                                {
                                    Undo.RegisterCompleteObjectUndo((UnityEngine.Object) this, "Avatar mapping modified");
                                    bone.bone = key;
                                    bone.Serialize(this.serializedObject);
                                    if ((UnityEngine.Object)key != (UnityEngine.Object)null && !modelBones.ContainsKey(key))
                                    {
                                        modelBones[key] = true;
                                    }
                                }
                                if (!string.IsNullOrEmpty(bone.error))
                                {
                                    GUILayout.BeginHorizontal();
                                    GUILayout.Space((float)((double)EditorGUI.indent + 19.0 + 4.0));
                                    GUILayout.Label(bone.error, AvatarMappingEditor.s_Styles.errorLabel, new GUILayoutOption[0]);
                                    GUILayout.EndHorizontal();
                                }
                            }
                        }
                    }
                    --EditorGUI.indentLevel;
                }
            }
            AvatarMappingEditor.s_DirtySelection = false;
            EditorGUIUtility.SetIconSize(Vector2.zero);
        }