Skip to content

Instantly share code, notes, and snippets.

@RimuruDev
Created December 10, 2022 10:31
Show Gist options
  • Save RimuruDev/9090727f16707a2e76dcff3be4d23517 to your computer and use it in GitHub Desktop.
Save RimuruDev/9090727f16707a2e76dcff3be4d23517 to your computer and use it in GitHub Desktop.
Output messages to the Unity console with different colors. #RimuruDev
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum ColorType { Violet, Red, Yellow, Magenta, Cyan }
public static class Console
{
public static void Log(string message, ColorType colorType)
{
switch (colorType)
{
case ColorType.Violet: Debug.Log("-><color=#9400D3>" + $"{message}" + "</color>"); break;
case ColorType.Red: Debug.Log("-><color=#FF4040>" + $"{message}" + "</color>"); break;
case ColorType.Yellow: Debug.Log("-><color=#FFFF00>" + $"{message}" + "</color>"); break;
case ColorType.Magenta: Debug.Log("-><color=#9400D3>" + $"{message}" + "</color>"); break;
case ColorType.Cyan: Debug.Log("-><color=#00EEEE>" + $"{message}" + "</color>"); break;
default:
Debug.Log($"default:{message}");
break;
}
}
public static void Log(string message) => Log(message, ColorType.Red);
public static void Log(string message, string colorHex)
{
Debug.Log($"-><color={colorHex}>" + $"{message}" + "</color>");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment