// Menu static void PopupMenu() { if (Event.current != null && Event.current.type == EventType.mouseDown) { if (Event.current.button == 1) { ControllerEditorMenu.Popup(Event.current.mousePosition, Content2Node(Event.current.mousePosition)); } } }
static void PoseNodeWindow(int windowID) { PoseNode posenode = null; if (windowID < controller.posenodes.Count) { posenode = controller.posenodes[windowID]; } else { posenode = controller.final; } if (posenode == null) { GUI.DragWindow(); return; } // Delete this posenode if (draggingSlot == null && editingSlot == null && Event.current != null && Event.current.type == EventType.mouseDown) { if (Event.current.button == 1 && Event.current.mousePosition.y < 16) { ControllerEditorMenu.PopupDelete(Event.current.mousePosition, null, posenode); } } // Multiple-click this posenode if (draggingSlot == null && editingSlot == null && Event.current != null && Event.current.type == EventType.mouseDown) { if (Event.current.button == 0 && Event.current.clickCount == 2 && Event.current.mousePosition.y < 16) { if (posenode is Modifier) { CameraForgeWindow.nextCurrent = posenode; mouseDown = false; } } } GUILayout.BeginHorizontal(GUILayout.MinHeight(10)); if (posenode.slots.Length + posenode.poseslots.Length > 0) { GUILayout.BeginVertical(); GUILayout.Space(1); for (int i = 0; i < posenode.slots.Length; ++i) { //GUILayout.Space(-1); Rect rct = EditorGUILayout.BeginHorizontal(); GUI.color = posenode.slots[i].input == null ? new Color(1, 1, 1, 0.2f) : Color.white; if (posenode.slots[i].name == "Name" || posenode.slots[i].name == "Count") { GUI.color = Color.clear; } GUILayout.Label(posenode.slots[i].input == null ? cfwindow.texInputSlot : cfwindow.texInputSlotActive); GUI.color = Color.white; EditorGUILayout.EndHorizontal(); GUILayout.Space(-3); // Draw "drag slot area" GUIStyle gs = new GUIStyle(); gs.normal.background = cfwindow.texInputSlot; gs.hover.background = cfwindow.texInputSlot; gs.active.background = cfwindow.texInputSlot; rct.x += 2; rct.y += 1; rct.width = 16; rct.height = 16; Color c = NodeColor(posenode); c.a = 0.7f; GUI.color = c; if (posenode.slots[i].name != "Name" && posenode.slots[i].name != "Count") { if (Event.current != null && rct.Contains(Event.current.mousePosition)) { GUI.Label(rct, "", gs); // Begin drag slot if (Event.current.type == EventType.MouseDown) { if (Event.current.button == 0) { draggingSlot = posenode.slots[i]; draggingSlotIndex = i; draggingSlot.input = null; dragSlotExcludeNode = null; dragPoseSlotExcludeNode = posenode; } } } } GUI.color = Color.white; } for (int i = 0; i < posenode.poseslots.Length; ++i) { //GUILayout.Space(-1); Rect rct = EditorGUILayout.BeginHorizontal(); GUI.color = posenode.poseslots[i].input == null ? new Color(1, 1, 1, 0.2f) : Color.white; GUILayout.Label(posenode.poseslots[i].input == null ? cfwindow.texInputSlot : cfwindow.texInputSlotActive); GUI.color = Color.white; EditorGUILayout.EndHorizontal(); GUILayout.Space(-3); // Draw "drag slot area" GUIStyle gs = new GUIStyle(); gs.normal.background = cfwindow.texInputSlot; gs.hover.background = cfwindow.texInputSlot; gs.active.background = cfwindow.texInputSlot; rct.x += 2; rct.y += 1; rct.width = 16; rct.height = 16; Color c = NodeColor(posenode); c.a = 0.7f; GUI.color = c; if (Event.current != null && rct.Contains(Event.current.mousePosition)) { GUI.Label(rct, "", gs); // Begin drag slot if (Event.current.type == EventType.MouseDown) { if (Event.current.button == 0) { draggingPoseSlot = posenode.poseslots[i]; draggingPoseSlotIndex = i; draggingPoseSlot.input = null; dragSlotExcludeNode = null; dragPoseSlotExcludeNode = posenode; } } } GUI.color = Color.white; } GUILayout.Space(3); GUILayout.EndVertical(); Rect nameRect = EditorGUILayout.BeginVertical(GUILayout.MinWidth(30), GUILayout.MaxWidth(200)); GUILayout.Space(2); for (int i = 0; i < posenode.slots.Length; ++i) { if (posenode.slots[i] == editingSlot) { GUI.color = Color.clear; } GUILayout.Label(posenode.slots[i].name); GUI.color = Color.white; } for (int i = 0; i < posenode.poseslots.Length; ++i) { GUILayout.Label(posenode.poseslots[i].name); } EditorGUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.MinWidth(20), GUILayout.MaxWidth(200)); GUILayout.Space(2); for (int i = 0; i < posenode.slots.Length; ++i) { string value = ""; if (!posenode.slots[i].value.isNull) { value = posenode.slots[i].value.ToEditString(false); } Rect rct = EditorGUILayout.BeginHorizontal(); GUIStyle gs = new GUIStyle(EditorStyles.label); gs.alignment = TextAnchor.MiddleRight; gs.padding = new RectOffset(gs.padding.left, 5, gs.padding.top, gs.padding.bottom); Color c = NodeColor(posenode); c.a = 0.25f; if (posenode.slots[i].input != null) { GUI.color = c; GUILayout.Label(value, gs); GUI.color = Color.white; } else { GUIStyle gbs = new GUIStyle(EditorStyles.miniButton); gbs.hover.background = gbs.normal.background; Rect btn_rct = new Rect(rct.xMin - (nameRect.width + 8), rct.yMin, rct.width + (nameRect.width + 8), rct.height - 1); c.a = 0.5f; GUI.color = c; if (!posenode.slots[i].value.isNull) { gbs.normal.background = null; } if (posenode.slots[i] != editingSlot && GUI.Button(btn_rct, "", gbs)) { if (Event.current != null && Event.current.button == 0) { EndEditingSlot(); editingSlot = posenode.slots[i]; editingSlotValue = posenode.slots[i].value.ToEditString(true); if (posenode is PoseBlend) { editingPoseBlend = posenode as PoseBlend; } else { editingPoseBlend = null; } GUI.FocusControl(""); } } GUI.color = Color.white; if (posenode.slots[i].value.isNull) { value = "?"; } if (posenode.slots[i] == editingSlot) { GUI.color = Color.clear; } GUILayout.Label(value, gs); GUI.color = Color.white; if (posenode.slots[i] == editingSlot) { GUIStyle gfs = new GUIStyle(EditorStyles.textField); gfs.alignment = TextAnchor.MiddleRight; gfs.padding = new RectOffset(gfs.padding.left, 5, gfs.padding.top, gfs.padding.bottom); gfs.fontSize = 10; c.a = 1; //GUI.color = c; GUI.SetNextControlName("EditSlot"); editingSlotValue = GUI.TextField(btn_rct, editingSlotValue, gfs); } } EditorGUILayout.EndHorizontal(); } for (int i = 0; i < posenode.poseslots.Length; ++i) { string value = "Camera Pose"; if (posenode is PoseBlend) { value = "Weight = " + (posenode as PoseBlend).GetWeight(i).ToString("0.000000"); } EditorGUILayout.BeginHorizontal(); GUIStyle gs = new GUIStyle(EditorStyles.label); gs.alignment = TextAnchor.MiddleRight; gs.padding = new RectOffset(gs.padding.left, 5, gs.padding.top, gs.padding.bottom); Color c = NodeColor(posenode); c.a = 0.25f; if (posenode.poseslots[i].input != null) { GUI.color = c; GUILayout.Label(value, gs); GUI.color = Color.white; } else { GUI.color = c; GUILayout.Label("Default Pose", gs); GUI.color = Color.white; } EditorGUILayout.EndHorizontal(); } GUILayout.EndVertical(); } else { GUILayout.BeginVertical(GUILayout.MaxWidth(5)); GUILayout.Space(2); GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.MaxWidth(5)); GUILayout.Space(2); GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.MinWidth(80)); GUILayout.Space(0); Color c = NodeColor(posenode); c.a = 0.25f; GUI.color = c; GUIStyle gs = new GUIStyle(); gs.normal.textColor = Color.white; gs.alignment = TextAnchor.LowerRight; GUILayout.Label("<Empty>", gs); GUI.color = Color.white; GUILayout.Space(1); GUILayout.EndVertical(); } if (!(posenode is FinalPose)) { GUILayout.Space(-13); GUILayout.BeginVertical(); GUILayout.Space(-21); GUI.color = NodeColor(posenode); if (!posenodeOutputs[windowID]) { GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.2f); } if (posenode == dragPoseSlotExcludeNode) { GUI.color = Color.clear; } GUILayout.Label(posenodeOutputs[windowID] ? cfwindow.texOutputSlotActive : cfwindow.texOutputSlot); GUI.color = Color.white; GUILayout.EndVertical(); GUILayout.Space(-7); } else { GUILayout.BeginVertical(); GUILayout.EndVertical(); } GUILayout.EndHorizontal(); if (dragPoseSlotExcludeNode != posenode) { GUI.DragWindow(); } }