private void DrawToolbar(ref Rect contentRect)
        {
#if UNITY_2019_3_OR_NEWER
            var toolbarSize = 22;
#else
            var toolbarSize = 18;
#endif

            contentRect.y      += toolbarSize;
            contentRect.height -= toolbarSize;

            GUILayout.BeginArea(new Rect(0, 0, contentRect.width, toolbarSize));

            EditorGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

            var clearButton = GUILayout.Button(_clearContent, EditorStyles.toolbarButton, GUILayout.Height(45f));

            GUILayout.Space(5f);

            ShowReceived    = GUILayout.Toggle(ShowReceived, _recevedContent, EditorStyles.toolbarButton);
            ShowTransmitted = GUILayout.Toggle(ShowTransmitted, _transmittedContent, EditorStyles.toolbarButton);

            GUILayout.FlexibleSpace();
            GUILayout.Space(5f);

            _filterDrawer.Draw();

            GUILayout.Space(5f);

            TrackLast = GUILayout.Toggle(TrackLast, _trackLastContent, EditorStyles.toolbarButton);

            GUILayout.Space(5f);

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();

            GUILayout.EndArea();

            if (clearButton)
            {
                OSCWindowConsole.Clear();

                SelectedMessage = null;
            }
        }
コード例 #2
0
        private void DrawToolbar(Rect contentRect)
        {
            GUILayout.BeginArea(new Rect(0, 0, contentRect.width, 18));

            EditorGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

            var clearButton = GUILayout.Button(_clearContent, EditorStyles.toolbarButton, GUILayout.Height(45f));

            GUILayout.Space(5f);

            _showReceived    = GUILayout.Toggle(_showReceived, _recevedContent, EditorStyles.toolbarButton);
            _showTransmitted = GUILayout.Toggle(_showTransmitted, _transmittedContent, EditorStyles.toolbarButton);

            GUILayout.FlexibleSpace();
            GUILayout.Space(5f);

            //GUILayout.Label(_filterContent);
            _filterDrawer.Draw();

            GUILayout.Space(5f);

            _trackLast = GUILayout.Toggle(_trackLast, _trackLastContent, EditorStyles.toolbarButton);

            GUILayout.Space(5f);

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();

            GUILayout.EndArea();

            if (clearButton)
            {
                OSCWindowConsole.Clear();

                _selectedMessage = null;
            }
        }
コード例 #3
0
        protected override void DrawContent(Rect contentRect)
        {
            GUILayout.BeginArea(new Rect(0, 0, contentRect.width, 18));

            EditorGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

            var clearButton = GUILayout.Button(_clearContent, EditorStyles.toolbarButton, GUILayout.Height(45f));

            GUILayout.Space(5f);

            _showReceived    = GUILayout.Toggle(_showReceived, _recevedContent, EditorStyles.toolbarButton);
            _showTransmitted = GUILayout.Toggle(_showTransmitted, _transmittedContent, EditorStyles.toolbarButton);

            GUILayout.Space(5f);

            _trackLast = GUILayout.Toggle(_trackLast, _trackLastContent, EditorStyles.toolbarButton);

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();

            GUILayout.EndArea();

            contentRect.y      += 18;
            contentRect.height -= 18;

            _lastContentRect = new Rect(contentRect);
            _consoleBuffer   = OSCWindowConsole.GetConsoleBuffer(_showTransmitted, _showReceived);

            if (_trackLast)
            {
                if (_consoleBuffer.Length > 0)
                {
                    _selectedMessage = _consoleBuffer[0];
                }
                else
                {
                    _selectedMessage = null;
                }
            }

            var viewRect = new Rect(contentRect);

            viewRect.height = _consoleBuffer.Length * _lineHeight;

            if (viewRect.height > contentRect.height)
            {
                viewRect.width -= 15f;
            }

            var itemRect = new Rect(0, viewRect.y, viewRect.width, _lineHeight);

            _scrollPosition = GUI.BeginScrollView(contentRect, _scrollPosition, viewRect);

            var drawed = false;

            for (var index = 0; index < _consoleBuffer.Length; index++)
            {
                var drawItem = !((itemRect.y + itemRect.height < _scrollPosition.y) ||
                                 (itemRect.y > _scrollPosition.y + contentRect.height + itemRect.height));

                if (drawItem)
                {
                    drawed = true;

                    var consoleMessage = _consoleBuffer[index];
                    var selected       = _selectedMessage == consoleMessage;
                    var color          = GUI.color;

                    DrawItem(itemRect, index, consoleMessage, selected);

                    GUI.color = color;

                    if (Event.current.type == EventType.MouseDown && itemRect.Contains(Event.current.mousePosition))
                    {
                        if (Event.current.button == 0)
                        {
                            _trackLast = false;

                            if (_selectedMessage != consoleMessage)
                            {
                                _selectedMessage = consoleMessage;
                                _parentWindow.Repaint();
                            }

                            Event.current.Use();
                        }
                        else if (Event.current.button == 1)
                        {
                            ShowMessageGenericMenu(consoleMessage);

                            Event.current.Use();
                        }
                    }
                }
                else if (drawed)
                {
                    break;
                }

                itemRect.y += itemRect.height;
            }

            GUI.EndScrollView(true);

            if (clearButton)
            {
                OSCWindowConsole.Clear();

                _selectedMessage = null;
            }
        }