private void DrawSelectedPointInspector() { GUILayout.Label("Selected Point"); EditorGUI.BeginChangeCheck(); // Display the vector of the selected point in the inspector. Vector3 point = EditorGUILayout.Vector3Field("Position", spline.GetControlPoint(selectedIndex)); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(spline, "Move Point"); spline.SetControlPoint(selectedIndex, point); EditorUtility.SetDirty(spline); } EditorGUI.BeginChangeCheck(); // Display the mode of the selected point in the inspector. BezierSpline.BezierControlPointMode mode = (BezierSpline.BezierControlPointMode) EditorGUILayout.EnumPopup("Mode", spline.GetControlPointMode(selectedIndex)); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(spline, "Change Point Mode"); spline.SetControlPointMode(selectedIndex, mode); EditorUtility.SetDirty(spline); } }
// --------- // Functions // --------- // Used to draw a new inspector based on the selected spline control point private void DrawSelectedPointInspector() { GUILayout.Label("Selected Point"); EditorGUI.BeginChangeCheck(); Vector3 point = EditorGUILayout.Vector3Field("Position", spline.GetControlPoint(selectedIndex)); // Draw our spline control points if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(spline, "Move Point"); EditorUtility.SetDirty(spline); spline.SetControlPoint(selectedIndex, point); } // Draw the mode per point EditorGUI.BeginChangeCheck(); // This probably should be its own class. BezierSpline.BezierControlPointMode mode = (BezierSpline.BezierControlPointMode) EditorGUILayout.EnumPopup("Mode", spline.GetControlPointMode(selectedIndex)); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(spline, "Change Point Mode"); spline.SetControlPointMode(selectedIndex, mode); EditorUtility.SetDirty(spline); } }
//Function called from OnInspectorGUI that lets us edit the selected control point's position with text private void DrawSelectedPointInspector() { //Creating a label in the editor saying which point is selected GUILayout.Label("Selected Point"); //Start checking for input changes to the selected handle EditorGUI.BeginChangeCheck(); //Creating a vector 3 input field showing the selected point's coordinates Vector3 point = EditorGUILayout.Vector3Field("Position", this.spline.GetControlPoint(this.selectedIndex)); //Once we're done checking for changes, we apply them to the selected control point's position if (EditorGUI.EndChangeCheck()) { //Setting our spline to dirty so we can save or undo the change Undo.RecordObject(this.spline, "Move Point"); EditorUtility.SetDirty(this.spline); //Applying the change in position to the selected control point this.spline.SetControlPoint(this.selectedIndex, point); } //Start checking for input changes to the enum for the control point mode EditorGUI.BeginChangeCheck(); BezierSpline.BezierControlPointMode mode = (BezierSpline.BezierControlPointMode)EditorGUILayout.EnumPopup("Mode", this.spline.GetControlPointMode(this.selectedIndex)); //Once we're done checking for changes to the enum, we apply them to the selected control point's mode if (EditorGUI.EndChangeCheck()) { //Setting our spline to dirty so we can save or undo the change Undo.RecordObject(this.spline, "Change Point Mode"); //Changing the selected control point's mode this.spline.SetControlPointMode(this.selectedIndex, mode); EditorUtility.SetDirty(this.spline); } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (e.Button == MouseButtons.Right) { SelectedTransform = GetSpline.TryGetTransformFromPosition(new Vector2(e.X, e.Y)); if (SelectedTransform != null && !SelectedTransform.IsCenterSpline) { BezierSpline.BezierControlPointMode nextMode = MySpline.GetControlPointMode(SelectedTransform.Index).Next(); MySpline.SetControlPointMode(SelectedTransform.Index, nextMode); } } }
protected override BezierSpline Read(ContentReader input, BezierSpline existingInstance) { BezierSpline bezierSpline = new BezierSpline(); Setup.SplineMarkerResolution = input.ReadSingle(); bezierSpline.CatMulRom = input.ReadBoolean(); bezierSpline.Loop = input.ReadBoolean(); int pointLength = input.ReadInt32(); Transform[] points = new Transform[pointLength]; for (int i = 0; i < pointLength; i++) { points[i] = new Transform(input.ReadVector2()); } int pointModeLength = input.ReadInt32(); BezierSpline.BezierControlPointMode[] pointModes = new BezierSpline.BezierControlPointMode[pointModeLength]; for (int i = 0; i < pointModeLength; i++) { pointModes[i] = (BezierSpline.BezierControlPointMode)Enum.Parse(typeof(BezierSpline.BezierControlPointMode), input.ReadString()); } int triggerLength = input.ReadInt32(); Trigger[] trigger = new Trigger[triggerLength]; for (int i = 0; i < triggerLength; i++) { trigger[i] = new Trigger( input.ReadString(), input.ReadSingle(), input.ReadSingle() * Setup.SplineMarkerResolution, input.ReadString()); } bezierSpline.LoadBezierSplineData( points, pointModes, trigger); return(bezierSpline); }
private Color GetModeColor(BezierSpline.BezierControlPointMode mode) { switch (mode) { case BezierSpline.BezierControlPointMode.Free: return(EditorSettings.FreeModeColor); case BezierSpline.BezierControlPointMode.Aligned: return(EditorSettings.AlignedModeColor); case BezierSpline.BezierControlPointMode.Mirrored: return(EditorSettings.MirroredModeColor); case BezierSpline.BezierControlPointMode.Auto: return(EditorSettings.AutoModeColor); default: break; } return(Color.cyan); }
void DrawSelectedPointInspector() { GUILayout.Label("Selected Point (" + _selectedIndex.ToString() + ")"); EditorGUI.BeginChangeCheck(); Vector3 point = EditorGUILayout.Vector3Field("Position", _spline.GetControlPoint(_selectedIndex)); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(_spline, "Move Point"); EditorUtility.SetDirty(_spline); _spline.SetControlPoint(_selectedIndex, point); } EditorGUI.BeginChangeCheck(); BezierSpline.BezierControlPointMode mode = (BezierSpline.BezierControlPointMode) EditorGUILayout.EnumPopup("Mode", _spline.GetControlPointMode(_selectedIndex)); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(_spline, "Change Point Mode"); _spline.SetControlPointMode(_selectedIndex, mode); EditorUtility.SetDirty(_spline); } }