Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Fliperamma · Jul 01, 2013 at 02:20 PM · coroutinestartcoroutinemissingmethodexception

StartCoroutine("MyMethod", parms) and MissingMethodException: Cannot find method MyMethod

 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.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image aldonaletto · Jul 01, 2013 at 02:53 PM 0
Share

Is this your actual code? Apparently it can enter an endless loop: DoSomething starts coroutine $$anonymous$$y$$anonymous$$ethod, which in turn calls DoSomething, and so on.

avatar image ovidiubuligan · Feb 16, 2014 at 01:55 PM 0
Share

I am getting the same issue but only when running on wp8

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by SubatomicHero · Jul 01, 2013 at 02:35 PM

You are searching for the coroutine using the string version of the argument. Why don't you call it by passing in the method name directly which is more effecient:

 // instead of:
 StartCoroutine("MyMethod", parms);
 
 // do this:
 StartCoroutine(MyMethod(parms));
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fliperamma · Jul 01, 2013 at 02:40 PM 2
Share

Hi!, thank you for your answer. The reason that I'm not using this approach is that I can't Stop my Coroutines.

Please note that only StartCoroutine using a string method name can be stopped using StopCoroutine.

avatar image SubatomicHero · Jul 01, 2013 at 02:42 PM -1
Share

To be honest, you should know when the coroutine will stop or the code inside the coroutine should perform fully and then stop by itself. Are you sure you need a coroutine?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why doesnt my coroutine ever end? 2 Answers

yield return M() vs yield return StartCoroutine 2 Answers

Is there any performance differences between Coroutine methods ? 3 Answers

Can I use StartCoroutine inside of the same coroutine with a new variable? 0 Answers

Stop a coroutine on a single gameobject 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges