//================================ Public methods ================================= /// <inheritdoc /> public override void OnInspectorGUI() { EditorGUILayout.HelpBox("Ope point mode: Editing a one point.", MessageType.Info); if (_selection < 0) { return; } Spline.Update(); var needToUpdate = SplineGUILayout.PointField(Spline, _selection); var action = SplineGUILayout.PointCreationControls(Spline.GetPointInfo(_selection)); PointInfo info; if (SplineGUILayout.PointTypeControls(Spline.GetPoint(_selection), out info, Spline.Count)) { Spline.SetPointInfo(_selection, info); needToUpdate = true; } if (action != SplineGUILayout.CreationType.None) { //TODO: Add creation methods if (action == SplineGUILayout.CreationType.AddLeft) { Spline.AddLeftPoint(_selection); } needToUpdate = true; } if (!needToUpdate) { return; } Spline.ApplyModifiedProperties(); SceneView.RepaintAll(); }
//================================ Private|Protected methods ================================ protected override void OnSceneGUI() { if (EditMode.editTool == Tool.Move) { base.OnSceneGUI(); return; } Spline.Update(); SplineContent[] points = FilterPoints(_selection); SplineHandles.DrawSegments(Spline.GetSegments(), _selection); SplineHandles.DrawNormals(FilterNormals(_selection), -1); if (points.Length == 0) { return; } var selection = Array.FindIndex(points, p => p.Index == _selection); //Draw points EditorGUI.BeginChangeCheck(); selection = SplineHandles.PointsHandle(selection, points, EditMode.editTool == Tool.Rect); if (EditorGUI.EndChangeCheck()) { _selection = points[selection].Index; } //Move points if (_selection < 0 || EditMode.editTool != Tool.Rect) { return; } Repaint(); EditorGUI.BeginChangeCheck(); Vector3 position = Spline[_selection]; position = Handles.PositionHandle(position, Quaternion.identity); if (!EditorGUI.EndChangeCheck()) { return; } MovePoint(_selection, position); Spline.ApplyModifiedProperties(); }