/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { var item = layout.CustomContainer <BezierCurveEditor <T> >(); _curve = item.CustomControl; _curve.Height = 120.0f; _curve.Edited += OnCurveEdited; }
protected virtual void OnSceneGUI() { BezierPointEditor.handleCapSize = BezierPointEditor.CircleCapSize; BezierCurveEditor.DrawPointsSceneGUI(this.point.Curve, this.point); BezierPointEditor.handleCapSize = BezierPointEditor.SphereCapSize; BezierPointEditor.DrawPointSceneGUI(this.point, Handles.DotHandleCap, Handles.SphereHandleCap); }
void OnSceneGUI() { Handles.color = Color.green; Vector3 newPosition = Handles.FreeMoveHandle(point.position, point.transform.rotation, HandleUtility.GetHandleSize(point.position) * 0.2f, Vector3.zero, Handles.CubeCap); if (point.position != newPosition) { point.position = newPosition; } handlers[(int)point.handleStyle](point); Handles.color = Color.yellow; Handles.DrawLine(point.position, point.globalHandle1); Handles.DrawLine(point.position, point.globalHandle2); BezierCurveEditor.DrawOtherPoints(point.curve, point); }
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; }
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); }; }
/// <inheritdoc /> protected override void Deinitialize() { _curve = null; base.Deinitialize(); }
protected virtual void OnSceneGUI() { BezierCurveEditor.DrawPointsSceneGUI(this.curve); }