Example #1
0
    /// <summary>
    /// Draws the thin, Unity-style toolbar showing error counts and toggle buttons
    /// </summary>
    void DrawToolbar()
    {
        EditorGUILayout.BeginHorizontal();
        if (ButtonClamped("Clear", EditorStyles.toolbarButton))
        {
            EditorLogger.Clear();
        }
        EditorLogger.ClearOnPlay  = ToggleClamped(EditorLogger.ClearOnPlay, "Clear On Play", EditorStyles.toolbarButton);
        EditorLogger.PauseOnError = ToggleClamped(EditorLogger.PauseOnError, "Pause On Error", EditorStyles.toolbarButton);
        ShowTimes = ToggleClamped(ShowTimes, "Show Times", EditorStyles.toolbarButton);

        var buttonSize = EditorStyles.toolbarButton.CalcSize(new GUIContent("T")).y;

        GUILayout.FlexibleSpace();

        var showErrors   = ToggleClamped(ShowErrors, new GUIContent(EditorLogger.NoErrors.ToString(), SmallErrorIcon), EditorStyles.toolbarButton, GUILayout.Height(buttonSize));
        var showWarnings = ToggleClamped(ShowWarnings, new GUIContent(EditorLogger.NoWarnings.ToString(), SmallWarningIcon), EditorStyles.toolbarButton, GUILayout.Height(buttonSize));
        var showMessages = ToggleClamped(ShowMessages, new GUIContent(EditorLogger.NoMessages.ToString(), SmallMessageIcon), EditorStyles.toolbarButton, GUILayout.Height(buttonSize));

        //If the errors/warning to show has changed, clear the selected message
        if (showErrors != ShowErrors || showWarnings != ShowWarnings || showMessages != ShowMessages)
        {
            ClearSelectedMessage();
        }
        ShowWarnings = showWarnings;
        ShowMessages = showMessages;
        ShowErrors   = showErrors;
        EditorGUILayout.EndHorizontal();
    }
Example #2
0
    /// <summary>
    /// Draws the thin, Unity-style toolbar showing error counts and toggle buttons
    /// </summary>
    void DrawToolbar()
    {
        var toolbarStyle = EditorStyles.toolbarButton;

        Vector2 elementSize;

        if (ButtonClamped("Clear", EditorStyles.toolbarButton, out elementSize))
        {
            EditorLogger.Clear();
        }
        DrawPos.x += elementSize.x;
        EditorLogger.ClearOnPlay = ToggleClamped(EditorLogger.ClearOnPlay, "Clear On Play", EditorStyles.toolbarButton, out elementSize);
        DrawPos.x += elementSize.x;
        EditorLogger.PauseOnError = ToggleClamped(EditorLogger.PauseOnError, "Error Pause", EditorStyles.toolbarButton, out elementSize);
        DrawPos.x += elementSize.x;
        var showTimes = ToggleClamped(ShowTimes, "Times", EditorStyles.toolbarButton, out elementSize);

        if (showTimes != ShowTimes)
        {
            MakeDirty = true;
            ShowTimes = showTimes;
        }
        DrawPos.x += elementSize.x;
        var collapse = ToggleClamped(Collapse, "Collapse", EditorStyles.toolbarButton, out elementSize);

        if (collapse != Collapse)
        {
            MakeDirty         = true;
            Collapse          = collapse;
            SelectedRenderLog = -1;
        }
        DrawPos.x += elementSize.x;

        ScrollFollowMessages = ToggleClamped(ScrollFollowMessages, "Follow", EditorStyles.toolbarButton, out elementSize);
        DrawPos.x           += elementSize.x;

        var errorToggleContent   = new GUIContent(EditorLogger.NoErrors.ToString(), SmallErrorIcon);
        var warningToggleContent = new GUIContent(EditorLogger.NoWarnings.ToString(), SmallWarningIcon);
        var messageToggleContent = new GUIContent(EditorLogger.NoMessages.ToString(), SmallMessageIcon);

        float totalErrorButtonWidth = toolbarStyle.CalcSize(errorToggleContent).x + toolbarStyle.CalcSize(warningToggleContent).x + toolbarStyle.CalcSize(messageToggleContent).x;

        float errorIconX = position.width - totalErrorButtonWidth;

        if (errorIconX > DrawPos.x)
        {
            DrawPos.x = errorIconX;
        }

        var showErrors = ToggleClamped(ShowErrors, errorToggleContent, toolbarStyle, out elementSize);

        DrawPos.x += elementSize.x;
        var showWarnings = ToggleClamped(ShowWarnings, warningToggleContent, toolbarStyle, out elementSize);

        DrawPos.x += elementSize.x;
        var showMessages = ToggleClamped(ShowMessages, messageToggleContent, toolbarStyle, out elementSize);

        DrawPos.x += elementSize.x;

        DrawPos.y += elementSize.y;
        DrawPos.x  = 0;

        //If the errors/warning to show has changed, clear the selected message
        if (showErrors != ShowErrors || showWarnings != ShowWarnings || showMessages != ShowMessages)
        {
            ClearSelectedMessage();
            MakeDirty = true;
        }
        ShowWarnings = showWarnings;
        ShowMessages = showMessages;
        ShowErrors   = showErrors;
    }
