Last active
December 7, 2018 02:37
-
-
Save baobao/ac6d0ad348f049c069f6096ef0b68e74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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