Fix double click on ToggleAR
This commit is contained in:
@@ -1,14 +1,26 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class ARToggleButton: MonoBehaviour
|
||||
public class ARToggleButton: MonoBehaviour, IPointerDownHandler
|
||||
{
|
||||
public OVRPassthroughLayer passthroughLayer;
|
||||
private bool pressed = false; //efix variable da button 2 mal pressed wird ??
|
||||
public GameObject raceTrack;
|
||||
|
||||
float lastClickTime = -1f;
|
||||
const float debounceTime = 0.3f; // 300ms Sperre
|
||||
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
if (Time.time - lastClickTime < debounceTime)
|
||||
return; // Ignoriere doppeltes Event
|
||||
|
||||
lastClickTime = Time.time;
|
||||
TogglePassthrough();
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
gameObject.GetComponent<Button>().onClick.AddListener(TogglePassthrough);
|
||||
|
||||
Reference in New Issue
Block a user