int PrintNumbers(int count) { for (int i = 0; i < count; i++) { RuntimeConsole.Log("number " + i, new Color((i / 255.0f) % 1, 1, 0), true); } return(count); }
public void UnityDebugLog(string logString, string stackTraceString, LogType logType, bool isMainThread, int threadId = -1, System.Diagnostics.StackTrace stackTrace = null, EntryType2 entryType = EntryType2.Unity, bool closeLi = true) { if (!isLogEnabled || sw == null) { return; } // float realTime = timeSinceStartup.ElapsedMilliseconds / 1000f; if (currentFrame != lastFrame) { lastFrame = currentFrame; sw.Write("</ul><br><strong><span style=\"color:#508EA1;"); sw.Write(frameFontSizeString); sw.Write("[Frame "); sw.Write(currentFrame.ToString("D6")); sw.Write("][Time "); sw.Write(Helper.ToTimeFormat(frameTime)); // sw.Write("] ***********************************************************************************************"); sw.Write("] -----------------------------------------------------------------------------------------------"); sw.Write("</span></strong><ul>"); } if (logType == LogType.Error) { sw.Write("<li style =\"color:#FF0000;"); } else if (logType == LogType.Exception) { sw.Write("<li style =\"color:#9D00FF;"); } else if (logType == LogType.Warning) { sw.Write("<li style =\"color:#FFFF00;"); } else if (entryType == EntryType2.Unity) { sw.Write("<li style =\"color:#F0F0F0;"); } else { if (!closeLi) { sw.Write("<li style =\"color:#"); } else { sw.Write("<span style =\"color:#"); } if (entryType == EntryType2.Command) { sw.Write(ColorUtility.ToHtmlStringRGB(Color.green) + ";"); } else if (entryType == EntryType2.CommandResult) { sw.Write(ColorUtility.ToHtmlStringRGB(Helper.colCommandResult) + ";"); } else if (entryType == EntryType2.CommandFault) { sw.Write(ColorUtility.ToHtmlStringRGB(Helper.colCommandResultFailed) + ";"); } } sw.Write(logFontSizeString); if (entryType != EntryType2.Unity) { sw.Write("<strong>"); } // sw.Write(logString.Replace("\n", "<br>")); sw.Write(logString); if (entryType != EntryType2.Unity) { sw.Write("</strong>"); } if (!isMainThread) { sw.Write(" <i>[Thread "); sw.Write(threadId); sw.Write("]</i>"); } sw.Write("</br>"); string[] lines = null; if (logType == LogType.Exception) { sw.Write("<span style=\"color:#7D00DF;"); sw.Write(stackFontSizeString); lines = stackTraceString.Split('\n'); for (int i = 0; i < lines.Length; i++) { sw.Write(lines[i]); if (i < lines.Length - 1) { sw.Write("<br>"); } } sw.Write("</span>"); } else { bool useStackTrace = (entryType == EntryType2.Unity && UseStackTrace(logType)); if (useStackTrace) { if (logType == LogType.Error) { sw.Write("<span style=\"color:#A00000;"); } else if (logType == LogType.Warning) { sw.Write("<span style=\"color:#A0A000;"); } else { sw.Write("<span style=\"color:#909090;"); } sw.Write(stackFontSizeString); int count; if (logType == LogType.Log && normalLogOnlyFirstLineStackTrace) { count = 1; } else { count = stackTrace.FrameCount; } if (RuntimeConsole.instance) { lines = new string[count]; } for (int i = 0; i < count; i++) { var frame = stackTrace.GetFrame(i); if (frame != null) { var method = frame.GetMethod(); string name = method.DeclaringType.Name; sw.Write(name); sw.Write("."); sw.Write(method); if (isEditor || isDebugBuild) { sw.Write(":"); int lineNumber = frame.GetFileLineNumber(); sw.Write(lineNumber); if (RuntimeConsole.instance) { lines[i] = name + "." + method + ":" + lineNumber; } } else if (RuntimeConsole.instance) { lines[i] = name + "." + method; } sw.Write("<br>"); } } sw.Write("</style></span>"); } } if (entryType == EntryType2.Unity) { if (RuntimeConsole.instance) { RuntimeConsole.Log(logString, lines, logType, Color.white, threadId); } } if (closeLi) { sw.Write("</li>"); sw.Write("<span style=\"font-size:9px;\"><br></span>"); } else { sw.Write("</span>"); } sw.Flush(); }