private void UnbindConnectionCallbacks(TransitionConnectionUI connection)
 {
     if (connection != null)
     {
         connection.OnCreatedTransition -= CreatedTransition;
         connection.OnRemovedTransition -= RemovedTransition;
     }
 }
        public void Hide()
        {
            UnbindConnectionCallbacks(_connection);

            _connection         = null;
            _selectedTransition = null;
            style.display       = DisplayStyle.None;
        }
        public void Show(TransitionConnectionUI connection)
        {
            UnbindConnectionCallbacks(_connection);

            _connection         = connection;
            _selectedTransition = _connection.Transitions[0];

            BindTransitionFields(_selectedTransition);
            BindConnectionCallbacks(_connection);

            _transitions.itemsSource   = _connection.Transitions;
            _transitions.selectedIndex = 0;
            _transitions.Refresh();
            style.display = DisplayStyle.Flex;
        }
Esempio n. 4
0
        public StateNodeUITransitionItem(TransitionConnectionUI transition)
        {
            StateNodeUI destinationState = (StateNodeUI)transition.Destination;

            DestinationLabel             = new Label(destinationState.Name);
            DestinationLabel.pickingMode = PickingMode.Ignore;

            var moveUpButton = new Button(MoveUp)
            {
                text = "▲"
            };

            moveUpButton.AddToClassList("move-up");

            var moveDownButton = new Button(MoveDown)
            {
                text = "▼"
            };

            moveDownButton.AddToClassList("move-down");

            Add(DestinationLabel);
            Add(moveUpButton);
            Add(moveDownButton);

            _transition = transition;

            destinationState.OnNameChanged += ChangeDestinationLabel;

            RegisterCallback <MouseDownEvent>(e =>
            {
                if (e.clickCount < 2)
                {
                    return;
                }

                schedule.Execute(() =>
                {
                    StateMachineEditor.Editor.GraphView.ClearSelection();
                    StateMachineEditor.Editor.GraphView.AddToSelection((StateNodeUI)_transition.Destination);
                    StateMachineEditor.Editor.GraphView.FrameSelection();
                });
            });
        }
 void RemovedTransition(TransitionConnectionUI transitionConnection, TransitionInfo transitionInfo, int index)
 {
     _transitions.Refresh();
     _transitions.selectedIndex = index == transitionConnection.Transitions.Count ? index - 1 : index;
 }
 void CreatedTransition(TransitionConnectionUI transitionConnection, TransitionInfo transitionInfo)
 {
     _transitions.Refresh();
     _transitions.selectedIndex = transitionConnection.Transitions.Count - 1;
 }