Ejemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            spline = target as BezierSpline;
            EditorGUI.BeginChangeCheck();
            bool loop = EditorGUILayout.Toggle("Loop", spline.Loop);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(spline, "Toggle Loop");
                EditorUtility.SetDirty(spline);
                spline.Loop = loop;
            }

            if (selectedIndex >= 0 && selectedIndex < spline.ControlPointCount)
            {
                DrawSelectedPointInspector();
            }
            if (GUILayout.Button("AddCurve"))
            {
                Undo.RecordObject(spline, "Add Curve");
                spline.AddCurve();
                EditorUtility.SetDirty(spline);
            }
        }
Ejemplo n.º 2
0
        private void OnSceneGUI()
        {
            spline          = target as BezierSpline;
            handleTransform = spline.transform;
            handleRotation  = Tools.pivotRotation == PivotRotation.Local ? handleTransform.rotation : Quaternion.identity;

            Vector3 point0 = ShowPoint(0);

            for (int i = 1; i < spline.ControlPointCount; i += 3)
            {
                Vector3 point1 = ShowPoint(i);
                Vector3 point2 = ShowPoint(i + 1);
                Vector3 point3 = ShowPoint(i + 2);

                Handles.color = Color.grey;
                Handles.DrawLine(point0, point1);
                Handles.DrawLine(point2, point3);

                Handles.DrawBezier(point0, point3, point1, point2, Color.white, null, 2f);
                point0 = point3;
            }
            ShowDirections();
            ShowNormals();
        }