1
0
mirror of https://github.com/xiaopeng12138/MaiDXR.git synced 2024-11-28 04:50:48 +01:00
MaiDXR/Assets/Scripts/TouchToSerial.cs

25 lines
601 B
C#
Raw Normal View History

2022-01-05 19:44:30 +01:00
using UnityEngine;
public class TouchToSerial : MonoBehaviour
{
public int Area;
private int _insideColliderCount = 0;
2022-01-05 20:38:10 +01:00
private void OnTriggerEnter(Collider other)
2022-01-05 19:44:30 +01:00
{
Serial.ChangeTouch((int)Area, true);
Serial.SendTouch();
2022-03-15 17:15:34 +01:00
_insideColliderCount += 1;
2022-01-05 19:44:30 +01:00
}
2022-01-05 20:38:10 +01:00
private void OnTriggerExit(Collider other)
2022-01-05 19:44:30 +01:00
{
if (_insideColliderCount == 0)
{
Serial.ChangeTouch((int)Area, false);
Serial.SendTouch();
}
2022-03-15 17:15:34 +01:00
_insideColliderCount -= 1;
_insideColliderCount = Mathf.Max(0, _insideColliderCount);
2022-01-05 19:44:30 +01:00
}
}