Tanoda
SampleUserPolling_JustRead.cs
Go to the documentation of this file.
1
9using UnityEngine;
10
14public class SampleUserPolling_JustRead : MonoBehaviour
15{
16#if !UNITY_WEBGL
18
19 // Initialization
20 void Start()
21 {
22 serialController = GameObject.Find("SerialController").GetComponent<SerialController>();
23 }
24
25 // Executed each frame
26 void Update()
27 {
28 var message = serialController.ReadSerialMessage();
29
30 if (message == null)
31 return;
32
33 // Check if the message is plain data or a connect/disconnect event.
34 if (ReferenceEquals(message, SerialController.SERIAL_DEVICE_CONNECTED))
35 Debug.Log("Connection established");
36 else if (ReferenceEquals(message, SerialController.SERIAL_DEVICE_DISCONNECTED))
37 Debug.Log("Connection attempt failed or disconnection detected");
38 else
39 Debug.Log("Message arrived: " + message);
40 }
41#endif
42}
UnityEngine.Debug Debug
Definition: TanodaServer.cs:19
const string SERIAL_DEVICE_CONNECTED
string ReadSerialMessage()
const string SERIAL_DEVICE_DISCONNECTED