C#中想要知道某句log出自哪个方法名,可采用如下方法:
void TestReflectMethodName() {
Type t;
t = Type.GetType(currentClassName); //参数要填写当前类的名字
var st = new System.Diagnostics.StackTrace();
Debug.Log(st.GetFrame(0).ToString().Split(' ')[0]); //自己截取
Debug.Log(st.GetFrame(0).GetMethod().Name); //从系统属性获取
}
如上方法,两句log打印都是
TestReflectMethodName