示例#1
0
        //function to hook into so OLogger can debug as Unity
        public static void DebugMethodHook(string logString, string stackTrace, LogType type)
        {
            //check if current log string is in ignore list
            foreach (string _toCheck in ignoreList.m_ignoreInDefaultCompiler)
            {
                if (logString.Contains(_toCheck))
                {
                    return;
                }
            }

            //switch type of log into correct colors
            switch (type)
            {
            case LogType.Assert:
                Log(logString, "00ff0ff", "Default Unity Compiler");
                break;

            case LogType.Error:
                Error(logString, "Default Unity Compiler");
                break;

            case LogType.Exception:
                Log(logString, "9999ffff", "Default Unity Compiler");
                break;

            case LogType.Log:
                Log(logString, null, "Default Unity Compiler");
                break;

            case LogType.Warning:
                Warning(logString, "Default Unity Compiler");
                break;

            default:
                break;
            }

            //log the stack trace to panel
            OLogger.Log(stackTrace, null, "Default Unity Stack Trace");
        }
        public DebugBox(string _boxName, Rect _rect, int _maxStoredLines, int _GUIID, bool _writeToDisk)
        {
            //setup basic variables required
            m_BoxName     = _boxName;
            m_showGUI     = false;
            m_writeToDisk = _writeToDisk;

            m_GUIID  = _GUIID;
            maxLines = _maxStoredLines;

            textLines = new List <DebugType>();

            m_offset        = 0;
            m_currentScroll = maxLines;
            m_scrollStart   = m_currentScroll;

            //used to scale GUI at a later point
            m_windowRect   = _rect;
            m_virtualSize  = new Vector2(1920, 1080);
            m_currentSize  = new Vector2(Screen.width, Screen.height);
            m_scaledMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(Screen.width / m_virtualSize.x, Screen.height / m_virtualSize.y, 1));

            //setup GUIStyle
            m_guiStyle          = new GUIStyle();
            m_guiStyle.richText = true;
            m_guiStyle.wordWrap = true;
            m_guiStyle.fontSize = 16;

            //used to setup output string
            m_currentOutputText = "";
            m_updateCurrentText = true;

            if (_writeToDisk)
            {
                //Setup debug text folder
                OLogger.SetupDirectory();

                //Setup debug text file
                m_writer = new StreamWriter("mods/Debug/" + m_BoxName + ".txt", false);
            }
        }
        internal void AddText(string _msg, string _msgColor)
        {
            textLines.Insert(0, new DebugType(m_msgCount.ToString() + ": " + _msg, _msgColor));
            m_updateCurrentText = true;

            //debug info to file
            if (m_writeToDisk)
            {
                if (m_writer == null)
                {
                    OLogger.SetupDirectory();
                    m_writer = new StreamWriter("mods/Debug/" + m_BoxName + ".txt", true);
                }
                m_writer.WriteLine(m_msgCount.ToString() + " :Message: " + _msg);
            }

            m_msgCount++;

            if (textLines.Count > maxLines)
            {
                textLines.RemoveAt(maxLines);
            }
        }