System.IO.ports 适用于 Unity 但不适用于构建

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

我在 Unity 中拼凑了一个需要访问串行端口的小应用程序。由于 Unity 不包含 System.IO.Ports,因此我使用 NugetForUnity 安装了 NugetPackage。在引擎中一切正常,但如果我构建项目,它就不能再使用 System.IO.Ports。

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 

我通过将“脚本后端”更改为“Mono”并在 Visual Studio 中构建解决方案来实现它。