I am trying to use an arduino to control a game in Unity. Whenever the arduino is writing to the serial monitor and I hit play on my game in Unity, it throws an IOException at the point when the execution gets to the point where I say ArduinoPort.open() in the C# code for Unity. Although sometimes when I plug in the Arduino, it does not start executing the sketch right away unless I re-upload the sketch. So whenever this happens, I hit play in Unity in the meanwhile after which I re-upload the sketch to Arduino to make it run again and it works perfectly without thrwoing any exception, doing what I want it to. Please tell me what is going on and what I could do. Any help would be greatly appreciated.