public static Constraint.ECollisionsState ConstraintCollisionsStateGUI(Constraint.ECollisionsState state, GUISkin skin) { bool guiWasEnabled = UnityEngine.GUI.enabled; using (new GUI.Indent(12)) { GUILayout.BeginHorizontal(); { GUILayout.Label(GUI.MakeLabel("Disable collisions: ", true), GUI.Align(skin.label, TextAnchor.MiddleLeft), new GUILayoutOption[] { GUILayout.Width(140), GUILayout.Height(25) }); UnityEngine.GUI.enabled = !EditorApplication.isPlaying; if (GUILayout.Button(GUI.MakeLabel("Rb " + GUI.Symbols.Synchronized.ToString() + " Rb", false, "Disable all shapes in rigid body 1 against all shapes in rigid body 2."), GUI.ConditionalCreateSelectedStyle(state == Constraint.ECollisionsState.DisableRigidBody1VsRigidBody2, skin.button), new GUILayoutOption[] { GUILayout.Width(76), GUILayout.Height(25) })) { state = state == Constraint.ECollisionsState.DisableRigidBody1VsRigidBody2 ? Constraint.ECollisionsState.KeepExternalState : Constraint.ECollisionsState.DisableRigidBody1VsRigidBody2; } if (GUILayout.Button(GUI.MakeLabel("Ref " + GUI.Symbols.Synchronized.ToString() + " Con", false, "Disable Reference object vs. Connected object."), GUI.ConditionalCreateSelectedStyle(state == Constraint.ECollisionsState.DisableReferenceVsConnected, skin.button), new GUILayoutOption[] { GUILayout.Width(76), GUILayout.Height(25) })) { state = state == Constraint.ECollisionsState.DisableReferenceVsConnected ? Constraint.ECollisionsState.KeepExternalState : Constraint.ECollisionsState.DisableReferenceVsConnected; } UnityEngine.GUI.enabled = guiWasEnabled; } GUILayout.EndHorizontal(); } return(state); }
public override void OnPreTargetMembersGUI(GUISkin skin) { // Possible undo performed that deleted the constraint. Remove us. if (Constraint == null) { PerformRemoveFromParent(); return; } GUILayout.Label(GUI.MakeLabel(Constraint.Type.ToString(), 24, true), GUI.Align(skin.label, TextAnchor.MiddleCenter)); GUI.Separator(); // Render AttachmentPair GUI. base.OnPreTargetMembersGUI(skin); GUI.Separator(); Constraint.CollisionsState = ConstraintCollisionsStateGUI(Constraint.CollisionsState, skin); Constraint.SolveType = ConstraintSolveTypeGUI(Constraint.SolveType, skin); GUI.Separator(); Constraint.ConnectedFrameNativeSyncEnabled = ConstraintConnectedFrameSyncGUI(Constraint.ConnectedFrameNativeSyncEnabled, skin); GUI.Separator(); ConstraintRowsGUI(skin); }
public override void OnPreTargetMembersGUI(GUISkin skin) { GUILayout.Label(GUI.MakeLabel("Debug render manager", 16, true), GUI.Align(skin.label, TextAnchor.MiddleCenter)); GUI.Separator(); Manager.RenderShapes = GUI.Toggle(GUI.MakeLabel("Debug render shapes"), Manager.RenderShapes, skin.button, skin.label); GUI.MaterialEditor(GUI.MakeLabel("Shape material"), 100, Manager.ShapeRenderMaterial, skin, newMaterial => Manager.ShapeRenderMaterial = newMaterial, true); GUI.Separator(); using (new GUILayout.HorizontalScope()) { Manager.RenderContacts = GUI.Toggle(GUI.MakeLabel("Render contacts"), Manager.RenderContacts, skin.button, skin.label); Manager.ContactColor = EditorGUILayout.ColorField(Manager.ContactColor); } Manager.ContactScale = EditorGUILayout.Slider(GUI.MakeLabel("Scale"), Manager.ContactScale, 0.0f, 1.0f); GUI.Separator(); Manager.ColorizeBodies = GUI.Toggle(GUI.MakeLabel("Colorize bodies", false, "Every rigid body instance will be rendered with a unique color (wire framed)."), Manager.ColorizeBodies, skin.button, skin.label); Manager.HighlightMouseOverObject = GUI.Toggle(GUI.MakeLabel("Highlight mouse over object", false, "Highlight mouse over object in scene view."), Manager.HighlightMouseOverObject, skin.button, skin.label); Manager.IncludeInBuild = GUI.Toggle(GUI.MakeLabel("Include in build", false, "Include debug rendering when building the project."), Manager.IncludeInBuild, skin.button, skin.label); }
private void HandleKeyHandlerGUI(GUIContent name, Utils.KeyHandler keyHandler, GUISkin skin) { const int keyButtonWidth = 90; const int keyButtonHeight = 18; GUILayout.BeginHorizontal(); { keyHandler.Enable = GUI.Toggle(name, keyHandler.Enable, skin.button, GUI.Align(skin.label, TextAnchor.MiddleLeft), new GUILayoutOption[] { GUILayout.Width(keyButtonHeight), GUILayout.Height(keyButtonHeight) }, new GUILayoutOption[] { GUILayout.Height(keyButtonHeight) }); GUILayout.FlexibleSpace(); UnityEngine.GUI.enabled = keyHandler.Enable; for (int iKey = 0; iKey < keyHandler.NumKeyCodes; ++iKey) { GUIContent buttonLabel = keyHandler.IsDetectingKey(iKey) ? GUI.MakeLabel("Detecting...") : GUI.MakeLabel(keyHandler.Keys[iKey].ToString()); bool toggleDetecting = GUILayout.Button(buttonLabel, skin.button, GUILayout.Width(keyButtonWidth), GUILayout.Height(keyButtonHeight)); if (toggleDetecting) { keyHandler.DetectKey(this, !keyHandler.IsDetectingKey(iKey), iKey); } } Rect dropDownButtonRect = new Rect(); GUILayout.BeginVertical(GUILayout.Height(keyButtonHeight)); { GUIStyle tmp = new GUIStyle(skin.button); tmp.fontSize = 6; m_showDropDown = GUILayout.Button(GUI.MakeLabel("v", true), tmp, GUILayout.Width(16), GUILayout.Height(14)) ? !m_showDropDown : m_showDropDown; dropDownButtonRect = GUILayoutUtility.GetLastRect(); GUILayout.FlexibleSpace(); } GUILayout.EndVertical(); UnityEngine.GUI.enabled = true; if (m_showDropDown && dropDownButtonRect.Contains(Event.current.mousePosition)) { GenericMenu menu = new GenericMenu(); menu.AddItem(GUI.MakeLabel("Reset to default"), false, () => { if (EditorUtility.DisplayDialog("Reset to default", "Reset key(s) to default?", "OK", "Cancel")) { keyHandler.ResetToDefault(); } }); menu.AddItem(GUI.MakeLabel("Add key"), false, () => { keyHandler.Add(KeyCode.None); }); if (keyHandler.NumKeyCodes > 1) { menu.AddItem(GUI.MakeLabel("Remove key"), false, () => { if (EditorUtility.DisplayDialog("Remove key", "Remove key: " + keyHandler[keyHandler.NumKeyCodes - 1].ToString() + "?", "OK", "Cancel")) { keyHandler.Remove(keyHandler.NumKeyCodes - 1); } }); } menu.ShowAsContext(); } } GUILayout.EndHorizontal(); if (UnityEngine.GUI.changed) { EditorUtility.SetDirty(this); } }
public void OnInspectorGUI(GUISkin skin) { using (GUI.AlignBlock.Center) GUILayout.Label(GUI.MakeLabel("AgXUnity Editor Settings", 24, true), skin.label); GUI.Separator3D(); // BuiltInToolsTool settings GUI. { using (GUI.AlignBlock.Center) GUILayout.Label(GUI.MakeLabel("Built in tools", 16, true), skin.label); //GUI.Separator(); HandleKeyHandlerGUI(GUI.MakeLabel("Select game object"), BuiltInToolsTool_SelectGameObjectKeyHandler, skin); HandleKeyHandlerGUI(GUI.MakeLabel("Select rigid body game object"), BuiltInToolsTool_SelectRigidBodyKeyHandler, skin); HandleKeyHandlerGUI(GUI.MakeLabel("Pick handler (scene view)"), BuiltInToolsTool_PickHandlerKeyHandler, skin); GUI.Separator(); } // Developer settings. { using (GUI.AlignBlock.Center) GUILayout.Label(GUI.MakeLabel("AGXUnity Developer", 16, true), skin.label); AutoFetchAGXUnityDlls = GUI.Toggle(GUI.MakeLabel("Auto fetch AGXUnity/AGXUnityEditor"), AutoFetchAGXUnityDlls, skin.button, GUI.Align(skin.label, TextAnchor.MiddleLeft), new GUILayoutOption[] { GUILayout.Width(ToggleButtonSize), GUILayout.Height(ToggleButtonSize) }, new GUILayoutOption[] { GUILayout.Height(ToggleButtonSize) }); using (new EditorGUI.DisabledScope(!AutoFetchAGXUnityDlls)) { using (new GUILayout.HorizontalScope()) { GUILayout.Space(ToggleButtonSize + 4); GUILayout.Label(GUI.MakeLabel("Checkout directory"), skin.label, GUILayout.Width(160)); var statusColor = AGXUnityCheckoutDirValid ? Color.Lerp(Color.white, Color.green, 0.2f) : Color.Lerp(Color.white, Color.red, 0.2f); var textFieldStyle = new GUIStyle(skin.textField); var prevColor = UnityEngine.GUI.backgroundColor; UnityEngine.GUI.backgroundColor = statusColor; AGXUnityCheckoutDir = GUILayout.TextField(AGXUnityCheckoutDir, skin.textField); UnityEngine.GUI.backgroundColor = prevColor; if (GUILayout.Button(GUI.MakeLabel("...", false, "Open file panel"), skin.button, GUILayout.Width(28))) { AGXUnityCheckoutDir = EditorUtility.OpenFolderPanel("AGXUnity checkout directory", AGXUnityCheckoutDir, ""); } } } GUI.Separator(); } GUI.Separator3D(); }
public void OnInspectorGUI(GUISkin skin) { GUILayout.BeginHorizontal(); { GUILayout.Label(GUI.MakeLabel("Disable: ", true), skin.label); GUILayout.Label(SelectGameObjectDropdownMenuTool.GetGUIContent(m_mainObject), skin.textField); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); GUILayout.Label(GUI.MakeLabel(GUI.Symbols.Synchronized.ToString()), skin.label); GUILayout.BeginVertical(); { if (m_selected.Count == 0) { GUILayout.Label(GUI.MakeLabel("None", true), skin.label, GUILayout.Width(180)); } else { int removeIndex = -1; for (int i = 0; i < m_selected.Count; ++i) { GUILayout.BeginHorizontal(); { GUILayout.Label(SelectGameObjectDropdownMenuTool.GetGUIContent(m_selected[i]), GUI.Align(skin.textField, TextAnchor.MiddleLeft), GUILayout.Height(20)); using (GUI.NodeListButtonColor) if (GUILayout.Button(GUI.MakeLabel(GUI.Symbols.ListEraseElement.ToString()), skin.button, GUILayout.Width(18), GUILayout.Height(18))) { removeIndex = i; } } GUILayout.EndHorizontal(); } if (removeIndex >= 0) { m_selected.RemoveAt(removeIndex); } } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); GUILayout.Space(12); bool applyPressed = false; bool cancelPressed = false; GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); UnityEngine.GUI.enabled = m_selected.Count > 0; applyPressed = GUILayout.Button(GUI.MakeLabel("Apply", true, "Apply current configuration"), skin.button, GUILayout.Width(86), GUILayout.Height(26)); UnityEngine.GUI.enabled = true; GUILayout.BeginVertical(); { GUILayout.Space(11); cancelPressed = GUILayout.Button(GUI.MakeLabel("Cancel", false, "Cancel/reset"), skin.button, GUILayout.Width(64), GUILayout.Height(18)); } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); if (applyPressed) { string selectedGroupName = m_mainObject.GetInstanceID().ToString(); string mainObjectGroupName = ""; for (int i = 0; i < m_selected.Count; ++i) { mainObjectGroupName += m_selected[i].GetInstanceID().ToString() + (i != m_selected.Count - 1 ? "_" : ""); } m_mainObject.GetOrCreateComponent <CollisionGroups>().AddGroup(mainObjectGroupName, ShouldPropagateToChildren(m_mainObject)); foreach (var selected in m_selected) { selected.GetOrCreateComponent <CollisionGroups>().AddGroup(selectedGroupName, ShouldPropagateToChildren(selected)); } CollisionGroupsManager.Instance.SetEnablePair(mainObjectGroupName, selectedGroupName, false); PerformRemoveFromParent(); } else if (cancelPressed) { PerformRemoveFromParent(); } }