1
0
mirror of https://github.com/xiaopeng12138/MaiDXR.git synced 2025-02-17 19:19:15 +01:00
MaiDXR/Assets/Scripts/TouchToSerial.cs
xpeng 27bc229b4c Add frame rate limit to none vr view and update touch serial backend
huge thanks to people who contribute to WACVR
2022-07-03 01:17:05 +02:00

26 lines
685 B
C#

using UnityEngine;
using System;
public class TouchToSerial : MonoBehaviour
{
public int Area;
private int _insideColliderCount = 0;
public static event Action touchDidChange;
private void OnTriggerEnter(Collider other)
{
_insideColliderCount += 1;
Serial.ChangeTouch(true, (int)Area, true);
touchDidChange?.Invoke();
}
private void OnTriggerExit(Collider other)
{
_insideColliderCount -= 1;
_insideColliderCount = Mathf.Max(0, _insideColliderCount);
if (_insideColliderCount == 0)
{
Serial.ChangeTouch(true, (int)Area, false);
touchDidChange?.Invoke();
}
}
}