samedi 19 mai 2018

How to use reflection to get a method with a ref keyword?

Yeah so I set up a little TestClass to figure out what GetMethod would work to actually find the method Test(ref int i). But so far nothing worked.

[Button(nameof(Method))]
public bool whatever;

private void Test(ref int i)
{
    Debug.Log("Works");
}

private void Method()
{
    Type[] types = { typeof(int) };
    MethodInfo methodInfo = GetType().GetMethod(nameof(Test),
        BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static,
        null, types, null);
    Debug.Log(methodInfo);
}

What am I supposed to do? I couldn't find anything on the web so far (for GetMethod specifically)





Aucun commentaire:

Enregistrer un commentaire