how to synchronize two functions with each other in unity

Hi,

Is there a direct way in unity to synchronizing two functions with each other. For example suppose there are two functions func1() and func2(). func1() invokes func2(). when it does the func1() should suspend automatically and func2() must be executed. once the func2() is done the func1() should continue from the next statement after the func2() was invoked from the func1(). Hope u get the idea.

Thanks.

provided func2() doesn’t start a process which span over several updates, what you want is exactly the default behavior of pretty much all programming languages. If you invoke func2() during func1(), func2() will have to complete before func1() procede to the next statement.

And if does span multiple updates then you can start looking at yield among other things.

Krobil, my func2() does start a process which spans over several updates and the problem i know.

NPSF3000, I will try the yield thing out and will reply here if it works out so that if someone like me is searching then it will be helpful.

Thanks both of you.

Hi, yeah I am getting the desired result using the yield statement. Thanks.