Fix double click on ToggleAR
This commit is contained in:
@@ -1,14 +1,26 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace UI
|
namespace UI
|
||||||
{
|
{
|
||||||
public class ARToggleButton: MonoBehaviour
|
public class ARToggleButton: MonoBehaviour, IPointerDownHandler
|
||||||
{
|
{
|
||||||
public OVRPassthroughLayer passthroughLayer;
|
public OVRPassthroughLayer passthroughLayer;
|
||||||
private bool pressed = false; //efix variable da button 2 mal pressed wird ??
|
private bool pressed = false; //efix variable da button 2 mal pressed wird ??
|
||||||
public GameObject raceTrack;
|
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()
|
void Start()
|
||||||
{
|
{
|
||||||
gameObject.GetComponent<Button>().onClick.AddListener(TogglePassthrough);
|
gameObject.GetComponent<Button>().onClick.AddListener(TogglePassthrough);
|
||||||
|
|||||||
Reference in New Issue
Block a user