public override void OnInspectorGUI() { serializedObject.UpdateIfRequiredOrScript(); Editor.DrawPropertiesExcluding(serializedObject, "m_Script"); GUI.enabled = (constraints.Actor != null && constraints.Actor.Initialized); GUILayout.BeginHorizontal(); if (GUILayout.Button("Generate Tethers")) { if (constraints.Actor != null) { Undo.RegisterCompleteObjectUndo(constraints, "Generate tethers"); constraints.RemoveFromSolver(null); if (!constraints.Actor.GenerateTethers(tetherType)) { Debug.LogWarning("Could not generate tethers. Make sure the actor has been properly initialized."); } constraints.AddToSolver(null); } } if (constraints.Actor is ObiRope) { tetherType = (ObiActor.TetherType)EditorGUILayout.EnumPopup(tetherType); } GUILayout.EndHorizontal(); if (GUILayout.Button("Clear Tethers")) { if (constraints.Actor != null) { if (EditorUtility.DisplayDialog("Clear tethers", "Are you sure you want to remove all tethers?", "Ok", "Cancel")) { Undo.RegisterCompleteObjectUndo(constraints, "Clear tethers"); constraints.RemoveFromSolver(null); constraints.Actor.ClearTethers(); constraints.AddToSolver(null); } } } GUI.enabled = true; // Apply changes to the serializedProperty if (GUI.changed) { serializedObject.ApplyModifiedProperties(); constraints.PushDataToSolver(); } }
public override void OnInspectorGUI() { serializedObject.UpdateIfDirtyOrScript(); Editor.DrawPropertiesExcluding(serializedObject, "m_Script"); GUI.enabled = (constraints.Actor != null && constraints.Actor.Initialized); if (GUILayout.Button("Generate Tether Constraints")) { if (constraints.Actor != null) { Undo.RegisterCompleteObjectUndo(constraints, "Generate tethers"); constraints.RemoveFromSolver(null); if (!constraints.Actor.GenerateTethers(constraints.Actor.MaxTethers)) { Debug.LogWarning("Could not generate tethers. Make sure the actor has been properly initialized."); } constraints.AddToSolver(null); EditorUtility.SetDirty(constraints); } } GUI.enabled = true; // Apply changes to the serializedProperty if (GUI.changed) { serializedObject.ApplyModifiedProperties(); constraints.PushDataToSolver(new ObiSolverData(ObiSolverData.TetherConstraintsData.ALL)); } }