I am trying too use boo and yield sttements my code is
def Start ():
targetLoop()
def targetLoop() as IEnumerator :
for i in range (10):
Debug.Log("here")
yield WaitForSeconds (1)
which does not print out “here” if I comment out the yield it prints “here” 10 times. Tried have the targetLoop return an IEnumerator as recomended for c# no luck, I also tried using
yield return 0;
as recommended For c# but it does not compile.
Does it work if you use StartCoroutine(targetLoop())?
In C# at least, if you try to call a coroutine like a normal function, you don’t get an error, but it just exits at the first yield. Javascript has some magic going on to make it work transparently, but everywhere else you have to call StartCoroutine manually, I believe.
Thanks, that was it. So boo syntax for yield is between C# and Java. Needs start StartCoroutine and has to return IEnumerator like C# but does not need return
The final code that works is
import UnityEngine
import System.Collections
class Yielder (MonoBehaviour):
def Start ():
StartCoroutine(targetLoop())
def targetLoop() as IEnumerator :
for i in range (10):
Debug.Log("here ${i}")
yield WaitForSeconds (1)