Last active
June 3, 2021 02:48
-
-
Save simonwittber/0f252614052da58972d3cdbb9b01ad9c to your computer and use it in GitHub Desktop.
Unity Logger with Color and Headings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class Logger | |
{ | |
string header; | |
public bool enabled = true; | |
public Logger(string name, string color) | |
{ | |
header = $"<color={color}>{name}:</color>"; | |
} | |
public void Log(string message) | |
{ | |
if(enabled) Debug.Log($"{header} {message}"); | |
} | |
public void Log(string message, params object[] things) => Log($"{message} ({string.Join(" ",things)})"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment