Last active
December 2, 2022 05:36
-
-
Save giacomelli/bba329d772f4fb7c8e6c9a1d3047bae2 to your computer and use it in GitHub Desktop.
#unitytips: Dynamic Log - http://diegogiacomelli.com.br/unitytips-dynamic-log
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; | |
/// <summary> | |
/// Dynamic Log - http://diegogiacomelli.com.br/unitytips-dynamic-log | |
/// </summary> | |
public class DynamicLog : MonoBehaviour | |
{ | |
[SerializeField] | |
string _format; | |
public void Log(string message) => Debug.Log(BuildMessage(message)); | |
public void LogWarning(string message) => Debug.LogWarning(BuildMessage(message)); | |
public void LogError(string message) => Debug.LogError(BuildMessage(message)); | |
private string BuildMessage(string message) | |
{ | |
if (string.IsNullOrEmpty(_format)) | |
return message; | |
return string.Format(_format, message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment