//Inspector public override void OnInspectorGUI() { //Loop checkbox EditorGUI.BeginChangeCheck(); bool loop = EditorGUILayout.Toggle("Loop", m_Spline.GetLoop()); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(m_Spline, "Toggle Loop"); EditorUtility.SetDirty(m_Spline); m_Spline.SetLoop(loop); } //Add curve button if (m_SelectedIndex >= 0 && m_SelectedIndex < m_Spline.GetPointCount()) { DrawSelectedPointInspector(); } m_Spline = target as LineSpline; if (GUILayout.Button("Add Line")) { Undo.RecordObject(m_Spline, "Add Line"); //Makes sure we can undo EditorUtility.SetDirty(m_Spline); //Makes sure unity asks us to save after changing m_Spline.AddLine(); } }
//Scene private void OnSceneGUI() { m_Spline = target as LineSpline; m_HandleTransform = m_Spline.transform; m_HandleRotation = Tools.pivotRotation == PivotRotation.Local ? m_HandleTransform.rotation : Quaternion.identity; //Show points Vector3 p0 = ShowPoint(0); for (int i = 1; i < m_Spline.GetPointCount(); ++i) { Vector3 p1 = ShowPoint(i); //Draw the handle lines Handles.color = Color.white; Handles.DrawLine(p0, p1); //p1 helps p0 p0 = p1; } }