protected static void DrawBone(int shownBodyView, int i, Rect rect, AvatarSetupTool.BoneWrapper bone, SerializedObject serializedObject, AvatarMappingEditor editor) { if (s_BonePositions[shownBodyView, i] != Vector2.zero) { Vector2 vector = s_BonePositions[shownBodyView, i]; vector.y *= -1f; vector.Scale(new Vector2(rect.width * 0.5f, rect.height * 0.5f)); vector = rect.center + vector; int num = 0x13; Rect rect2 = new Rect(vector.x - (num * 0.5f), vector.y - (num * 0.5f), (float)num, (float)num); bone.BoneDotGUI(rect2, i, true, true, serializedObject, editor); } }
protected static void DrawBone(int shownBodyView, int i, Rect rect, AvatarSetupTool.BoneWrapper bone, SerializedObject serializedObject, AvatarMappingEditor editor) { if (!(AvatarControl.s_BonePositions[shownBodyView, i] == Vector2.zero)) { Vector2 b = AvatarControl.s_BonePositions[shownBodyView, i]; b.y *= -1f; b.Scale(new Vector2(rect.width * 0.5f, rect.height * 0.5f)); b = rect.center + b; int num = 19; Rect rect2 = new Rect(b.x - (float)num * 0.5f, b.y - (float)num * 0.5f, (float)num, (float)num); bone.BoneDotGUI(rect2, rect2, i, true, true, true, serializedObject, editor); } }
static protected void DrawBone(int shownBodyView, int i, Rect rect, AvatarSetupTool.BoneWrapper bone, SerializedObject serializedObject, AvatarMappingEditor editor) { if (s_BonePositions[shownBodyView, i] == Vector2.zero) { return; } Vector2 pos = s_BonePositions[shownBodyView, i]; pos.y *= -1; // because higher values should be up pos.Scale(new Vector2(rect.width * 0.5f, rect.height * 0.5f)); pos = rect.center + pos; int kIconSize = AvatarSetupTool.BoneWrapper.kIconSize; Rect r = new Rect(pos.x - kIconSize * 0.5f, pos.y - kIconSize * 0.5f, kIconSize, kIconSize); bone.BoneDotGUI(r, r, i, true, true, true, serializedObject, editor); }
protected void DisplayFoldout() { Dictionary <Transform, bool> bones = modelBones; EditorGUIUtility.SetIconSize(Vector2.one * 16); // Legend EditorGUILayout.BeginHorizontal(); GUI.color = Color.grey; GUILayout.Label(styles.dotFrameDotted.image, GUILayout.ExpandWidth(false)); GUI.color = Color.white; GUILayout.Label("Optional Bone", GUILayout.ExpandWidth(true)); EditorGUILayout.EndHorizontal(); // Avatar body part has nothing to show for (int i = 1; i < m_BodyPartToggle.Length; i++) { if (m_BodyPartToggle[i]) { // Unfold body part ui whenever a new selection is made. if ((s_DirtySelection == true) && (m_BodyPartFoldout[i] == false)) { for (int j = 0; j < m_BodyPartHumanBone[i].Length; j++) { int boneIndex = m_BodyPartHumanBone[i][j]; if (s_SelectedBoneIndex == boneIndex) { m_BodyPartFoldout[i] = true; } } } m_BodyPartFoldout[i] = GUILayout.Toggle(m_BodyPartFoldout[i], styles.BodyPartMapping[i], EditorStyles.foldout); EditorGUI.indentLevel++; if (m_BodyPartFoldout[i]) { for (int j = 0; j < m_BodyPartHumanBone[i].Length; j++) { int boneIndex = m_BodyPartHumanBone[i][j]; if (boneIndex == -1) { continue; } AvatarSetupTool.BoneWrapper bone = m_Bones[boneIndex]; string displayBoneName = bone.humanBoneName; // @TODO@MECANIM: do properly if ((BodyPart)i == BodyPart.RightArm || (BodyPart)i == BodyPart.RightFingers || (BodyPart)i == BodyPart.RightLeg) { displayBoneName = displayBoneName.Replace("Right", ""); } if ((BodyPart)i == BodyPart.LeftArm || (BodyPart)i == BodyPart.LeftFingers || (BodyPart)i == BodyPart.LeftLeg) { displayBoneName = displayBoneName.Replace("Left", ""); } displayBoneName = ObjectNames.NicifyVariableName(displayBoneName); Rect r = EditorGUILayout.GetControlRect(); Rect selectRect = r; selectRect.width -= 15; Rect rect = new Rect(r.x + EditorGUI.indent, r.y - 1, AvatarSetupTool.BoneWrapper.kIconSize, AvatarSetupTool.BoneWrapper.kIconSize); bone.BoneDotGUI(rect, selectRect, boneIndex, true, false, true, serializedObject, this); r.xMin += AvatarSetupTool.BoneWrapper.kIconSize; Transform newBoneTransform = EditorGUI.ObjectField(r, new GUIContent(displayBoneName), bone.bone, typeof(Transform), true) as Transform; if (newBoneTransform != bone.bone) { Undo.RegisterCompleteObjectUndo(this, "Avatar mapping modified"); bone.bone = newBoneTransform; bone.Serialize(m_HumanBoneArray); // User adding a bone manually, if it not in the modelBones dict, we must explictly add it if (newBoneTransform != null && !bones.ContainsKey(newBoneTransform)) { bones[newBoneTransform] = true; } } if (!string.IsNullOrEmpty(bone.error)) { GUILayout.BeginHorizontal(); GUILayout.Space(EditorGUI.indent + AvatarSetupTool.BoneWrapper.kIconSize + 4); GUILayout.Label(bone.error, s_Styles.errorLabel); GUILayout.EndHorizontal(); } } } EditorGUI.indentLevel--; } } s_DirtySelection = false; EditorGUIUtility.SetIconSize(Vector2.zero); }
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); }
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); }