示例#1
0
        private void DrawTransitionFromPointToPoint(TransitionViewData transitionViewData, Vector2 point, Vector2 targetPoint, TransitionViewStyle style)
        {
            Color    transitionColor      = TransitionViewStyleUtil.GetColor(style);
            GUIStyle transitionArrowStyle = TransitionViewStyleUtil.GetArrowStyle(style);

            Vector2 offset = targetPoint - point;
            // ex. A ---> B    ==    Direction.RIGHT
            Direction offsetDirection = DirectionUtil.ConvertVector2(offset);

            // ex. (Direction.RIGHT).Vector2Value()   ==   Vector2(1.0f, 0.0f)
            Vector2 nodeTangent       = Vector2.Scale(offsetDirection.Vector2Value(), Vector2Util.Abs(offset) * kTransitionTangentMultiplier);
            Vector2 targetNodeTangent = -nodeTangent;

            Handles.DrawBezier(point,
                               targetPoint,
                               point + nodeTangent,
                               targetPoint + targetNodeTangent,
                               transitionColor,
                               null,
                               kTransitionLineWidth);

            Vector3[] bezierPoints = Handles.MakeBezierPoints(point,
                                                              targetPoint,
                                                              point + nodeTangent,
                                                              targetPoint + targetNodeTangent,
                                                              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);
        }