1
0
mirror of synced 2024-12-11 22:15:58 +01:00
WACVR/Assets/Script/ColliderToSerial.cs
2022-05-16 23:38:40 +02:00

28 lines
680 B
C#

using UnityEngine;
using System.IO.Ports;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
public class ColliderToSerial : MonoBehaviour
{
private int _insideColliderCount = 0;
private void OnTriggerEnter(Collider other)
{
_insideColliderCount += 1;
Serial.SetTouch(Convert.ToInt32(gameObject.name), true);
}
private void OnTriggerExit(Collider other)
{
_insideColliderCount -= 1;
_insideColliderCount = Mathf.Max(0, _insideColliderCount);
if (_insideColliderCount == 0)
{
Serial.SetTouch(Convert.ToInt32(gameObject.name), false);
}
}
}