ArduinoHandler.cs
672 Bytes
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ArduinoHandler : MonoBehaviour
{
public SerialHandler serialHandler;
void Start()
{
serialHandler.OnDataReceived += OnDataReceived;
}
void Update()
{
//Write Something
serialHandler.Write("");
}
void OnDataReceived(string message)
{
var data = message.Split(
new string[]{"\t"}, System.StringSplitOptions.None);
if (data.Length < 2) return;
try {
// Do Something
} catch (System.Exception e) {
Debug.LogWarning(e.Message);
}
}
}