Exemplo n.º 1
0
    private static void CreateBezeirCurve()
    {
        BezierCurve curve    = new GameObject("Bezier Curve", typeof(BezierCurve)).GetComponent <BezierCurve>();
        Vector3     position = Vector3.zero;

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

        curve.transform.position = position;

        BezierCurveEditor.AddDefaultPoints(curve);

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

        Selection.activeGameObject = curve.gameObject;
    }
Exemplo n.º 2
0
    protected virtual void OnEnable()
    {
        this.curve = (BezierCurve)this.target;
        if (curve.KeyPointsCount < 2)
        {
            while (curve.KeyPointsCount != 0)
            {
                curve.RemoveKeyPointAt(this.curve.KeyPointsCount - 1);
            }

            BezierCurveEditor.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);
        };
    }