示例#1
0
        private TransitionViewData MakeNewTransitionViewData(Transition transition)
        {
            TransitionViewData viewData = new TransitionViewData(transition);

            this._transitionViewDatas.Add(viewData);
            this.ClearCached();
            return(viewData);
        }
        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);
        }
示例#3
0
        public TransitionViewData GetViewDataForTransition(Transition transition)
        {
            TransitionViewData viewData = this.CachedViewDataMapping.SafeGet(transition);

            if (viewData == null)
            {
                viewData = this.MakeNewTransitionViewData(transition);
            }
            return(viewData);
        }
        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);
                }
            }
        }
示例#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);
            }
        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);
        }