AddDefaultPoints() private static method

private static AddDefaultPoints ( BezierCurve3D curve ) : void
curve BezierCurve3D
return void
Beispiel #1
0
        private static void CreateBezeirCurve()
        {
            BezierCurve3D curve    = new GameObject("Bezier Curve", typeof(BezierCurve3D)).GetComponent <BezierCurve3D>();
            Vector3       position = Vector3.zero;

            if (Camera.current != null)
            {
                position = Camera.current.transform.position + Camera.current.transform.forward * 10f;
            }

            curve.transform.position = position;

            BezierCurve3DEditor.AddDefaultPoints(curve);

            Undo.RegisterCreatedObjectUndo(curve.gameObject, "Create Curve");

            Selection.activeGameObject = curve.gameObject;
        }
Beispiel #2
0
        protected virtual void OnEnable()
        {
            this.curve = (BezierCurve3D)this.target;
            if (curve.KeyPointsCount < 2)
            {
                while (curve.KeyPointsCount != 0)
                {
                    curve.RemoveKeyPointAt(this.curve.KeyPointsCount - 1);
                }

                BezierCurve3DEditor.AddDefaultPoints(this.curve);
            }

            this.keyPoints = new ReorderableList(this.serializedObject, serializedObject.FindProperty("keyPoints"), true, true, false, false);
            this.keyPoints.drawElementCallback = this.DrawElementCallback;
            this.keyPoints.drawHeaderCallback  =
                (Rect rect) =>
            {
                EditorGUI.LabelField(rect, string.Format("Points: {0}", this.keyPoints.serializedProperty.arraySize), EditorStyles.boldLabel);
            };
        }