[Unity] RS232 Serial(유니티 RS232 시리얼 통신)
by Sugar0810※ Api Compatibility Level 설정
Project Setting - Player - Other Settings - Configuration - Api Compatibility Level - .NET Framework
※ DemoSerialCommuncation.cs
using UnityEngine;
using System;
using System.IO.Ports;
public class DemoSerialCommuncation : MonoBehaviour
{
SerialPort m_SerialPort = new SerialPort("COM3", 9600, Parity.None, 8, StopBits.One);
string m_Data = null;
void Start()
{
m_SerialPort.Open();
}
private void Update()
{
try
{
if (m_SerialPort.IsOpen)
{
m_Data = m_SerialPort.ReadLine();
m_SerialPort.ReadTimeout = 30;
}
}
catch (Exception e)
{
Debug.Log(e);
}
}
void OnApplicationQuit()
{
m_SerialPort.Close();
}
}
※ 참고 사이트
'⚙️ Programming > C# & Unity' 카테고리의 다른 글
[Unity AR] Import Vuforia Model Target SDK (0) | 2023.08.14 |
---|---|
[Unity] URP-Based Water Shader(Feat.Boat Attack) (유니티 URP 모바일 최적화 물 셰이더 간단 적용) (0) | 2023.08.14 |
[Unity] Arduino Serial(유니티 아두이노 시리얼 통신) (0) | 2023.08.14 |
[Unity XR] Android Build Setting(유니티 XR 안드로이드 최적화) (0) | 2023.08.14 |
[Unity XR] XRI Input Action Custom Binding (0) | 2023.08.14 |
블로그의 정보
Sugar
Sugar0810