87 lines
1.6 KiB
C#
87 lines
1.6 KiB
C#
using UnityEngine;
|
|
namespace G
|
|
{
|
|
public enum Colors
|
|
{
|
|
aqua,
|
|
black,
|
|
blue,
|
|
brown,
|
|
cyan,
|
|
darkblue,
|
|
fuchsia,
|
|
green,
|
|
grey,
|
|
lightblue,
|
|
lime,
|
|
magenta,
|
|
maroon,
|
|
navy,
|
|
olive,
|
|
purple,
|
|
red,
|
|
silver,
|
|
teal,
|
|
white,
|
|
yellow
|
|
}
|
|
|
|
public static class StringLoggingExtensions
|
|
{
|
|
public static string ColoredForLog(this string message, Colors color)
|
|
{
|
|
return message;
|
|
}
|
|
|
|
public static string ColoredForLog(this string message, Color32 color)
|
|
{
|
|
return message;
|
|
}
|
|
|
|
public static string ColoredForLog(this string message, string colorCode)
|
|
{
|
|
return message;
|
|
}
|
|
|
|
public static string Colored(this string message, Colors color)
|
|
{
|
|
return $"<color={color.ToString()}>{message}</color>";
|
|
}
|
|
|
|
public static string Colored(this string message, Color32 color)
|
|
{
|
|
return $"<color={ColorToHex(color)}>{message}</color>";
|
|
}
|
|
|
|
public static string Colored(this string message, string colorCode)
|
|
{
|
|
return $"<color={colorCode}>{message}</color>";
|
|
}
|
|
|
|
public static string ColorToHex(Color32 color)
|
|
{
|
|
return string.Format("#{0}{1}{2}", color.r.ToString("X2"), color.g.ToString("X2"), color.b.ToString("X2"));
|
|
}
|
|
|
|
public static string Sized(this string message, int size)
|
|
{
|
|
return $"<size={size}>{message}</size>";
|
|
}
|
|
|
|
public static string Bold(this string message)
|
|
{
|
|
return $"<b>{message}</b>";
|
|
}
|
|
|
|
public static string Italics(this string message)
|
|
{
|
|
return $"<i>{message}</i>";
|
|
}
|
|
|
|
public static string LimitTo(this string data, int length)
|
|
{
|
|
return (data != null && data.Length >= length) ? data.Substring(0, length) : data;
|
|
}
|
|
}
|
|
}
|