Search code examples
unity-game-enginenuget-package

System.IO.ports works in Unity but not in build


I threw together a little application in Unity which needs to access a serial port. Since Unity does not include System.IO.Ports I installed the NugetPackage with NugetForUnity. Everything works fine in the engine but if I build the project it somehow can't use System.IO.Ports anymore.

BuildSettings enter image description here

NotSupportedException: System.IO.Ports.SerialPort::.ctor
at System.IO.Ports.SerialPort..ctor (System.String portName, System.Int32 baudRate, System.IO.Ports.Parity parity, System.Int32 dataBits, System.IO.Ports.StopBits stopBits) [0x00000] in <00000000000000000000000000000000>:0 
at GetInput.Start () [0x00000] in <00000000000000000000000000000000>:0 

Solution

  • I got it to work by changing the "Scripting Backend" to "Mono" and building the solution in Visual Studio.