public static DebugBox CreateDebugBox(GameObject obj, string _boxName, Rect _rect, int _maxStoredLines, int _GUIID, bool _writeToDisk) { var box = obj.AddComponent <DebugBox>(); //setup basic variables required box.m_BoxName = _boxName; box.m_showGUI = false; box.m_writeToDisk = _writeToDisk; box.m_GUIID = _GUIID; box.maxLines = _maxStoredLines; box.textLines = new List <DebugType>(); box.m_offset = 0; box.m_currentScroll = box.maxLines; box.m_scrollStart = box.m_currentScroll; //used to scale GUI at a later point box.m_windowRect = _rect; box.m_virtualSize = new Vector2(1920, 1080); box.m_currentSize = new Vector2(Screen.width, Screen.height); box.m_scaledMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(Screen.width / box.m_virtualSize.x, Screen.height / box.m_virtualSize.y, 1)); //used to setup output string box.m_currentOutputText = ""; box.m_updateCurrentText = true; if (_writeToDisk) { //Setup debug text folder OLogger.SetupDirectory(); //Setup debug text file box.m_writer = new StreamWriter("mods/Debug/" + box.m_BoxName + ".txt", false); } return(box); }
internal void Start() { // create logger var m_logger = new Vector2(600, 260); OLogger.CreateLog(new Rect(Screen.width - m_logger.x - 5, Screen.height - m_logger.y - 5, m_logger.x, m_logger.y)); // done init ShowMenu = true; OLogger.Log("Initialised Explorer. Unity version: " + Application.unityVersion.ToString()); }
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); } }