Skip to content

Instantly share code, notes, and snippets.

@baobao
Last active Dec 7, 2018
Embed
What would you like to do?
using UnityEngine;
public class SerialSample : MonoBehaviour
{
private SerialPortWrapper _serialPort;
void Awake()
{
_serialPort = new SerialPortWrapper("/dev/cu.usbmodem14101", 9600);
}
private void OnDisable()
{
_serialPort.KillThread();
}
void OnGUI()
{
if (GUILayout.Button("n", GUILayout.Width(200f), GUILayout.Height(60f)))
{
// 文字列nを送信
_serialPort.Write("n");
}
if (GUILayout.Button("f", GUILayout.Width(200f), GUILayout.Height(60f)))
{
// 文字列fを送信
_serialPort.Write("f");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment