MissingMethodException: Cannot find method MyMethod.
System.MonoType.InvokeMember (System.String name, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object target, System.Object args, System.Reflection.ParameterModifier modifiers, System.Globalization.CultureInfo culture, System.String namedParameters) (at /Applications/buildAgent/work/84669f285f6a667f/mcs/class/corlib/System/MonoType.cs:520)
UnityEngine.SetupCoroutine.InvokeMember (System.Object behaviour, System.String name, System.Object variable)
UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
I’m having this problem when I call my Coroutine. If I remove the “object” parameter from the code, or change it to a float parameter (for example) it works fine. . . The strangest thing is that I’m using the exact same approach in another class and there this issue doesn’t happen Oo
Heres my code snippet:
public void DoSomething(int someParam, bool temp = false, float tempSeconds = 5f)
{
actualParam = someParam;
StopCoroutine("MyMethod");
object[] parms = new object[2]{temp, tempSeconds};
StartCoroutine("MyMethod", parms);
}
IEnumerator MyMethod(object[] parms)
{
// Do something
yield return new WaitForSeconds(0.1f);
// Do something else after 0.1
if((bool)parms[0] == true)
{
yield return new WaitForSeconds((float)parms[1]);
// Do Something else
DoSomething (actualParam*2);
}
}
*EDIT:
Sorry, I forgot to mention that:
- I’m now caching the parameters outside the functions so I can get it working OK, but the issue still exists;
- I’m using Unity PRO 4.1.5f.