Esempio n. 1
0
        private void CreateToolbar()
        {
            _graphButton = new TextElement {
                tooltip = "Select a graph to edit"
            };
            _graphButton.AddToClassList(ToolbarButtonUssClassName);
            _graphButton.AddToClassList(ToolbarButtonLargeUssClassName);
            _graphButton.AddToClassList(ToolbarButtonFirstUssClassName);
            _graphButton.AddToClassList(ToolbarButtonGraphUssClassName);
            _graphButton.AddManipulator(new Clickable(() => ShowGraphPicker(GUIUtility.GUIToScreenPoint(_graphButton.worldBound.position))));

            _editButton = CreateEditMenu();
            _editButton.AddToClassList(ToolbarMenuUssClassName);

            _viewButton = CreateViewMenu();
            _viewButton.AddToClassList(ToolbarMenuUssClassName);

            _playButton = new Image {
                image = _playIcon.Texture, tooltip = "Resume execution of the graph"
            };
            _playButton.AddToClassList(ToolbarButtonUssClassName);
            _playButton.AddToClassList(ToolbarButtonSmallUssClassName);
            _playButton.AddManipulator(new Clickable(() => CurrentGraph.DebugPlay()));

            _pauseButton = new Image {
                image = _pauseIcon.Texture, tooltip = "Pause the execution of the graph"
            };
            _pauseButton.AddToClassList(ToolbarButtonUssClassName);
            _pauseButton.AddToClassList(ToolbarButtonSmallUssClassName);
            _pauseButton.AddManipulator(new Clickable(() => CurrentGraph.DebugPause()));

            _stepButton = new Image {
                image = _stepIcon.Texture, tooltip = "Step forward one node in the graph"
            };
            _stepButton.AddToClassList(ToolbarButtonUssClassName);
            _stepButton.AddToClassList(ToolbarButtonSmallUssClassName);
            _stepButton.AddManipulator(new Clickable(() => CurrentGraph.DebugStep()));

            _stopButton = new Image {
                image = _stopIcon.Texture, tooltip = "Stop executing the graph", tintColor = Color.gray
            };
            _stopButton.AddToClassList(ToolbarButtonUssClassName);
            _stopButton.AddToClassList(ToolbarButtonSmallUssClassName);
            _stopButton.AddManipulator(new Clickable(() => CurrentGraph.DebugStop()));

            _breakButton = new VisualElement {
                tooltip = "Enable/Disable node breakpoints for all graphs"
            };
            _breakButton.AddToClassList(ToolbarButtonUssClassName);
            _breakButton.AddToClassList(ToolbarButtonSmallUssClassName);
            _breakButton.AddToClassList(ToolbarButtonFirstUssClassName);
            _breakButton.AddManipulator(new Clickable(ToggleBreakpointsEnabled));

            var breakButton = new VisualElement();

            breakButton.AddToClassList(ToolbarButtonBreakpointUssClassName);

            _breakButton.Add(breakButton);

            _loggingButton = new Image {
                image = _logIcon.Texture, tooltip = "Enable/Disable logging of graph execution for all graphs"
            };
            _loggingButton.AddToClassList(ToolbarButtonUssClassName);
            _loggingButton.AddToClassList(ToolbarButtonSmallUssClassName);
            _loggingButton.AddManipulator(new Clickable(ToggleLoggingEnabled));

            _lockButton = new Image {
                tintColor = Color.black, tooltip = "Lock/Unlock this window so it won't be used when other graphs are opened"
            };
            _lockButton.AddToClassList(ToolbarButtonUssClassName);
            _lockButton.AddToClassList(ToolbarButtonSmallUssClassName);
            _lockButton.AddToClassList(ToolbarButtonLockUssClassName);
            _lockButton.AddManipulator(new Clickable(ToggleLockingEnabled));

            var watchButton = new Image {
                image = Icon.View.Texture, tooltip = "Open the Watch Window"
            };

            watchButton.AddToClassList(ToolbarButtonUssClassName);
            watchButton.AddToClassList(ToolbarButtonSmallUssClassName);
            watchButton.AddManipulator(new Clickable(WatchWindow.ShowWindow));

            RefreshToolbar();

            var toolbar = new Toolbar();

            toolbar.AddToClassList(ToolbarUssClassName);
            toolbar.Add(_graphButton);
            toolbar.Add(_editButton);
            toolbar.Add(_viewButton);
            toolbar.Add(_playButton);
            toolbar.Add(_pauseButton);
            toolbar.Add(_stepButton);
            toolbar.Add(_stopButton);
            toolbar.Add(new ToolbarSpacer {
                flex = true
            });
            toolbar.Add(_breakButton);
            toolbar.Add(_loggingButton);
            toolbar.Add(watchButton);
            toolbar.Add(_lockButton);

            Add(toolbar);
        }