Beispiel #1
0
        void OnGUI()
        {
            var width  = position.width;
            var height = position.height;

            _zoomArea = new Rect(0, 0, width, height);
            HandleEvents();

            if (_graphGUI != null)
            {
                Rect r = EditorZoomArea.Begin(_zoom, _zoomArea);
                // Main graph area
                _graphGUI.BeginGraphGUI(this, r);
                _graphGUI.OnGraphGUI();
                _graphGUI.EndGraphGUI();

                // Clear selection on background click
                var e = Event.current;
                if (e.type == EventType.MouseDown && e.clickCount == 1)
                {
                    _graphGUI.ClearSelection();
                }


                EditorZoomArea.End();
            }


            // Status bar
            GUILayout.BeginArea(new Rect(0, 0, width, kBarHeight + 5));
            string[] toolbarStrings = new string[] { "Update connections", "Clear" };
            int      result         = GUILayout.Toolbar(-1, toolbarStrings);

            if (result == 0)
            {
                RefreshGraphConnections();
            }
            else if (result == 1)
            {
                RebuildGraph();
            }
            GUILayout.EndArea();
        }
        void OnGUI()
        {
            // In case we start with the window open
            if (!_initialised)
            {
                Initialize();
            }

            var width  = position.width;
            var height = position.height;

            _zoomArea = new Rect(0, 0, width, height - kBarHeight);
            HandleEvents();

            if (_graphGUI != null)
            {
                Rect r = EditorZoomArea.Begin(_zoom, _zoomArea);
                // Main graph area
                _graphGUI.BeginGraphGUI(this, r);
                _graphGUI.zoomLevel = _zoom;
                _graphGUI.OnGraphGUI();
                _graphGUI.EndGraphGUI();

                // Clear selection on background click
                var e = Event.current;
                if (e.type == EventType.MouseDown && e.clickCount == 1)
                {
                    _graphGUI.ClearSelection();
                }


                EditorZoomArea.End();
            }


            // Status bar
            GUILayout.BeginArea(new Rect(0, height - kBarHeight, width, kBarHeight));
            if (GUILayout.Button("Refresh"))
            {
                Refresh();
            }
            GUILayout.EndArea();
        }