ShowBoneMapping() public static method

public static ShowBoneMapping ( int shownBodyView, BodyPartFeedback bodyPartCallback, AvatarSetupTool bones, SerializedObject serializedObject, UnityEditor.AvatarMappingEditor editor ) : int
shownBodyView int
bodyPartCallback BodyPartFeedback
bones AvatarSetupTool
serializedObject SerializedObject
editor UnityEditor.AvatarMappingEditor
return int
        public override void OnInspectorGUI()
        {
            HandleUndoPerformed();
            UpdateSelectedBone();

            // case 837655.  GUI.keyboardControl is overriden when changing scene selection.
            // Late update here to bypass this issue.
            if (s_KeyboardControl != 0)
            {
                GUIUtility.keyboardControl = s_KeyboardControl;
                s_KeyboardControl          = 0;
            }

            GUILayout.BeginVertical();
            {
                EditorGUI.BeginChangeCheck();

                GUILayout.BeginVertical("", "TE NodeBackground");
                {
                    m_BodyView = AvatarControl.ShowBoneMapping(m_BodyView, new AvatarControl.BodyPartFeedback(this.IsValidBodyPart), m_Bones, serializedObject, this);
                    HandleBodyView(m_BodyView);
                }
                GUILayout.EndVertical();

                m_FoldoutScroll = GUILayout.BeginScrollView(m_FoldoutScroll, styles.box, GUILayout.MinHeight(80), GUILayout.MaxHeight(500), GUILayout.ExpandHeight(true));
                {
                    DisplayFoldout();
                    GUILayout.FlexibleSpace();
                }
                GUILayout.EndScrollView();

                if (EditorGUI.EndChangeCheck())
                {
                    ValidateMapping();
                    SceneView.RepaintAll();
                }

                DisplayMappingButtons();
            }
            GUILayout.EndVertical();

            if (EditorGUIUtility.hotControl == 0)
            {
                TransferPoseIfChanged();
            }

            //DebugPoseButtons ();

            ApplyRevertGUI();

            if (Selection.activeTransform != null)
            {
                // Selection is changing, clean up before we create a new editor
                if (m_CurrentTransformEditor != null && m_CurrentTransformEditor.target != Selection.activeTransform)
                {
                    DestroyImmediate(m_CurrentTransformEditor);
                }

                if (m_CurrentTransformEditor == null)
                {
                    m_CurrentTransformEditor = Editor.CreateEditor(Selection.activeTransform);
                }

                EditorGUILayout.Space();
                m_CurrentTransformEditorFoldout = EditorGUILayout.InspectorTitlebar(m_CurrentTransformEditorFoldout, Selection.activeTransform, true);

                if (m_CurrentTransformEditorFoldout && m_CurrentTransformEditor != null)
                {
                    m_CurrentTransformEditor.OnInspectorGUI();
                }
            }
            else if (m_CurrentTransformEditor != null)
            {
                DestroyImmediate(m_CurrentTransformEditor);
                m_CurrentTransformEditor = null;
            }
        }
Esempio n. 2
0
 public override void OnInspectorGUI()
 {
     if (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
     {
         AvatarSetupTool.TransferPoseToDescription(base.serializedObject, base.root);
         for (int i = 0; i < this.m_Bones.Length; i++)
         {
             this.m_Bones[i].Serialize(base.serializedObject);
         }
     }
     this.UpdateSelectedBone();
     if (Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.Backspace || Event.current.keyCode == KeyCode.Delete) && AvatarMappingEditor.s_SelectedBoneIndex != -1 && AvatarMappingEditor.s_SelectedBoneIndex < this.m_Bones.Length)
     {
         Undo.RegisterCompleteObjectUndo(this, "Avatar mapping modified");
         AvatarSetupTool.BoneWrapper boneWrapper = this.m_Bones[AvatarMappingEditor.s_SelectedBoneIndex];
         boneWrapper.bone  = null;
         boneWrapper.state = BoneState.None;
         boneWrapper.Serialize(base.serializedObject);
         Selection.activeTransform = null;
         GUI.changed = true;
         Event.current.Use();
     }
     GUILayout.BeginVertical(new GUILayoutOption[0]);
     EditorGUI.BeginChangeCheck();
     GUILayout.BeginVertical(string.Empty, "TE NodeBackground", new GUILayoutOption[0]);
     this.m_BodyView = AvatarControl.ShowBoneMapping(this.m_BodyView, new AvatarControl.BodyPartFeedback(this.IsValidBodyPart), this.m_Bones, base.serializedObject, this);
     this.HandleBodyView(this.m_BodyView);
     GUILayout.EndVertical();
     this.m_FoldoutScroll = GUILayout.BeginScrollView(this.m_FoldoutScroll, AvatarMappingEditor.styles.box, new GUILayoutOption[]
     {
         GUILayout.MinHeight(80f),
         GUILayout.MaxHeight(500f),
         GUILayout.ExpandHeight(true)
     });
     this.DisplayFoldout();
     GUILayout.FlexibleSpace();
     GUILayout.EndScrollView();
     if (EditorGUI.EndChangeCheck())
     {
         this.ValidateMapping();
         SceneView.RepaintAll();
     }
     this.DisplayMappingButtons();
     GUILayout.EndVertical();
     if (GUIUtility.hotControl == 0)
     {
         this.TransferPoseIfChanged();
     }
     base.ApplyRevertGUI();
     if (Selection.activeTransform != null)
     {
         if (this.m_CurrentTransformEditor != null && this.m_CurrentTransformEditor.target != Selection.activeTransform)
         {
             UnityEngine.Object.DestroyImmediate(this.m_CurrentTransformEditor);
         }
         if (this.m_CurrentTransformEditor == null)
         {
             this.m_CurrentTransformEditor = Editor.CreateEditor(Selection.activeTransform);
         }
         EditorGUILayout.Space();
         this.m_CurrentTransformEditorFoldout = EditorGUILayout.InspectorTitlebar(this.m_CurrentTransformEditorFoldout, Selection.activeTransform, true);
         if (this.m_CurrentTransformEditorFoldout && this.m_CurrentTransformEditor != null)
         {
             this.m_CurrentTransformEditor.OnInspectorGUI();
         }
     }
     else if (this.m_CurrentTransformEditor != null)
     {
         UnityEngine.Object.DestroyImmediate(this.m_CurrentTransformEditor);
         this.m_CurrentTransformEditor = null;
     }
 }