I wonder if anyone has experienced the problem on Mac. I tried to use Arduino to communicate with Unity 4 (just a simple test sending a sensor value to Unity via serial communication).
It works perfectly fine on Windows, but on Mac, I got "IOException: No such file or directory " error.
Open your Terminal and search ls /dev/tty.* to find the serial port for your Arduino. It will look something like /dev/tty.usbmodem1411. Then replace COM3 in the above script with /dev/tty.usbmodem1411 or whatever your search showed.
You should also make sure that you’ve changed the below setting;
Edit > Project Settings > Player > Other Settings > Api Compatibility Level > NET 4.x.