0

I have two functions.The first function takes 2 seconds. Second function must wait until the second will finish. This is my following code.

     void Update(){

      StartCoroutine("something");

        }

     IEnumerator something()
        {
           First();
           yield return null;
             Second();

        }
        void First(){
                      for(long i=0;i<2131232123123123;i++){
                          print(i);
}
        }
        void Second(){print("Done");}
Egyu Hook
  • 33
  • 1
  • 8
  • 1
    @Programmer where I have to add `yield return new WaitForSeconds(2);`After `First` or before `First` – Egyu Hook Jul 31 '17 at 09:50
  • 1
    *"Second function must wait until the second will finish"* This does not even make sense. Please edit your question and explain this. Also add why the function will wait for 2 seconds and this will help you get a proper solution. Note that you use coroutine functions to wait not a void function. – Programmer Jul 31 '17 at 09:54
  • I use your dublicate question for edit. So is that would wait 2 seconds? – Egyu Hook Jul 31 '17 at 10:03
  • I don't need wait exactly 2 seconds. But The first function takes some more time. So how to wait until `first` will finish? After then the second must start. Is that possible? – Egyu Hook Jul 31 '17 at 10:10
  • Yes, it it. It is called chaining coroutines. I added another duplicate link to this question. Check the second link I just added. It has an example of how to make functions call each other after another. – Programmer Jul 31 '17 at 10:18

0 Answers0