Skip to content

Instantly share code, notes, and snippets.

@giacomelli
Last active December 2, 2022 05:36
Show Gist options
  • Save giacomelli/bba329d772f4fb7c8e6c9a1d3047bae2 to your computer and use it in GitHub Desktop.
Save giacomelli/bba329d772f4fb7c8e6c9a1d3047bae2 to your computer and use it in GitHub Desktop.
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