You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.4 KiB
82 lines
2.4 KiB
using UnityEngine;
|
|
|
|
public static class Logger
|
|
{
|
|
[System.Diagnostics.Conditional("UNITY_EDITOR")]
|
|
public static void Log(object message)
|
|
{
|
|
Debug.Log(message);
|
|
}
|
|
|
|
[System.Diagnostics.Conditional("UNITY_EDITOR")]
|
|
public static void Log(object message, Object context)
|
|
{
|
|
Debug.Log(message, context);
|
|
}
|
|
|
|
[System.Diagnostics.Conditional("UNITY_EDITOR")]
|
|
public static void LogError(object message)
|
|
{
|
|
Debug.LogError(message);
|
|
}
|
|
|
|
[System.Diagnostics.Conditional("UNITY_EDITOR")]
|
|
public static void LogError(object message, Object context)
|
|
{
|
|
Debug.LogError(message, context);
|
|
}
|
|
|
|
[System.Diagnostics.Conditional("UNITY_EDITOR")]
|
|
public static void LogWarning(object message)
|
|
{
|
|
Debug.LogWarning(message);
|
|
}
|
|
|
|
[System.Diagnostics.Conditional("UNITY_EDITOR")]
|
|
public static void LogWarning(object message, Object context)
|
|
{
|
|
Debug.LogWarning(message, context);
|
|
}
|
|
|
|
[System.Diagnostics.Conditional("UNITY_EDITOR")]
|
|
public static void DrawArrow2D(Vector3 position, Vector3 direction, float arrowLength, Color color)
|
|
{
|
|
var targetPosition = position + direction.normalized * arrowLength;
|
|
Debug.DrawLine(position, targetPosition, color);
|
|
|
|
Vector3 v = Quaternion.Euler(0, 0, 45) * direction.normalized;
|
|
Debug.DrawLine(targetPosition, targetPosition - v * 0.5f, color);
|
|
|
|
v = Quaternion.Euler(0, 0, -45) * direction.normalized;
|
|
Debug.DrawLine(targetPosition, targetPosition - v * 0.5f, color);
|
|
}
|
|
|
|
public static string LogMessage(LogType logType, string tag, string message)
|
|
{
|
|
Color logColor;
|
|
switch (logType)
|
|
{
|
|
case LogType.Error:
|
|
logColor = Color.red;
|
|
break;
|
|
case LogType.Assert:
|
|
logColor = Color.magenta;
|
|
break;
|
|
case LogType.Warning:
|
|
logColor = Color.yellow;
|
|
break;
|
|
case LogType.Log:
|
|
logColor = Color.white;
|
|
break;
|
|
case LogType.Exception:
|
|
logColor = Color.red;
|
|
break;
|
|
default:
|
|
logColor = Color.white;
|
|
break;
|
|
}
|
|
|
|
return Utility.GetMergeStringWithColor(logColor, string.Format("[{0}] {1}: {2}", logType, tag, message));
|
|
}
|
|
}
|
|
|