private TransitionViewData MakeNewTransitionViewData(Transition transition)
        {
            TransitionViewData viewData = new TransitionViewData(transition);

            this._transitionViewDatas.Add(viewData);
            this.ClearCached();
            return(viewData);
        }
Exemple #2
0
        private void DrawTransitionFromNodeToNode(TransitionViewData transitionViewData, Node node, Node targetNode, TransitionViewStyle style)
        {
            NodeViewData nodeViewData       = this.GetViewDataForNode(node);
            NodeViewData targetNodeViewData = this.GetViewDataForNode(targetNode);

            this.DrawTransitionFromPointToPoint(transitionViewData,
                                                nodeViewData.position + this._panner.Position,
                                                targetNodeViewData.position + this._panner.Position,
                                                style);
        }
        public TransitionViewData GetViewDataForTransition(Transition transition)
        {
            TransitionViewData viewData = this.CachedViewDataMapping.SafeGet(transition);

            if (viewData == null)
            {
                viewData = this.MakeNewTransitionViewData(transition);
            }
            return(viewData);
        }
Exemple #4
0
        private void DrawTransitionsForNode(Node node)
        {
            NodeViewData           nodeViewData    = this.GetViewDataForNode(node);
            IList <NodeTransition> nodeTransitions = this.TargetGraph.GetOutgoingTransitionsForNode(node);

            foreach (NodeTransition nodeTransition in nodeTransitions)
            {
                TransitionViewStyle transitionStyle    = this.GetStyleForTransition(node, nodeTransition);
                TransitionViewData  transitionViewData = nodeViewData.GetViewDataForTransition(nodeTransition.transition);

                IList <Node> targetNodes = nodeTransition.targets.Select(targetId => this.TargetGraph.LoadNodeById(targetId)).ToList();
                foreach (Node targetNode in targetNodes)
                {
                    this.DrawTransitionFromNodeToNode(transitionViewData, node, targetNode, transitionStyle);
                }
            }
        }
Exemple #5
0
            private void DrawEditingTransitionToMousePoint()
            {
                if (this._node == null)
                {
                    Debug.LogError("DrawEditingTransitionToMousePoint - node is null!");
                    return;
                }

                Vector2            mousePosition      = Event.current.mousePosition;
                NodeViewData       nodeViewData       = this.Context.GetViewDataForNode(this._node);
                TransitionViewData transitionViewData = nodeViewData.GetViewDataForTransition(this._nodeTransition.transition);

                this.Context.DrawTransitionFromPointToPoint(transitionViewData,
                                                            nodeViewData.position + this.Context._panner.Position,
                                                            mousePosition,
                                                            TransitionViewStyle.HIGHLIGHTED);
            }
Exemple #6
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);
        }