// Displays a collapsed message with a specific button skin
    void displayCollapsedMessage(CollapsedMessage cmessage, GUISkin skin, bool isSelected)
    {
        LogMessage message = cmessage.message;

        GUILayout.BeginHorizontal();

        bool selected = drawIconLabel(cmessage.message.type,skin);

        float unselectedWidth = 0.025f;

        // The Log
        selected |= GUILayout.Button(message.log, skin.button, GUILayout.Width(_labelWidth * 0.65f), GUILayout.Height(_labelHeight));

        skin.button.alignment = TextAnchor.MiddleCenter;

        // Counter
        selected |= GUILayout.Button("#" + cmessage.counter, skin.button, GUILayout.Width(_labelWidth * 0.15f), GUILayout.Height(_labelHeight));

        // Tag
        selected |= GUILayout.Button(message.tag, skin.button, GUILayout.Width(_labelWidth * 0.14f), GUILayout.Height(_labelHeight));

        // Unselect
        if (isSelected && GUILayout.Button("X", skin.button, GUILayout.Width(_labelWidth * unselectedWidth), GUILayout.Height(_labelHeight)))
        {
        _data.selectedLogMessage = new LogMessage();
        }

        skin.button.alignment = TextAnchor.UpperLeft;

        if(selected)
        {
          if (_data.selectedCollapsedMessage.message.hashKey() == cmessage.message.hashKey())
        _data.goToSelectedLog(cmessage.message); // Jump to Line
          else
        _data.selectedCollapsedMessage = cmessage;
        }

        GUILayout.EndHorizontal();
    }
Exemple #2
0
  private static void Log(string log, string tag, SMLogType type, string stackTrace)
  {
#if UNITY_EDITOR
    LogMessage message;
    SMConsoleData _data = SMConsoleData.Instance;

    if (stackTrace == StackTraceEntry.EMPTY_STACK_TRACE)
      message = new LogMessage(log, tag, type,Environment.StackTrace);
    else
      message = new LogMessage(log, tag, type, stackTrace);

    _data.logs.Add(message);

    _data.logCounter[(int)type]++;

    string hashKey = message.hashKey();

    if (!_data.collapsedHash.ContainsKey(hashKey))
    {
      CollapsedMessage collapsed = new CollapsedMessage(message);
      _data.collapsedHash.Add(hashKey, collapsed);
    }
    else
    {
      CollapsedMessage collapsed = _data.collapsedHash[hashKey];
      collapsed.counter++;
      _data.collapsedHash[hashKey] = collapsed;
    }

    if (!_data.tags.Contains(message.tag))
    {
      _data.tags.Add(message.tag);
      _data.selectedTags.Add(message.tag);
    }

    // See if should be added to currently showing
     if (_data.searchFilter == SMConsoleData.DEFAULT_SEARCH_STR || _data.searchFilter == "")
    {
      _data.showingLogs.Add(message);
    }
    else
    {
       if(!_data.canCollapse)
       {
         if(message.log.IndexOf(_data.searchFilter, StringComparison.OrdinalIgnoreCase) >= 0)
            _data.showingLogs.Add(message);
       }
       else if(_data.collapsedHash[hashKey].counter == 1) // first instance
       {
         if (message.log.IndexOf(_data.searchFilter, StringComparison.OrdinalIgnoreCase) >= 0)
           _data.showingLogs.Add(_data.collapsedHash[hashKey]);
       }
    }
        if(_data.mainEditorConsole != null)
        {
            _data.mainEditorConsole.Repaint();
        }

#endif
  }
Exemple #3
0
    private void init()
    {
        // Initialize counter
        logCounter[(int)SMLogType.NORMAL] = 0;
        logCounter[(int)SMLogType.WARNING] = 0;
        logCounter[(int)SMLogType.ERROR] = 0;

        // init log arrays
        logs = new ArrayList();
        showingLogs = new ArrayList();
        tags = new ArrayList();
        selectedTags = new ArrayList();
        collapsedHash = new Dictionary<string, CollapsedMessage>();

        selectedLogMessage = new LogMessage();
        selectedCollapsedMessage = new CollapsedMessage(new LogMessage());

        canCollapse = false;
        canClearOnPlay = false;
        showWarnings = true;
        showErrors = true;
        showLogs = true;
        searchFilter = DEFAULT_SEARCH_STR;
    }