mirror of
https://github.com/xiaopeng12138/MaiDXR.git
synced 2024-11-24 12:00:09 +01:00
25 lines
601 B
C#
25 lines
601 B
C#
using UnityEngine;
|
|
|
|
public class TouchToSerial : MonoBehaviour
|
|
{
|
|
public int Area;
|
|
private int _insideColliderCount = 0;
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
Serial.ChangeTouch((int)Area, true);
|
|
Serial.SendTouch();
|
|
_insideColliderCount += 1;
|
|
}
|
|
|
|
private void OnTriggerExit(Collider other)
|
|
{
|
|
if (_insideColliderCount == 0)
|
|
{
|
|
Serial.ChangeTouch((int)Area, false);
|
|
Serial.SendTouch();
|
|
}
|
|
_insideColliderCount -= 1;
|
|
_insideColliderCount = Mathf.Max(0, _insideColliderCount);
|
|
}
|
|
}
|