Пример #1
0
        private void AddControlPointsMode()
        {
            float mu = ObiEditorCurveDrawing.ScreenPointToCurveMu(spline, Event.current.mousePosition);

            Vector3 pointOnSpline = spline.transform.TransformPoint(spline.GetPositionAt(mu));

            float size = HandleUtility.GetHandleSize(pointOnSpline) * 0.12f;

            Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);

            Handles.color = Color.red;
            Handles.DrawDottedLine(pointOnSpline, ray.origin, 4);
            Handles.SphereHandleCap(0, pointOnSpline, Quaternion.identity, size, Event.current.type);


            if (Event.current.type == EventType.MouseDown && Event.current.modifiers == EventModifiers.None)
            {
                Undo.RecordObject(spline, "Add control point");
                int newIndex = spline.AddPoint(mu);
                if (newIndex >= 0)
                {
                    ResizeCPArrays();
                    for (int i = 0; i < selectedStatus.Length; ++i)
                    {
                        selectedStatus[i] = false;
                    }
                    selectedStatus[newIndex] = true;
                }
                Event.current.Use();
            }

            // Repaint the scene, so that the add control point helpers are updated every frame.
            SceneView.RepaintAll();
        }
Пример #2
0
 private static void DrawGizmosNonSelected(ObiCurve spline, GizmoType gizmoType)
 {
     ObiEditorCurveDrawing.DrawSplineGizmos(spline, 30, new Color(1, 1, 1, 0.5f), new Color(1, 0, 0, 0.5f), Color.white, false);
 }