the task is to get data from the COM port. I wrote the C # code for the console application directly according to the MSDN manual and everything works fine.

using System; using System.IO.Ports; class PortDataReceived { public static void Main() { SerialPort SP = new SerialPort("COM3",38400){ DataBits = 8 }; SP.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler); SP.Open(); mySerialPort.Close(); } private static void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e) { SerialPort sp = (SerialPort)sender; int B = sp.ReadByte(); // Мой код для обработки полученных данных } } 

Now about Unity. When I try to use SP.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler); in Unity, this code does not work. I assume that in Unity event SP.DataReceived is not implemented.

I ask the help in search of alternative of the pure C # code for Unity. Preferably your code and not through the Update method of MonoBehaviour , since it is executed when the scene is updated, and I need to constantly update the information received from the COM port, like the DataReceived event.

    0