public override void OnPostTargetMembersGUI() { if (NumTargets != 1) { return; } using (new GUI.EnabledBlock(!EditorApplication.isPlayingOrWillChangePlaymode)) { Undo.RecordObject(Sink, "Sink template"); var sinkAll = InspectorGUI.Toggle(GUI.MakeLabel("Sink All"), Sink.SinkAll); if (sinkAll != Sink.SinkAll) { Sink.SinkAll = sinkAll; } if (!Sink.SinkAll) { InspectorGUI.ToolListGUI(this, Sink.Templates, "Sink Templates", m_availableTemplates, OnTemplateAdd, OnTemplateRemove); } } }
private Action <ContactMaterial, int> PreContactMaterialEditor(ContactMaterialEntry[] entries) { return((cm, index) => { using (InspectorGUI.IndentScope.Single) { entries[index].IsOriented = InspectorGUI.Toggle(GUI.MakeLabel("Is Oriented", false, "Enable/disable oriented friction models."), entries[index].IsOriented); if (entries[index].IsOriented) { using (InspectorGUI.IndentScope.Single) { entries[index].ReferenceObject = (GameObject)EditorGUILayout.ObjectField(GUI.MakeLabel("Reference Object"), entries[index].ReferenceObject, typeof(GameObject), true); entries[index].PrimaryDirection = (FrictionModel.PrimaryDirection)EditorGUILayout.EnumPopup(GUI.MakeLabel("Primary Direction", false, "Primary direction in object local frame."), entries[index].PrimaryDirection, InspectorEditor.Skin.Popup); } } } }); }
private void OnShapeConfigGUI(bool hasRadius) { using (InspectorGUI.IndentScope.Create(2)) { State.ShapeAsParent = InspectorGUI.Toggle(GUI.MakeLabel("Shape as parent"), State.ShapeAsParent); if (hasRadius) { State.ExpandRadius = InspectorGUI.Toggle(GUI.MakeLabel("Expand radius"), State.ExpandRadius); } } }
public override void OnPostTargetMembersGUI() { if (FrictionModel.Type != FrictionModel.EType.ConstantNormalForceBoxFriction) { return; } EditorGUI.showMixedValue = ShowMixed((fm1, fm2) => !AGXUnity.Utils.Math.Approximately(fm1.NormalForceMagnitude, fm2.NormalForceMagnitude)); var normalForce = Mathf.Max(EditorGUILayout.FloatField(GUI.MakeLabel("Normal Force Magnitude"), FrictionModel.NormalForceMagnitude), 0.0f); if (UnityEngine.GUI.changed) { foreach (var fm in GetTargets <FrictionModel>()) { fm.NormalForceMagnitude = normalForce; } } UnityEngine.GUI.changed = false; EditorGUI.showMixedValue = ShowMixed((fm1, fm2) => fm1.ScaleNormalForceWithDepth != fm2.ScaleNormalForceWithDepth); var scaleNormalForceWithDepth = InspectorGUI.Toggle(GUI.MakeLabel("Scale Normal Force With Depth"), FrictionModel.ScaleNormalForceWithDepth); if (UnityEngine.GUI.changed) { foreach (var fm in GetTargets <FrictionModel>()) { fm.ScaleNormalForceWithDepth = scaleNormalForceWithDepth; } } EditorGUI.showMixedValue = false; UnityEngine.GUI.changed = false; }
public override void OnPreTargetMembersGUI() { var skin = InspectorEditor.Skin; GUILayout.Label(GUI.MakeLabel("Debug render manager", 16, true), skin.LabelMiddleCenter); var newRenderState = InspectorGUI.Toggle(GUI.MakeLabel("Debug render shapes"), Manager.RenderShapes); if (newRenderState != Manager.RenderShapes) { Manager.RenderShapes = newRenderState; EditorUtility.SetDirty(Manager); } InspectorGUI.UnityMaterial(GUI.MakeLabel("Shape material"), Manager.ShapeRenderMaterial, newMaterial => Manager.ShapeRenderMaterial = newMaterial); using (new GUILayout.HorizontalScope()) { Manager.RenderContacts = InspectorGUI.Toggle(GUI.MakeLabel("Render contacts"), Manager.RenderContacts); Manager.ContactColor = EditorGUILayout.ColorField(Manager.ContactColor); } Manager.ContactScale = EditorGUILayout.Slider(GUI.MakeLabel("Scale"), Manager.ContactScale, 0.0f, 1.0f); Manager.ColorizeBodies = InspectorGUI.Toggle(GUI.MakeLabel("Colorize bodies", false, "Every rigid body instance will be rendered with a unique color (wire framed)."), Manager.ColorizeBodies); Manager.HighlightMouseOverObject = InspectorGUI.Toggle(GUI.MakeLabel("Highlight mouse over object", false, "Highlight mouse over object in scene view."), Manager.HighlightMouseOverObject); Manager.IncludeInBuild = InspectorGUI.Toggle(GUI.MakeLabel("Include in build", false, "Include debug rendering when building the project."), Manager.IncludeInBuild); }
public static bool ConstraintConnectedFrameSyncGUI(bool enabled) { enabled = InspectorGUI.Toggle(GUI.MakeLabel("Connected Frame Animated", true), !EditorGUI.showMixedValue && enabled); return(enabled); }
public void OnInspectorGUI() { if (AttachmentFrameTool == null || AttachmentFrameTool.AttachmentPairs[0] == null) { PerformRemoveFromParent(); return; } InspectorGUI.OnDropdownToolBegin("Create constraint given type and use additional tools to " + "configure the constraint frames."); var skin = InspectorEditor.Skin; m_createConstraintData.Name = EditorGUILayout.TextField(GUI.MakeLabel("Name", true), m_createConstraintData.Name, skin.TextField); #if UNITY_2018_1_OR_NEWER m_createConstraintData.ConstraintType = (ConstraintType)EditorGUILayout.EnumPopup(GUI.MakeLabel("Type", true), m_createConstraintData.ConstraintType, val => (ConstraintType)val != ConstraintType.Unknown, false, skin.Popup); #else m_createConstraintData.ConstraintType = (ConstraintType)EditorGUILayout.EnumPopup(GUI.MakeLabel("Type", true), m_createConstraintData.ConstraintType, skin.Popup); #endif AttachmentFrameTool.OnPreTargetMembersGUI(); AttachmentFrameTool.AttachmentPairs[0].Synchronize(); m_createConstraintData.CollisionState = ConstraintTool.ConstraintCollisionsStateGUI(m_createConstraintData.CollisionState); m_createConstraintData.SolveType = ConstraintTool.ConstraintSolveTypeGUI(m_createConstraintData.SolveType); if (Parent != null) { MakeConstraintChildToParent = InspectorGUI.Toggle(GUI.MakeLabel($"Create as child", true, $"Add the created constraint game object as child " + $"to \"{Parent.name}\". If false, the game object is " + $"created without a parent or under the prefab root if " + $"created inside a prefab stage."), MakeConstraintChildToParent); } var createCancelState = InspectorGUI.PositiveNegativeButtons(m_createConstraintData.AttachmentPair.ReferenceObject != null && m_createConstraintData.AttachmentPair.ReferenceObject.GetComponentInParent <RigidBody>() != null, "Create", "Create the constraint", "Cancel"); if (createCancelState == InspectorGUI.PositiveNegativeResult.Positive) { GameObject constraintGameObject = Factory.Create(m_createConstraintData.ConstraintType, m_createConstraintData.AttachmentPair); Constraint constraint = constraintGameObject.GetComponent <Constraint>(); constraintGameObject.name = m_createConstraintData.Name; constraint.CollisionsState = m_createConstraintData.CollisionState; if (MakeConstraintChildToParent) { constraintGameObject.transform.SetParent(Parent.transform); } else { // If we're in the Prefab Stage this call will add the constraint // game object as child of the root prefab. UnityEditor.SceneManagement.StageUtility.PlaceGameObjectInCurrentStage(constraintGameObject); } Undo.RegisterCreatedObjectUndo(constraintGameObject, "New constraint '" + constraintGameObject.name + "' created"); m_onCreate?.Invoke(constraint); m_createConstraintData.Reset(); } if (createCancelState != InspectorGUI.PositiveNegativeResult.Neutral) { PerformRemoveFromParent(); } InspectorGUI.OnDropdownToolEnd(); }
public override void OnPostTargetMembersGUI() { var skin = InspectorEditor.Skin; Simulation.DisplayStatistics = InspectorGUI.Toggle(GUI.MakeLabel("Display Statistics"), Simulation.DisplayStatistics); if (Simulation.DisplayStatistics) { using (InspectorGUI.IndentScope.Single) Simulation.DisplayMemoryAllocations = InspectorGUI.Toggle(GUI.MakeLabel("Display Memory Allocations"), Simulation.DisplayMemoryAllocations); } InspectorGUI.Separator(1, 4); using (new GUI.EnabledBlock(Application.isPlaying)) { #if AGXUNITY_DEV_BUILD if (GUILayout.Button(GUI.MakeLabel("Save current step as (.agx)...", false, "Save scene in native file format when the editor is in play mode."), skin.Button)) { saveCurrentState(); } if (GUILayout.Button(GUI.MakeLabel("Open in AGX native viewer", false, "Creates Lua file, saves current scene to an .agx file and executes luaagx.exe."), skin.Button)) { Simulation.OpenInNativeViewer(); } #endif var rect = EditorGUILayout.GetControlRect(); var orgWidth = rect.width; rect.width = EditorGUIUtility.labelWidth; EditorGUI.PrefixLabel(rect, GUI.MakeLabel("Save current step as (.agx)"), skin.Label); rect.x += EditorGUIUtility.labelWidth; rect.width = orgWidth - EditorGUIUtility.labelWidth; if (UnityEngine.GUI.Button(rect, GUI.MakeLabel("Output file..."), skin.Button)) { string result = EditorUtility.SaveFilePanel("Save scene as .agx", "Assets", UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name, "agx"); if (result != string.Empty) { var success = Simulation.SaveToNativeFile(result); if (success) { Debug.Log(GUI.AddColorTag("Successfully wrote simulation to file: ", Color.green) + result); } } } } Simulation.SavePreFirstStepPath = InspectorGUI.ToggleSaveFile(GUI.MakeLabel("Dump initial (.agx)"), Simulation.SavePreFirstStep, enabled => Simulation.SavePreFirstStep = enabled, Simulation.SavePreFirstStepPath, UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name, "agx", "Path to initial dump (including file name and extension)", fileExtension => fileExtension == ".agx" || fileExtension == ".aagx"); #if AGXUNITY_DEV_ENV using (new GUI.EnabledBlock(EditorApplication.isPlaying)) { var rect = EditorGUILayout.GetControlRect(); rect.x += EditorGUIUtility.labelWidth; rect.width -= EditorGUIUtility.labelWidth; if (UnityEngine.GUI.Button(rect, GUI.MakeLabel("Open in native viewer..."), skin.Button)) { ; } } #endif }