So I’ve been getting some help on Unity Answers about inputting yield and coroutines in my code. (Yield Script Update Error - Questions & Answers - Unity Discussions)
Right now, the start of my code looks like this.
void Start ()
{
OSCHandler.Instance.Init ();
servers = new Dictionary<string, ServerLog> ();
particleSystem.emissionRate = 0;
StartCoroutine(BongoClap());
}
IEnumerator BongoClap () {
while (true) {
// Rest of my code...
However, now I’m getting an error.
Assets/Scripts/UnityOSC-master/BoncoClapScript.cs(78,51): error CS0019: Operator
||' cannot be applied to operands of typebool’ and `UnityEngine.KeyCode’
It seems to be having a problem with the || operators in this line of code…
if (Input.GetKeyDown (KeyCode.JoystickButton0) || (KeyCode.JoystickButton1) || (KeyCode.JoystickButton2) || (KeyCode.JoystickButton3)) {
yield return new WaitForSeconds(5.0f);
yield return null;
}
Any idea why this might be happening? :S
Okay... Now I'm confused. I input that small change of code and now every time I run Play, Unity doesn't work... At all. No errors or anything. Unity just freezes indefintely and stops working. It's definitely an issue with the code I have now because I saved a copy of the code I had before I began using coroutines and it works fine. I'm not sure what is so game breaking about this code. It seems to make sense...
– SuperSparkplugYou've got the yield return null in the wrong place probably. To be absolutely sure, put it right at the top of the while(true) loop. the first statement.
– whydoidoitIt works! Thank you so much! :)
– SuperSparkplug