hi we use
yield new WaitForSeconds(5);
in java script
how we will use it in c shapr…
its not working in c shapr
hi we use
yield new WaitForSeconds(5);
in java script
how we will use it in c shapr…
its not working in c shapr
thanks for reply
I need to do something like this
function MyCustomFunction()
{
while(true)
{
yield new WaitForSeconds(5);
print("working after 5 second");
}
}
But I could not do that using the Corountines that are mentioned in this link
IEnumerator SomeCoroutine () {
// Wait for one frame
yield return 0;
// Wait for two seconds
yield return new WaitForSeconds (2);
}
I mean how to call it in a separate function rather than Start().
@FizixMan I could not see it in these posts without Start() functions.
but how to implement it in my custom funciton like i mentioned above( MyCustomFunction() ).
please help
Thats how ya use it.
Here’s an example,
http://unity3d.com/support/documentation/ScriptReference/index.Writing_Scripts_in_Csharp.html
using System.Collections;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour {
// C# coroutine
IEnumerator SomeCoroutine () {
// Wait for one frame
yield return 0;
// Wait for two seconds
yield return new WaitForSeconds (2);
}
}