public static int ShowBoneMapping(int shownBodyView, AvatarControl.BodyPartFeedback bodyPartCallback, AvatarSetupTool.BoneWrapper[] bones, SerializedObject serializedObject, AvatarMappingEditor editor) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if ((bool) ((Object) AvatarControl.styles.Silhouettes[shownBodyView].image)) { Rect rect = GUILayoutUtility.GetRect(AvatarControl.styles.Silhouettes[shownBodyView], GUIStyle.none, new GUILayoutOption[1]{ GUILayout.MaxWidth((float) AvatarControl.styles.Silhouettes[shownBodyView].image.width) }); AvatarControl.DrawBodyParts(rect, shownBodyView, bodyPartCallback); for (int i = 0; i < bones.Length; ++i) AvatarControl.DrawBone(shownBodyView, i, rect, bones[i], serializedObject, editor); } else GUILayout.Label("texture missing,\nfix me!"); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); Rect lastRect = GUILayoutUtility.GetLastRect(); string[] strArray = new string[4]{ "Body", "Head", "Left Hand", "Right Hand" }; lastRect.x += 5f; lastRect.width = 70f; lastRect.yMin = lastRect.yMax - 69f; lastRect.height = 16f; for (int index = 0; index < strArray.Length; ++index) { if (GUI.Toggle(lastRect, shownBodyView == index, strArray[index], EditorStyles.miniButton)) shownBodyView = index; lastRect.y += 16f; } return shownBodyView; }
private void UpdateSelectedBone() { // Look for selected bone slot int oldSelectedBoneIndex = s_SelectedBoneIndex; if (s_SelectedBoneIndex < 0 || s_SelectedBoneIndex >= m_Bones.Length || m_Bones[s_SelectedBoneIndex].bone != Selection.activeTransform) { s_SelectedBoneIndex = -1; if (Selection.activeTransform != null) { for (int i = 0; i < m_Bones.Length; i++) { if (m_Bones[i].bone == Selection.activeTransform) { s_SelectedBoneIndex = i; break; } } } } if (s_SelectedBoneIndex != oldSelectedBoneIndex) { // If selected bone changed, change visual to show image that contains that bone. List <int> views = AvatarControl.GetViewsThatContainBone(s_SelectedBoneIndex); if (views.Count > 0 && !views.Contains(m_BodyView)) { m_BodyView = views[0]; } } }
private void UpdateSelectedBone() { int num = AvatarMappingEditor.s_SelectedBoneIndex; if (AvatarMappingEditor.s_SelectedBoneIndex < 0 || AvatarMappingEditor.s_SelectedBoneIndex >= this.m_Bones.Length || this.m_Bones[AvatarMappingEditor.s_SelectedBoneIndex].bone != Selection.activeTransform) { AvatarMappingEditor.s_SelectedBoneIndex = -1; if (Selection.activeTransform != null) { for (int i = 0; i < this.m_Bones.Length; i++) { if (this.m_Bones[i].bone == Selection.activeTransform) { AvatarMappingEditor.s_SelectedBoneIndex = i; break; } } } } if (AvatarMappingEditor.s_SelectedBoneIndex != num) { List <int> viewsThatContainBone = AvatarControl.GetViewsThatContainBone(AvatarMappingEditor.s_SelectedBoneIndex); if (viewsThatContainBone.Count > 0 && !viewsThatContainBone.Contains(this.m_BodyView)) { this.m_BodyView = viewsThatContainBone[0]; } } }
private void UpdateSelectedBone() { int selectedBoneIndex = AvatarMappingEditor.s_SelectedBoneIndex; if (AvatarMappingEditor.s_SelectedBoneIndex < 0 || AvatarMappingEditor.s_SelectedBoneIndex >= this.m_Bones.Length || (UnityEngine.Object) this.m_Bones[AvatarMappingEditor.s_SelectedBoneIndex].bone != (UnityEngine.Object)Selection.activeTransform) { AvatarMappingEditor.s_SelectedBoneIndex = -1; if ((UnityEngine.Object)Selection.activeTransform != (UnityEngine.Object)null) { for (int index = 0; index < this.m_Bones.Length; ++index) { if ((UnityEngine.Object) this.m_Bones[index].bone == (UnityEngine.Object)Selection.activeTransform) { AvatarMappingEditor.s_SelectedBoneIndex = index; break; } } } } if (AvatarMappingEditor.s_SelectedBoneIndex == selectedBoneIndex) { return; } List <int> viewsThatContainBone = AvatarControl.GetViewsThatContainBone(AvatarMappingEditor.s_SelectedBoneIndex); if (viewsThatContainBone.Count <= 0 || viewsThatContainBone.Contains(this.m_BodyView)) { return; } this.m_BodyView = viewsThatContainBone[0]; }
public static void DrawBodyParts(Rect rect, int shownBodyView, AvatarControl.BodyPartFeedback bodyPartCallback) { GUI.color = new Color(0.2f, 0.2f, 0.2f, 1f); if (AvatarControl.styles.Silhouettes[shownBodyView] != null) { GUI.DrawTexture(rect, AvatarControl.styles.Silhouettes[shownBodyView].image); } for (int i = 1; i < 9; ++i) { AvatarControl.DrawBodyPart(shownBodyView, i, rect, bodyPartCallback((BodyPart)i)); } }
public static int ShowBoneMapping(int shownBodyView, AvatarControl.BodyPartFeedback bodyPartCallback, AvatarSetupTool.BoneWrapper[] bones, SerializedObject serializedObject, AvatarMappingEditor editor) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); if (AvatarControl.styles.Silhouettes[shownBodyView].image) { Rect rect = GUILayoutUtility.GetRect(AvatarControl.styles.Silhouettes[shownBodyView], GUIStyle.none, new GUILayoutOption[] { GUILayout.MaxWidth((float)AvatarControl.styles.Silhouettes[shownBodyView].image.width) }); AvatarControl.DrawBodyParts(rect, shownBodyView, bodyPartCallback); for (int i = 0; i < bones.Length; i++) { AvatarControl.DrawBone(shownBodyView, i, rect, bones[i], serializedObject, editor); } } else { GUILayout.Label("texture missing,\nfix me!", new GUILayoutOption[0]); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); Rect lastRect = GUILayoutUtility.GetLastRect(); string[] array = new string[] { "Body", "Head", "Left Hand", "Right Hand" }; lastRect.x += 5f; lastRect.width = 70f; lastRect.yMin = lastRect.yMax - 69f; lastRect.height = 16f; for (int j = 0; j < array.Length; j++) { if (GUI.Toggle(lastRect, shownBodyView == j, array[j], EditorStyles.miniButton)) { shownBodyView = j; } lastRect.y += 16f; } return(shownBodyView); }
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; } }
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; } }
protected static void DrawBodyPart(int shownBodyView, int i, Rect rect, AvatarControl.BodyPartColor bodyPartColor) { if (AvatarControl.styles.BodyPart[shownBodyView, i] == null || !((Object) AvatarControl.styles.BodyPart[shownBodyView, i].image != (Object) null)) return; GUI.color = (bodyPartColor & AvatarControl.BodyPartColor.Green) != AvatarControl.BodyPartColor.Green ? ((bodyPartColor & AvatarControl.BodyPartColor.Red) != AvatarControl.BodyPartColor.Red ? Color.gray : Color.red) : Color.green; GUI.DrawTexture(rect, AvatarControl.styles.BodyPart[shownBodyView, i].image); GUI.color = Color.white; }
public static void DrawBodyParts(Rect rect, int shownBodyView, AvatarControl.BodyPartFeedback bodyPartCallback) { GUI.color = new Color(0.2f, 0.2f, 0.2f, 1f); if (AvatarControl.styles.Silhouettes[shownBodyView] != null) GUI.DrawTexture(rect, AvatarControl.styles.Silhouettes[shownBodyView].image); for (int i = 1; i < 9; ++i) AvatarControl.DrawBodyPart(shownBodyView, i, rect, bodyPartCallback((BodyPart) i)); }
protected static void DrawBodyPart(int shownBodyView, int i, Rect rect, AvatarControl.BodyPartColor bodyPartColor) { if (AvatarControl.styles.BodyPart[shownBodyView, i] != null && AvatarControl.styles.BodyPart[shownBodyView, i].image != null) { if ((bodyPartColor & AvatarControl.BodyPartColor.Green) == AvatarControl.BodyPartColor.Green) { GUI.color = Color.green; } else { if ((bodyPartColor & AvatarControl.BodyPartColor.Red) == AvatarControl.BodyPartColor.Red) { GUI.color = Color.red; } else { GUI.color = Color.gray; } } GUI.DrawTexture(rect, AvatarControl.styles.BodyPart[shownBodyView, i].image); GUI.color = Color.white; } }