private void DrawTransitionFromPointToPoint(TransitionViewData transitionViewData, Vector2 point, Vector2 targetPoint, TransitionViewStyle style) { Color transitionColor = TransitionViewStyleUtil.GetColor(style); GUIStyle transitionArrowStyle = TransitionViewStyleUtil.GetArrowStyle(style); CubicBezierV2 bezier = new CubicBezierV2(point, targetPoint, kTransitionTangentMultiplier); Handles.DrawBezier(bezier.start, bezier.end, bezier.startTangent, bezier.endTangent, transitionColor, null, kTransitionLineWidth); Vector3[] bezierPoints = Handles.MakeBezierPoints(bezier.start, bezier.end, bezier.startTangent, bezier.endTangent, division: 40); int midPointIndex = Mathf.FloorToInt(bezierPoints.Length / 2.0f); Vector2 midPointTangent = bezierPoints[midPointIndex + 1] - bezierPoints[midPointIndex]; Vector2 midPoint = (point + targetPoint) / 2.0f; float rotationAngle = Vector2.Angle(Vector2.right, midPointTangent); if (midPointTangent.y < 0.0f) { rotationAngle *= -1.0f; } GUIUtility.RotateAroundPivot(rotationAngle, midPoint); GUI.Box(RectUtil.MakeRect(midPoint, new Vector2(10.0f, 10.0f), pivot: new Vector2(0.5f, 0.5f)), "", transitionArrowStyle); GUIUtility.RotateAroundPivot(-rotationAngle, midPoint); }
public static Vector2 Evaluate(this CubicBezierV2 q, float t) { return(BezierUtil.Cubic(q.start, q.startTangent, q.end, q.endTangent, t)); }