Reputation: 8466
In older versions of Unity (e.g. 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.
Upvotes: 1
Views: 8858
Reputation: 72
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'
Upvotes: 1
Reputation: 8466
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).
Upvotes: 0