12345678910111213141516171819202122232425262728 |
- using System;
- using TMPro;
- using UnityEngine;
- public class HrDisplay : MonoBehaviour{
- public int hrSensorId;
- public TextMeshProUGUI heartRateDisplay;
- private HrReceiver hrReceiver;
- private bool heartRateDisplayAvailable;
- private void Start()
- {
- hrReceiver = new HrReceiver(hrSensorId);
- hrReceiver.StartScan();
- heartRateDisplayAvailable = heartRateDisplay != null;
- }
- private void Update()
- {
- if (heartRateDisplayAvailable)
- {
- heartRateDisplay.text = $"{(hrReceiver?.HeartRate ?? 0):0} bpm";
- }
- }
- }
|