public override void OnInspectorGUI() { AngleConstraintMB mb = (AngleConstraintMB)target; mb.enabled = EditorGUILayout.Toggle("Enabled", mb.enabled); EditorGUI.BeginChangeCheck(); mb.nextJoint = EditorGUILayout.ObjectField("nextJoint", mb.nextJoint, typeof(Transform), true) as Transform; if (EditorGUI.EndChangeCheck()) { EUtil.SetDirty(mb); EUtil.RepaintSceneView(); } if (mb.nextJoint == null) { EditorGUILayout.LabelField("Set the nextJoint first..."); return; } else { EUtil.PushGUIEnable(mb.enabled); GUILayout.BeginHorizontal(); { GUILayout.Space(30f); if (EUtil.Button("ReInit", "decide all the parameters with default method", Color.green)) { Undo.RecordObject(mb, "ReInit"); mb.AutoSetParameters(); EUtil.SetDirty(mb); EUtil.RepaintSceneView(); } GUILayout.Space(30f); } GUILayout.EndHorizontal(); // min/max limit float min = mb.minLimit; float max = mb.maxLimit; EditorGUI.BeginChangeCheck(); EUtil.DrawMinMaxSlider("Angle Limits", ref min, ref max, -180f, 180f); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(mb, "Modify Angle limits"); mb.minLimit = min; mb.maxLimit = max; EUtil.SetDirty(mb); EUtil.RepaintSceneView(); } EditorGUI.BeginChangeCheck(); Vector3 newRotAxis = EUtil.DrawV3P(new GUIContent("Rotation Axis", "in parent space, in world space if no parent joint"), mb.rotAxis); Vector3 newPrimAxis = EUtil.DrawV3P(new GUIContent("Primary Axis", "in parent space, in world space if no parent joint"), mb.primAxis); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(mb, "Modify Constraint parameters"); mb.rotAxis = newRotAxis; mb.primAxis = newPrimAxis; mb.CalcInitData(); //!! recalc the startLocalRot EUtil.SetDirty(mb); EUtil.RepaintSceneView(); } ms_showDisplaySetting = EditorGUILayout.Foldout(ms_showDisplaySetting, "Display Settings:"); if (ms_showDisplaySetting) { EditorGUI.BeginChangeCheck(); ms_markerSize = EditorGUILayout.FloatField("ArcSize", ms_markerSize); ms_arcColor = EditorGUILayout.ColorField("ArcColor", ms_arcColor); if (EditorGUI.EndChangeCheck()) { EUtil.RepaintSceneView(); } } EUtil.PopGUIEnable(); } }
public override void OnInspectorGUI() { ConeConstraintMB mb = (ConeConstraintMB)target; mb.enabled = EditorGUILayout.Toggle("Enabled", mb.enabled); EditorGUI.BeginChangeCheck(); mb.nextJoint = EditorGUILayout.ObjectField("nextJoint", mb.nextJoint, typeof(Transform), true) as Transform; if (EditorGUI.EndChangeCheck()) { EUtil.RepaintSceneView(); } if (mb.nextJoint == null) { EditorGUILayout.LabelField("Set the nextJoint first..."); return; } else { EUtil.PushGUIEnable(mb.enabled); EditorGUILayout.BeginHorizontal(); { GUILayout.Space(30f); if (EUtil.Button("ReInit", "decide all the parameters with default method", Color.green)) { Undo.RecordObject(mb, "AutoInit"); mb._AutoSetParameters(); EUtil.RepaintSceneView(); } GUILayout.Space(30f); } EditorGUILayout.EndHorizontal(); // angle limit EditorGUI.BeginChangeCheck(); float newAngleLimit = EditorGUILayout.Slider(CONT_AngleLimit, mb.angleLimit, 0, 180f); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(mb, "Modify Angle Limit"); mb.angleLimit = newAngleLimit; EUtil.RepaintSceneView(); } // ref-Axis EditorGUI.BeginChangeCheck(); Vector3 newRefAxis = EUtil.DrawV3P(CONT_RefAxis, mb.refAxis); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(mb, "Modify ref axis"); mb.refAxis = newRefAxis; mb.CalcInitData(); //!! recalc the startTwistRot EUtil.RepaintSceneView(); } mb.limitTwist = EditorGUILayout.Toggle(CONT_LimitTwist, mb.limitTwist); if (mb.limitTwist) { float min = mb.minTwistLimit; float max = mb.maxTwistLimit; EditorGUI.BeginChangeCheck(); EUtil.DrawMinMaxSlider("Twist Limits", ref min, ref max, -180f, 180f); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(mb, "Modify twist limits"); mb.minTwistLimit = min; mb.maxTwistLimit = max; EUtil.RepaintSceneView(); } EditorGUILayout.LabelField("Current twist: " + mb.CalcTwist()); } ms_showDisplaySetting = EditorGUILayout.Foldout(ms_showDisplaySetting, "Display Settings:"); if (ms_showDisplaySetting) { EditorGUI.BeginChangeCheck(); ms_markerSize = EditorGUILayout.FloatField("Marker size", ms_markerSize); ms_markerColor = EditorGUILayout.ColorField("Marker color", ms_markerColor); if (EditorGUI.EndChangeCheck()) { EUtil.RepaintSceneView(); } } EUtil.PopGUIEnable(); } }