Hello.
the script in js like this:
var a : GameObject;
a = GameObject.Find("xxx");
yield a;
if(a) {
Destroy(a);
}
How do translate it to C#?
Regard
:shock:
Hello.
the script in js like this:
var a : GameObject;
a = GameObject.Find("xxx");
yield a;
if(a) {
Destroy(a);
}
How do translate it to C#?
Regard
:shock:
Why do you need yield? You simply want to destroy the object if you find it, no? =)
Thank you for your reply.
in javascript, use ‘yield’ because ‘GameObject.Find’ function performance need spend more time.
if you do not use ‘yield’, the code will continue and the gameObject still null.
Thanks.
Ok, I find by myself, write like this:
yield return A;
it work fine in C#
What? GameObject.Find is no asynchronous method, if it returns null the searched object simply dont exist, maybe the GameObject is not yet created, but will be created before the coroutines will start executing. This basically means that the yield will only hide an other problem.