I have an Android app developed in C# using Unity and I have an Arduino Nano Board connected to the phone using an OTG cable. I tried running the app in the Unity Player with the COM3-Port on my Windows machine, but whats the serial port on android? I couldn't find anything working yet. I hope someone of you knows how to figure the serial port out.
Asked
Active
Viewed 4,156 times
1
-
Standard C# Serial IO.Ports will **not** run on Android. You have to do know Java to do this.Get Java serial code for Android [here](http://stackoverflow.com/questions/11011515/how-to-read-and-write-data-to-com-serial-ports-in-android) and [here](https://github.com/mik3y/usb-serial-for-android/releases) . Convert code into functions then call them from C#. – Programmer Sep 06 '16 at 15:40
1 Answers
0
You need to use System.IO.Ports namespace and change your android compatibility to .Net 2.0 , not Subset.
Go to Project Settings >> Player and set here to .Net 2.0

joreldraw
- 1,736
- 1
- 14
- 28
-
What exactly do you mean with "use System.IO.Ports namespace"? Sorry I'm not that familiar with C# – fgroeger Sep 06 '16 at 12:59
-
-
@joreldraw `IO.Ports` does not work on Android devices. Op needs to make an Androud plugin with Java then call the functions from Unity(C#). – Programmer Sep 06 '16 at 14:31
-
@Programmer io.ports is compatible with mono Api, how i tell you in the repply you need to change to .Net 2.0 instead os 2.0 Subset and you got. – joreldraw Sep 06 '16 at 14:43
-
1I said, not available **"on Android devices**" . It is available on Windows, Linux and Mac. Not on Android. This question is clearly about Android because it is in the title and tag. It will combine but won't work because there is no binding on the Android side. There are other ways to do this including re-compiling kernel but I am not sure Op can do that.The easiest way is to make a plugin. Please research this before making further comments. – Programmer Sep 06 '16 at 14:50
-
Updated the snapshoot, i forgive to switch platform. Please try what i tell you. If not try i not understand why you tell not available. Yo do it and you can publish Unity to android apk and run your serial port device. – joreldraw Sep 06 '16 at 14:58