Exemplo n.º 1
0
        /// <summary>
        /// Update parameters of new transition while it is not a part of model yet.
        /// </summary>
        /// <param name="color"></param>
        private static void UpdateNewTransition(Color?color = null)
        {
            if (color == null)
            {
                color = NeutralColor;
            }
            if (ClickedMouse())
            {
                var hover = HoverOnNode();
                if (hover == null)
                {
                    _makeTransitionMode = false;
                    return;
                }
                if (_nodeThatStartedTransition.Equals(hover))
                {
                    _makeTransitionMode = false;
                    return;
                }
                var transition = CreateInstance <Transition>();
                EditorUtility.SetDirty(transition);
                transition.Start = _nodeThatStartedTransition;
                transition.End   = hover;
                transition.Color = _transitionColor;
                _nodeThatStartedTransition.Transitions.Add(transition);
                _makeTransitionMode = false;
                _transitionColor    = NeutralColor;

                ClearGrouped();
                _draggingGroup = false;
            }

            var startPos = new Vector3(_newTransitionStart.x + _newTransitionStart.width / 2,
                                       _newTransitionStart.y + _newTransitionStart.height / 2, 0);
            var endPos = new Vector3(Event.current.mousePosition.x, Event.current.mousePosition.y, 0);

            Handles.color = color.Value;
            Handles.DrawAAPolyLine(4, startPos, endPos);
            DrawArrow(startPos, endPos);
            Event.current.Use();
        }