public override void OnInspectorGUI() { serializedObject.Update(); TxEditor.LookLikeControls(); bool isPlaying = Application.isPlaying; GUI.enabled = true && !isPlaying; EditorGUILayout.PropertyField(collision); EditorGUI.indentLevel++; switch (collision.enumValueIndex) { case 1: EditorGUILayout.PropertyField(mesh); break; case 2: EditorGUILayout.PropertyField(terrain); break; case 3: EditorGUILayout.PropertyField(mesh); break; case 4: EditorGUILayout.PropertyField(shapeCenter, new GUIContent("Box Center")); EditorGUILayout.PropertyField(shapeSize, new GUIContent("Box Size")); break; case 5: EditorGUILayout.PropertyField(shapeCenter, new GUIContent("Capsule Center")); EditorGUILayout.PropertyField(shapeSize.FindPropertyRelative("x"), new GUIContent("Capsule Radius")); EditorGUILayout.PropertyField(shapeSize.FindPropertyRelative("y"), new GUIContent("Capsule Height")); EditorGUILayout.IntPopup(capsuleDirection, new GUIContent[] { new GUIContent("X-Axis"), new GUIContent("Y-Axis"), new GUIContent("Z-Axis") }, new int[] { 0, 1, 2 }); break; case 6: EditorGUILayout.PropertyField(shapeCenter, new GUIContent("Sphere Center")); EditorGUILayout.PropertyField(shapeSize.FindPropertyRelative("x"), new GUIContent("Sphere Radius")); break; } EditorGUI.indentLevel--; EditorGUI.indentLevel++; GUI.enabled = (collision.enumValueIndex > 0) && !isPlaying; EditorGUILayout.PropertyField(margin); EditorGUILayout.PropertyField(matters, true); EditorGUI.indentLevel--; SpawnEnabledUI(); BodyGroupUI(); if (GUI.changed) { serializedObject.ApplyModifiedProperties(); } }
public override void OnInspectorGUI() { serializedObject.Update(); TxEditor.LookLikeControls(); EditorGUILayout.LabelField("Use Soft Body inspector Edit button to open Truss Designer"); if (GUI.changed) { serializedObject.ApplyModifiedProperties(); } }
public override void OnInspectorGUI() { serializedObject.Update(); TxEditor.LookLikeControls(); EditorGUILayout.PropertyField(staticFriction); EditorGUILayout.PropertyField(slidingFriction); if (GUI.changed) { serializedObject.ApplyModifiedProperties(); } }
public override void OnInspectorGUI() { serializedObject.Update(); TxEditor.LookLikeControls(); EditorGUILayout.LabelField("Simulation"); EditorGUI.indentLevel++; //EditorGUILayout.PropertyField(simulationStep); EditorGUILayout.PropertyField(substepPower); GUI.enabled = false; EditorGUILayout.IntField("Substep Count", 1 << substepPower.intValue); EditorGUILayout.FloatField("Substep Size", Time.fixedDeltaTime / (1 << substepPower.intValue)); GUI.enabled = true; EditorGUILayout.PropertyField(solverIterations); EditorGUI.indentLevel--; EditorGUILayout.Separator(); EditorGUILayout.LabelField("Environment"); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(globalGravity); EditorGUILayout.PropertyField(globalPressure); EditorGUI.indentLevel--; EditorGUILayout.Separator(); EditorGUILayout.LabelField("Optimization"); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(workerThreads); EditorGUI.indentLevel--; EditorGUILayout.Separator(); EditorGUILayout.Separator(); if (GUILayout.Button("Remove Scene Settings")) { EditorApplication.delayCall += () => Undo.DestroyObjectImmediate(m_targets[0].gameObject); } if (GUI.changed) { serializedObject.ApplyModifiedProperties(); } }
protected virtual void OnEnable() { m_targets = new TxSceneSettings[targets.Length]; for (int i = 0; i < targets.Length; ++i) { m_targets[i] = (TxSceneSettings)targets[i]; } //simulationStep = serializedObject.FindProperty("m_simulationStep"); substepPower = serializedObject.FindProperty("m_substepPower"); solverIterations = serializedObject.FindProperty("m_solverIterations"); globalGravity = serializedObject.FindProperty("m_globalGravity"); globalPressure = serializedObject.FindProperty("m_globalPressure"); workerThreads = serializedObject.FindProperty("m_workerThreads"); TxEditor.HideHandles(true); }
public override void OnInspectorGUI() { serializedObject.Update(); TxEditor.LookLikeControls(); bool isPlaying = Application.isPlaying; GUI.enabled = true && !isPlaying; EditorGUILayout.PropertyField(baseBody); EditorGUILayout.PropertyField(disableCollision); if (m_targets.Length > 1) { GUI.enabled = false; EditorGUILayout.LabelField("Select single body to edit snaps"); GUI.enabled = true; } else { TxSoftBody softBodyA = m_targets[0].GetComponent <TxSoftBody>(); TxSoftBody softBodyB = baseBody.objectReferenceValue as TxSoftBody; for (int i = snaps.arraySize - 1; i >= 0; --i) { SerializedProperty snap = snaps.GetArrayElementAtIndex(i); SerializedProperty snapType = snap.FindPropertyRelative("type"); if ((snapType.enumValueIndex == 0 && softBodyB != null) || (snapType.enumValueIndex != 0 && softBodyB == null)) { snaps.DeleteArrayElementAtIndex(i); showSnaps.boolValue = false; } } // GUI.enabled = true && !isPlaying; EditorGUILayout.BeginHorizontal(); showSnaps.boolValue = EditorGUILayout.Foldout(showSnaps.boolValue, "Snap List (" + snaps.arraySize + " Item" + (snaps.arraySize == 1 ? "" : "s") + ")"); if (showSnaps.boolValue) { if (GUILayout.Button("Add", EditorStyles.miniButton, GUILayout.MaxWidth(50))) { snaps.InsertArrayElementAtIndex(0); // Initialize new snap snaps.GetArrayElementAtIndex(0).FindPropertyRelative("type").enumValueIndex = softBodyB != null ? 1 : 0; snaps.GetArrayElementAtIndex(0).FindPropertyRelative("node").stringValue = ""; snaps.GetArrayElementAtIndex(0).FindPropertyRelative("featureB").stringValue = ""; snaps.GetArrayElementAtIndex(0).FindPropertyRelative("minLimit").floatValue = 0; snaps.GetArrayElementAtIndex(0).FindPropertyRelative("maxLimit").floatValue = 0; snaps.GetArrayElementAtIndex(0).FindPropertyRelative("strength").floatValue = Mathf.Infinity; snaps.GetArrayElementAtIndex(0).FindPropertyRelative("master").boolValue = true; snaps.GetArrayElementAtIndex(0).FindPropertyRelative("show").boolValue = true; } } EditorGUILayout.EndHorizontal(); if (showSnaps.boolValue) { EditorGUI.indentLevel++; if (softBodyB != null) { for (int i = 0; i < snaps.arraySize; ++i) { SerializedProperty snap = snaps.GetArrayElementAtIndex(i); SerializedProperty showSnap = snap.FindPropertyRelative("show"); if (showSnap.boolValue) { EditorGUILayout.BeginHorizontal(); showSnap.boolValue = EditorGUILayout.Foldout(showSnap.boolValue, "Snap " + (i + 1)); if (GUILayout.Button("Remove", EditorStyles.miniButton, GUILayout.MaxWidth(50))) { snaps.DeleteArrayElementAtIndex(i); break; } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel++; SerializedProperty node = snap.FindPropertyRelative("node"); string[] nodes = GetNodes(softBodyA); int index = System.Array.IndexOf(nodes, node.stringValue); index = EditorGUILayout.Popup("Node", index, nodes); if (index > -1 && index < nodes.Length) { node.stringValue = nodes[index]; } SerializedProperty snapType = snap.FindPropertyRelative("type"); int selectType = EditorGUILayout.Popup("Snap To", snapType.enumValueIndex - 1, new string[] { "Node", "Edge" }); //EditorGUILayout.PropertyField(snapType, new GUIContent("Snap To")); snapType.enumValueIndex = selectType + 1; switch (snapType.enumValueIndex) { case 1: { SerializedProperty nodeB = snap.FindPropertyRelative("featureB"); string[] nodesB = GetNodes(softBodyB); index = System.Array.IndexOf(nodesB, nodeB.stringValue); index = EditorGUILayout.Popup("Node B", index, nodesB); if (index > -1 && index < nodesB.Length) { nodeB.stringValue = nodesB[index]; } } break; case 2: { SerializedProperty nodeB = snap.FindPropertyRelative("featureB"); string[] nodesB = GetNodes(softBodyB, 2, 2); index = System.Array.IndexOf(nodesB, nodeB.stringValue); index = EditorGUILayout.Popup("Nodes B", index, nodesB); if (index > -1 && index < nodesB.Length) { nodeB.stringValue = nodesB[index]; } } break; } SerializedProperty snapMinLimit = snap.FindPropertyRelative("minLimit"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(snapMinLimit); if (GUILayout.Button("Calc", TxEditor.MiniUnpressedStyle(), GUILayout.MaxWidth(40))) { snapMinLimit.floatValue = CalcSnapDistance(node.stringValue, snap.FindPropertyRelative("featureB").stringValue); } EditorGUILayout.EndHorizontal(); SerializedProperty snapMaxLimit = snap.FindPropertyRelative("maxLimit"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(snapMaxLimit); if (GUILayout.Button("Calc", TxEditor.MiniUnpressedStyle(), GUILayout.MaxWidth(40))) { snapMaxLimit.floatValue = CalcSnapDistance(node.stringValue, snap.FindPropertyRelative("featureB").stringValue); } EditorGUILayout.EndHorizontal(); SerializedProperty snapStrength = snap.FindPropertyRelative("strength"); EditorGUILayout.PropertyField(snapStrength); SerializedProperty snapMaster = snap.FindPropertyRelative("master"); EditorGUILayout.PropertyField(snapMaster); EditorGUI.indentLevel--; } else { SerializedProperty node = snap.FindPropertyRelative("node"); string nodeName = node.stringValue; string targetName = "Point"; SerializedProperty snapType = snap.FindPropertyRelative("type"); if (snapType.enumValueIndex > 0) { SerializedProperty nodeB = snap.FindPropertyRelative("featureB"); targetName = nodeB.stringValue; } showSnap.boolValue = EditorGUILayout.Foldout(showSnap.boolValue, "Snap " + (i + 1) + ": " + nodeName + " - " + targetName); } } } else { for (int i = 0; i < snaps.arraySize; ++i) { SerializedProperty snap = snaps.GetArrayElementAtIndex(i); SerializedProperty showSnap = snap.FindPropertyRelative("show"); if (showSnap.boolValue) { EditorGUILayout.BeginHorizontal(); showSnap.boolValue = EditorGUILayout.Foldout(showSnap.boolValue, "Snap " + (i + 1)); if (GUILayout.Button("Remove", EditorStyles.miniButton, GUILayout.MaxWidth(50))) { snaps.DeleteArrayElementAtIndex(i); break; } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel++; SerializedProperty node = snap.FindPropertyRelative("node"); string[] nodes = GetNodes(softBodyA, 1, 100); int index = System.Array.IndexOf(nodes, node.stringValue); index = EditorGUILayout.Popup("Nodes", index, nodes); if (index > -1 && index < nodes.Length) { node.stringValue = nodes[index]; } //SerializedProperty snapMinLimit = snap.FindPropertyRelative("minLimit"); //EditorGUILayout.BeginHorizontal(); //EditorGUILayout.PropertyField(snapMinLimit); //EditorGUILayout.EndHorizontal(); SerializedProperty snapMaxLimit = snap.FindPropertyRelative("maxLimit"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(snapMaxLimit); EditorGUILayout.EndHorizontal(); SerializedProperty snapStrength = snap.FindPropertyRelative("strength"); EditorGUILayout.PropertyField(snapStrength); SerializedProperty snapMaster = snap.FindPropertyRelative("master"); EditorGUILayout.PropertyField(snapMaster); EditorGUI.indentLevel--; } else { SerializedProperty node = snap.FindPropertyRelative("node"); showSnap.boolValue = EditorGUILayout.Foldout(showSnap.boolValue, "Snap " + (i + 1) + ": " + node.stringValue); } } } EditorGUI.indentLevel--; } } EditorGUILayout.Separator(); EditorGUILayout.PropertyField(enableMotor); EditorGUI.indentLevel++; if (m_targets.Length == 1) { GUI.enabled = true && !isPlaying; string[] axisNodes = GetNodes(m_targets[0].GetComponent <TxSoftBody>(), 2, 2); int index = System.Array.IndexOf(axisNodes, axisNodeSet.stringValue); index = EditorGUILayout.Popup("Axis Nodes", index, axisNodes); if (index > -1 && index < axisNodes.Length) { axisNodeSet.stringValue = axisNodes[index]; } } else { GUI.enabled = false; string[] empty = { }; EditorGUILayout.Popup("Axis Nodes", -1, empty); GUI.enabled = true; } GUI.enabled = true; EditorGUILayout.PropertyField(targetRate); EditorGUILayout.PropertyField(maxTorque); EditorGUI.indentLevel--; if (GUI.changed) { serializedObject.ApplyModifiedProperties(); } }
public override void OnInspectorGUI() { serializedObject.Update(); TxEditor.LookLikeControls(); bool isPlaying = Application.isPlaying; GUI.enabled = true && !isPlaying; EditorGUILayout.PropertyField(massScale); bool sameMass = true; for (int i = 1; i < m_targets.Length; ++i) { if (m_targets[i].mass != m_targets[i - 1].mass) { sameMass = false; break; } } if (sameMass) { GUI.enabled = false; EditorGUILayout.FloatField("Scaled Mass", m_targets[0].mass); } else { GUI.enabled = false; EditorGUILayout.TextField("Scaled Mass", "-"); } GUI.enabled = true && !isPlaying; EditorGUILayout.PropertyField(collision); EditorGUI.indentLevel++; switch (collision.enumValueIndex) { case 1: EditorGUILayout.PropertyField(mesh); break; case 2: EditorGUILayout.PropertyField(mesh); break; case 3: EditorGUILayout.PropertyField(shapeCenter, new GUIContent("Box Center")); EditorGUILayout.PropertyField(shapeSize, new GUIContent("Box Size")); break; case 4: EditorGUILayout.PropertyField(shapeCenter); EditorGUILayout.PropertyField(shapeSize.FindPropertyRelative("x"), new GUIContent("Capsule Radius")); EditorGUILayout.PropertyField(shapeSize.FindPropertyRelative("y"), new GUIContent("Capsule Height")); EditorGUILayout.IntPopup(capsuleDirection, new GUIContent[] { new GUIContent("X-Axis"), new GUIContent("Y-Axis"), new GUIContent("Z-Axis") }, new int[] { 0, 1, 2 }); break; case 5: EditorGUILayout.PropertyField(shapeCenter); EditorGUILayout.PropertyField(shapeSize.FindPropertyRelative("x"), new GUIContent("Sphere Radius")); break; } EditorGUI.indentLevel--; EditorGUI.indentLevel++; GUI.enabled = (collision.enumValueIndex > 0) && !isPlaying; EditorGUILayout.PropertyField(margin); EditorGUILayout.PropertyField(matters, true); EditorGUI.indentLevel--; SpawnEnabledUI(); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(spawnActive); EditorGUI.indentLevel--; GUI.enabled = true; EditorGUILayout.PropertyField(deactivation); EditorGUI.indentLevel++; GUI.enabled = deactivation.boolValue; EditorGUILayout.PropertyField(deactivationSpeed, new GUIContent("Speed")); EditorGUILayout.PropertyField(deactivationTime, new GUIContent("Time")); EditorGUI.indentLevel--; BodyGroupUI(); GUI.enabled = true && !isPlaying; EditorGUILayout.PropertyField(interaction); if (GUI.changed) { serializedObject.ApplyModifiedProperties(); } }
void OnDisable() { TxEditor.HideHandles(false); }
public override void OnInspectorGUI() { serializedObject.Update(); TxEditor.LookLikeControls(); bool isPlaying = Application.isPlaying; TxTrussDesigner trussDesigner = m_targets[0].GetComponent <TxTrussDesigner>(); GUI.enabled = (trussDesigner == null && !Application.isPlaying) && !isPlaying; EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(truss); GUI.enabled = (truss.objectReferenceValue != null && !Application.isPlaying); if (GUILayout.Button("Edit", (trussDesigner != null) ? TxEditor.MiniPressedStyle() : TxEditor.MiniUnpressedStyle(), GUILayout.MaxWidth(40))) { if (trussDesigner) { EditorApplication.delayCall += () => Undo.DestroyObjectImmediate(trussDesigner); } else { Undo.AddComponent <TxTrussDesigner>(m_targets[0].gameObject); } } EditorGUILayout.EndHorizontal(); GUI.enabled = true; EditorGUILayout.PropertyField(massScale); if (truss.objectReferenceValue == null || truss.hasMultipleDifferentValues || massScale.hasMultipleDifferentValues) { GUI.enabled = false; EditorGUILayout.TextField("Scaled Mass", "-"); } else { TxTruss trussAsset = truss.objectReferenceValue as TxTruss; if (trussAsset != null) { float scaledMass = 0; foreach (var m in trussAsset.nodeMass) { scaledMass += m; } GUI.enabled = false; EditorGUILayout.FloatField("Scaled Mass", scaledMass * massScale.floatValue); } } GUI.enabled = true && !isPlaying; EditorGUILayout.PropertyField(collision); EditorGUI.indentLevel++; GUI.enabled = collision.boolValue && !isPlaying; EditorGUILayout.PropertyField(margin); EditorGUILayout.PropertyField(matters, true); EditorGUI.indentLevel--; BodyGroupUI(); GUI.enabled = true && !isPlaying; EditorGUILayout.PropertyField(skinning); GUI.enabled = true && !isPlaying; SpawnEnabledUI(); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(spawnActive); EditorGUI.indentLevel--; GUI.enabled = true; EditorGUILayout.PropertyField(deactivation); EditorGUI.indentLevel++; GUI.enabled = deactivation.boolValue; EditorGUILayout.PropertyField(deactivationSpeed, new GUIContent("Speed")); EditorGUILayout.PropertyField(deactivationTime, new GUIContent("Time")); EditorGUI.indentLevel--; GUI.enabled = true; EditorGUILayout.PropertyField(filling); EditorGUI.indentLevel++; GUI.enabled = filling.boolValue; EditorGUILayout.PropertyField(internalPressure); EditorGUILayout.PropertyField(adiabaticIndex); EditorGUI.indentLevel--; if (GUI.changed) { serializedObject.ApplyModifiedProperties(); } }