|
I want to live a GameObject for some seconds before destroy it.I saw the code by c# like this in documentation: IEnumerator Awake() { print(Time.time); yield return new WaitForSeconds(5); print(Time.time); } how to use this code? If I put it in my code like this: void update(){ ...... Awake(); ...... } It is not called.Noting happen! If I put it like this void update(){ ..... yield return new WaitForSeconds(5); ...... } There is a error like this : error CS1624: The body of If I put it like this: void update(){ ..... yield new WaitForSeconds(5); ...... } There is a red line . How to use this WaitForSeconds?Thanks!
(comments are locked)
|
|
Or just: If I want to play an animation after that,how to do ?
Aug 03 '11 at 06:35 AM
noob22
You could queue the animation to start in 5 seconds. In Javascript, yield is actually really easy too: The C# isn't much difference, but if you're struggling with it, I'd suggest using Javascript.
Aug 03 '11 at 06:38 AM
Waz
I want to know the difference between c# and Js.Because I dont know where the function I should put.When I put it in update(),it dont work like having not be called.
Aug 03 '11 at 06:53 AM
noob22
StartCoroutine(Awake());It is called like this!
Aug 03 '11 at 07:23 AM
noob22
(comments are locked)
|
