In older versions of Unity (eg v5), I used to solve this issue by setting
Edit > Project Settings > Player > PC setting (icon) > Other Settings > API Compatibility Level
from .Net 2.0 Subset to .Net 2.0
but in Unity 2018.3.2f1, this doesn't solve the issue. I also set the same setting to .Net 4.x but it didn't help.
Note 1 : My build settings is set to Android platform but I need SerialPort class from System.IO.Ports namespace in order to read the serial port while running the game in the Unity Editor (PC). I have done this before with Unity 5.
Note 2 : I cannot manually add a reference to the related assembly in the Visual Studio project made by Unity. The command is removed.
Go to Edit->projectsettings->Player->APIcompetibilityLevel = .Net4.x This worked for me.
check out this -> The type or namespace name 'Ports' does not exist in the namespace 'System.IO'
I came up with a workaround:
By doing that, Unity adds the required assembly to 'Assembly-CSharp-Editor' project (which is related to running game inside Unity Editor).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.