public override void OnInspectorGUI() { BezierPoints bezierPoints = (BezierPoints)target; bezierPoints.lineColor = EditorGUILayout.ColorField("Line Color", bezierPoints.lineColor); if (GUILayout.Button("Clear all curves")) { clearFoldedPrefs(bezierPoints.CurvesCount); Undo.RecordObject(bezierPoints, "Cleared beizer curves"); bezierPoints.clearAll(); } GUILayout.BeginHorizontal(); bezierPoints.autoLerp = EditorGUILayout.Toggle("Auto lerp", bezierPoints.autoLerp); bezierPoints.lerpBackwards = EditorGUILayout.Toggle("Lerp backwards", bezierPoints.lerpBackwards); GUILayout.EndHorizontal(); bezierPoints.looping = EditorGUILayout.Toggle("Looping", bezierPoints.looping); EditorGUILayout.Space(); //add curve button if (GUILayout.Button("Add Beizer curve")) { setFoldedPref(bezierPoints.CurvesCount, false); Undo.RecordObject(bezierPoints, "Added beizer curve"); bezierPoints.addBeizeCurve(); } //if points exists if (bezierPoints.CurvesCount > 0) { //slider for lerp value bezierPoints.lerpValue = EditorGUILayout.Slider("Lerp Value", bezierPoints.lerpValue, 0, 1); //show all points for each curve for (int i = 0; i < bezierPoints.CurvesCount; i++) { //Debug.Log(EditorPrefs.HasKey("folded" + (i / 2)) + " : " + i); setFoldedPref(i, EditorGUILayout.Foldout(EditorPrefs.GetBool("folded" + (i)), "Beizer curve " + i, true)); if (EditorPrefs.HasKey("folded" + (i)) && EditorPrefs.GetBool("folded" + (i))) { EditorGUI.indentLevel++; EditorGUI.BeginChangeCheck(); Vector3 endPoint1 = EditorGUILayout.Vector3Field("End Point 1", bezierPoints.getEndpoint1(i)); Vector3 endPoint2 = EditorGUILayout.Vector3Field("End Point 2", bezierPoints.getEndpoint2(i)); Vector3 controlPoint1 = EditorGUILayout.Vector3Field("Control Point 1", bezierPoints.getControlPoint1(i)); Vector3 controlPoint2 = EditorGUILayout.Vector3Field("Control Point 2", bezierPoints.getControlPoint2(i)); GUILayout.BeginHorizontal(); AnimationCurve animCurve = EditorGUILayout.CurveField("Speed curve", bezierPoints.getAnimationCurve(i)); float speedMultiplier = EditorGUILayout.FloatField("Speed Multiplier", bezierPoints.getCurveMultiplier(i)); GUILayout.EndHorizontal(); EditorGUILayout.Space(); Quaternion startRotation = Quaternion.Euler(EditorGUILayout.Vector3Field("Start Rotation", bezierPoints.getStartRotation(i).eulerAngles)); Quaternion endRotation = Quaternion.Euler(EditorGUILayout.Vector3Field("End Rotation", bezierPoints.getEndRotation(i).eulerAngles)); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(bezierPoints, "Changed point position"); bezierPoints.setEndPoint1(i, endPoint1); bezierPoints.setEndPoint2(i, endPoint2); bezierPoints.setControlPoint1(i, controlPoint1); bezierPoints.setControlPoint2(i, controlPoint2); bezierPoints.setStartRotation(i, startRotation); bezierPoints.setEndRotation(i, endRotation); bezierPoints.setAnimationCurve(i, animCurve); bezierPoints.setCurveMultiplier(i, Mathf.Clamp(speedMultiplier, 0.1f, int.MaxValue)); } EditorGUI.indentLevel--; GUILayout.BeginHorizontal(); if (GUILayout.Button("Clear")) { removeFoldedPrefAt(i, bezierPoints.CurvesCount); Undo.RecordObject(bezierPoints, "Removed curve"); bezierPoints.removeCurve(i); } if (bezierPoints.CurvesCount > i + 1) { if (GUILayout.Button("Snap to next")) { Undo.RecordObject(bezierPoints, "Snap curve to next"); bezierPoints.setEndPoint2(i, bezierPoints.getEndpoint1(i + 1)); } } else { GUI.enabled = false; GUILayout.Button("Snap to next"); GUI.enabled = true; } GUILayout.EndHorizontal(); } } //clear all curves if (GUILayout.Button("Clear all curves")) { clearFoldedPrefs(bezierPoints.CurvesCount); Undo.RecordObject(bezierPoints, "Cleared beizer curves"); bezierPoints.clearAll(); } } }