"Unity3d" invoke,invokerepeating, Coroutine deferred call, periodic call

Source: Internet
Author: User

The Invoke and Invokerepeating methods can implement deferred calls, and periodic calls

The first one is executed once and the second one is repeated

void Invoke (String methodName, float time);

The first parameter is the method name (note is in the form of a string) and is not a more convenient delegate. The second one is how many seconds to delay. Executes only once.

void Invokerepeating (String methodName, float time, float repeatrate);

Invokerepeating The second parameter is the number of seconds after which the delay begins, and the third parameter is the second of each execution interval.

The problem with these two functions is that parameters cannot be passed

If you want to pass parameters and implement deferred calls, consider using Coroutine

Startcoroutine (Fun (1, "2", 3.0f,4.0f));

IEnumerator Fun (int arg1, string arg2, float arg3, float delaysecond)

{

Yield return new waitforseconds (Delaysecond);

......

}

"Unity3d" invoke,invokerepeating, Coroutine deferred call, periodic call

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.