void OnEnable() { bc = (BezierCurveCollider2D)target; if (!bc.initialized) { bc.Init(); } }
public override void OnInspectorGUI() { GUI.changed = false; DrawDefaultInspector(); if (!bc.edge.offset.Equals(Vector2.zero)) { bc.edge.offset = Vector2.zero; // prevent changes to offset } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Add Point")) { bc.addControlPoint(); } if (bc.controlPoints.Count > 2) // minimum 2 control points are always required { if (GUILayout.Button("Remove Point")) { bc.removeControlPoint(); } } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Reset")) { bc.initialized = false; bc.Init(); } if (GUI.changed) { bc.drawCurve(); } }
void OnEnable() { bc = (BezierCurveCollider2D)target; if (!bc.initialized) bc.Init(); }