This is going to be a complex post that isn’t as simple as you might think. I need to take output from Arduino as input on Unity. What I’ve gather is that I need to access my serial ports with System.IO.Ports, but as you’ve guessed from this post, System.IO.Ports does not exist.
I’ve searched for several hours now and I have narrowed down the issue: I have to switch to .NET 2.0 from .NET 2.0 subset. I’m using .NET 2.0 subset because it allows me to use unsafe code in my scripts. I have a smcs.rsp file with “-unsafe” in it which is the only way I’ve found that Unity allows me to use unsafe code (reason is explained below). Now I know .NET 2.0 subset does not have System.IO.Ports by default, so my question is:
How can I gain access to System.IO.Ports namespace without switching to .NET 2.0?
Before you mention compiling with unsafe through visual studio and just sticking with .NET 2.0, I have already tried that. I have come across a very bizarre situation in Visual Studio in that VS does not allow me to access my properties to allow compiling in unsafe. If I try to right click my script in VS and go to project properties, it doesn’t do anything. I’ve seen 100s of posts saying the same thing, right-click project → project properties → compile with unsafe, it just doesn’t work for me and I have received no solution in the VS forums either.
So unless there’s a way to use unsafe code in Unity without compiling in unsafe with VS, all the while using .NET 2.0, please enlighten me. Otherwise, I am truly lost like Theon Greyjoy.