Example #3
0
        void DrawToolbar()
        {
            var toolbarStyle = EditorStyles.toolbarButton;

            var errorToggleContent   = new GUIContent(EditorLogger.NoErrors.ToString(), SmallErrorIcon);
            var warningToggleContent = new GUIContent(EditorLogger.NoWarnings.ToString(), SmallWarningIcon);
            var messageToggleContent = new GUIContent(EditorLogger.NoMessages.ToString(), SmallMessageIcon);

            GUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.Height(100));
            if (GUILayout.Button(new GUIContent("Clear"), EditorStyles.toolbarButton, GUILayout.Width(50), GUILayout.Height(15)))
            {
                EditorLogger.Clear();
            }
            var collapse = GUILayout.Toggle(Collapse, "Collapse", EditorStyles.toolbarButton, GUILayout.Width(65), GUILayout.Height(15));

            if (collapse != Collapse)
            {
                MakeDirty         = true;
                Collapse          = collapse;
                SelectedRenderLog = -1;
            }
            EditorLogger.ClearOnPlay  = GUILayout.Toggle(EditorLogger.ClearOnPlay, "Clear On Play", EditorStyles.toolbarButton, GUILayout.Width(85), GUILayout.Height(15));
            EditorLogger.PauseOnError = GUILayout.Toggle(EditorLogger.PauseOnError, "Error Pause", EditorStyles.toolbarButton, GUILayout.Width(75), GUILayout.Height(15));
            GUILayout.FlexibleSpace();
            Vector2 size         = EditorStyles.toolbarButton.CalcSize(messageToggleContent);
            var     showMessages = GUILayout.Toggle(ShowMessages, messageToggleContent, EditorStyles.toolbarButton, GUILayout.Width(size.x), GUILayout.Height(15));

            size = EditorStyles.toolbarButton.CalcSize(warningToggleContent);
            var showWarnings = GUILayout.Toggle(ShowWarnings, warningToggleContent, EditorStyles.toolbarButton, GUILayout.Width(size.x), GUILayout.Height(15));

            size = EditorStyles.toolbarButton.CalcSize(errorToggleContent);
            var showErrors = GUILayout.Toggle(ShowErrors, errorToggleContent, EditorStyles.toolbarButton, GUILayout.Width(size.x), GUILayout.Height(15));

            GUILayout.EndHorizontal();
            DrawPos.y += 18;
            //var showTimes = ToggleClamped(ShowTimes, "Times", EditorStyles.toolbarButton, out elementSize);
            //if(showTimes!=ShowTimes)
            //{
            //    MakeDirty = true;
            //    ShowTimes = showTimes;
            //}
            //DrawPos.x += elementSize.x;

            //var showChannels = ToggleClamped(ShowChannels, "Channels", EditorStyles.toolbarButton, out elementSize);
            //if (showChannels != ShowChannels)
            //{
            //    MakeDirty = true;
            //    ShowChannels = showChannels;
            //}
            //DrawPos.x += elementSize.x;

            //If the errors/warning to show has changed, clear the selected message
            if (showErrors != ShowErrors || showWarnings != ShowWarnings || showMessages != ShowMessages)
            {
                ClearSelectedMessage();
                MakeDirty = true;
            }
            ShowWarnings = showWarnings;
            ShowMessages = showMessages;
            ShowErrors   = showErrors;
        }