Hey guys, I hope everyone is working on something cool.
I am trying to write the following code in C# but cant figure out the syntax, if you know the syntax or better yet point me to a resource where I can look this type of stuff up in the future without bothering everyone, that would be great thanx.
This is a Javascript version of what I want to create in C#
private var dead : boolean = false;
function Start(){
while(true){
while(!dead) yield;
Debug.Log("dead");
dead = false;
}
}
And this is what I have in C# but as you can see, I am writing the yield part wrong.
bool dead = false;
void Start(){
StartCoroutine(Run());
}
IEnumerator Run() {
while(true){
while(!dead) yield;????
Debug.Log("dead");
dead = false;
}
}
Well first off, you’re certainly not bothering anyone here. In fact, for my case, you’re helping me become a better programmer by troubleshooting other people’s code. It’s actually a great learning exercise.
Let me help you with a great resource, Unity - Scripting API:. This is the API of Unity.
Now, back to your question, the yield is wrong. I don’t think you know exactly what the Yield is supposed to be doing (I say that but I could be wrong).