I want to make a simple debug tool that prints a variable and can be used anywhere inside my project:
public static DebugUtils {
public static Log(object obj) {
Debug.Log(GetOriginalVariableName(obj) + "=" + obj);
}
private static GetOriginalVariableName(object) {
...
}
}
so in a class I can do:
public class MyClass {
public void Foo {
string mySpecialString = "abc";
DebugUtils.Log(mySpecialString);
}
}
and this will print (what I want):
mySpecialString=abc
I can find similar answer here, but it has to be in a same class, otherwise it prints this (what I DON'T want):
obj=abc
It grabs the variabale name of DebugUtils.Log instead... Any idea or builtin c# function so I can achieve this?
P.S. I'm in Unity 5 which using C# 5