I can get method name by JavaScript
XXX.Method.Name;
but it’s not working in C#
I can get method name by JavaScript
XXX.Method.Name;
but it’s not working in C#
You can get the current method you are in like this I think:
using UnityEngine;
//this is important to use
using System.Reflection;
public class example : MonoBehaviour {
void Start () {
MethodBase methodBase = MethodBase.GetCurrentMethod();
Debug.Log(methodBase.Name); //prints "Start"
}
}
and not current method by:
using UnityEngine;
using System;
public class exampled : MonoBehaviour {
void Start () {
System.Func<float,int> fooFunc = this.yeah;
Debug.Log(fooFunc.Method.Name); // prints "yeah"
}
int yeah (float x) {
return 0;
}
}
You need to declare the method as public…
i.e
public void MyMethod()
{
Debug.Log("MyMethod was called");
}