lundi 5 novembre 2018

How to get a list of the types of the inputs to a function

I am looking for a way to get the types of the input paramaters to a function when only having the method as a variable. See code below:

public List<MonoScript> Targets;

public const string methodName = "Execute";

private void Start()
{
    foreach (var t in Targets)
    {
        // get the mothod (works)
        var method = t.GetClass().GetMethod(methodName);

        // Get the List of input variables (Does not work)
        var variableTypes = method.GetParameters();

        // Variable list is empty at this stage
        foreach (var variable in variableTypes)
            Debug.Log(variable);
    }
}





Aucun commentaire:

Enregistrer un commentaire