- Home /
Coroutine couldn't be started! [BOO]
Hi! I'm a newbie and think BOO's great. So I have some test try to put a Coroutine Function into a Variable. What's the "Coroutine couldn't be started!". Please?
There script has been copyed and changed form Unity3d Document. http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.StartCoroutine.html
import UnityEngine
import System.Collections
class Parent (MonoBehaviour):
public cmd as callable(single) as IEnumerator
def Awake ():
cmd = WaitAndPrint
return
def Start ():
print(('Starting ' + Time.time))
StartCoroutine('cmd', 2.0)
//Coroutine 'cmd' couldn't be started!
//UnityEngine.MonoBehaviour:StartCoroutine(String, Object)
//Test:Start() (at Assets/Test.boo:15)
print(('Before WaitAndPrint Finishes ' + Time.time))
def WaitAndPrint(waitTime as single) as IEnumerator :
yield WaitForSeconds(waitTime)
print(('WaitAndPrint ' + Time.time))
Any help will be deeply appreciated.
You're trying to start a coroutine named 'cmd' - but you don't have a function in your file with that name.
@Fla$$anonymous$$gHairball he has defined cmd as a function pointer in Awake so calling cmd() should be just like calling the function it points to ( WaitAndPrint() ), at least this is how I read the code.
Yes, that's what he does. He created a function pointer / delegate that is named "cmd", but it's not a function, it's a variable. The string version of StartCoroutine will try to execute a function on the script with that name that doesn't exist.
Answer by DannyB · Jun 25, 2012 at 04:05 PM
I am not writing in Boo, but shouldn't it be one of these:
StartCoroutine('WaitAndPrint', 2.0F);
or
StartCoroutine( cmd(2.0F) );
Yes, i guess it should be something like that ;) But i'm also not a Boo user (who is? :D).
It's not a bad thing to use Boo, but most people use UnityScript or C#. There are only a few Boo users out there, so don't expect too much help here ;)
Since boo is also some kind of a standardized .NET language, you might get more help on boo forums or the developer page.
However what the OP has tried here won't work in any language that is supported by Unity.
Answer by nirenyang1 · Jun 26, 2012 at 07:28 AM
Thanks all of you.
Danny is right. I thought that's the different usage by the same function. It's seems I was wrong.
BTW, I known C# has more users. My chosen is follow my heart :) I will try it until forced to face some big problem.
Best regards!
Oops~ I found that green tick Finally :) Thank you $$anonymous$$izuho~
Your answer
Follow this Question
Related Questions
Rerun a script after it finishes, when it already has multiple Coroutines? 1 Answer
How to change this using a coroutine 1 Answer
Starting and stopping Coroutines 1 Answer
Adding a coroutine to an event? 6 Answers
Ienumerator wait for event 0 Answers