Files
2025-11-30 08:35:03 +02:00

63 lines
1.9 KiB
C#

using UnityEngine;
namespace Needle.Engine.Utils
{
public static class LogHelpers
{
public static void LogWithoutStacktrace(object message, Object context = null)
{
Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, context, "{0}", message);
}
public static void ErrorWithoutStacktrace(object message, Object context = null)
{
Debug.LogFormat(LogType.Error, LogOption.NoStacktrace, context, "{0}", message);
}
public static void WithoutStacktrace(LogType type, object message, Object context = null)
{
Debug.LogFormat(type, LogOption.NoStacktrace, context, "{0}", message);
}
public static string AsLink(this string str, string href = null)
{
return "<a href=\"" + (href ?? str) + "\">" + str + "</a>";
}
public static string AsError(this string str)
{
return "<color=#ff2222>" + str + "</color>";
}
public static string AsSuccess(this string str)
{
return "<color=#00dd00>" + str + "</color>";
}
public static string Highlight(this string str)
{
#if UNITY_EDITOR
var highlightColor = UnityEditor.EditorGUIUtility.isProSkin ? "#a4d501" : "#6d0198";
#else
var highlightColor = "#a4d501";
#endif
return "<b><color=" + highlightColor + ">" + str + "</color></b>";
}
public static string LowContrast(this string str)
{
if (str.Contains("\n")) str = str.Replace("\n", "</color>\n<color=#888888>");
return "<color=#888888>" + str + "</color>";
}
#if UNITY_EDITOR_WIN
// public static readonly string NeedlePrefix = "\u2688 ".Highlight();
// public static readonly string NeedlePrefixError = "<b>\u2688 </b>".AsError();
public static readonly string NeedlePrefix = "\u25CF ".Highlight();
public static readonly string NeedlePrefixError = "<b>\u25CF </b>".AsError();
#else
public static readonly string NeedlePrefix = "\u25a0 ".Highlight();
public static readonly string NeedlePrefixError = "<b>\u25a0 </b>".AsError();
#endif
}
}