Go Down

Topic: Arduino to Unity - System.IO.Ports does not exist (Read 7046 times) previous topic - next topic


I have a very unique case involving taking output from Arduino to Unity. What I'm trying to do is take output from Arduino, simply a 1 or 0 from button input, into Unity to do something. My arduino code is working and I know it returns 1 or 0 from my button input.

Now most sources say for Unity to take Arduino output as input I have to first access the serial port that Arduino uses. This is done by using the System.IO.Ports namespace through a script. Problem is, System.IO.Ports (specifically the .Ports namespace) does not exist in my version of Unity (5.3 free).

Some sources say switching the .NET framework from a 2.0 subset to 2.0 should resolve the issue. It does not. The namespace .Ports still does not exist in .NET 2.0. Maybe it is due to me using Unity 5.3 Free instead of Pro, as some forums mention the pro version not having this issue (although for older version of Unity - ie. 3.0). If the simplest, 100% sure-fire way of getting this to work is by purchasing Unity pro, just say so and disregard the rest of the post. If not, please suggest an alternative.

I appreciate any responses in advance, and thanks for reading my post.


Thank you so very much for the helpful advice. I never thought to go to the Unity forums for help. What a brilliant idea... /s.


I had the same problem where .Ports namespace did not exist. However for me, switching to the API Compatibility from Subset 2.0 to just 2.0 solved my problems.

For those looking to try this, in Unity:
1) go to file>build settings>player settings and scroll down in the inspector to configuration where you will see .NET 2.0 subset... change that to just 2.0

2) Save everything, close and reboot Unity (sometimes you don't need to do this).

Hope this helps!


Unfortunately, it seems that the new 2018.3 Unity is having trouble again. Simply setting the Subset to 2.0 no longer helps, "Ports" is no longer defined. I was able to have Ports recognized by downloading it from NuGet and adding the .dll to the Plugins folder in Unity. However, when I go to run, it gives the error "PlatformNotSupportedError: System.IO.Ports is currently only supported on Windows". I am running this on the Editor on a Windows computer.


Hello Hooligan_Labs,
did you find a solution for this issue?
I´m having the same problem as discribed at the top of this page...
Currently, I´m using Unity 2018.3.6f1 pro.

Kind regards,


I am also having this same error. I have spent several hours looking for solutions, but nothing has worked. If anyone has a solution please contact me.

Here's my email just in case: diplacido2@sasktel.net


Update: I found a solution that worked for me!

Here is a youtube link:

Note: I had to delete some old unity files that I didn't need before it worked. This may not be important, just thought I would mention it just in case.

Go Up