You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
735 B
C#

6 months ago
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
namespace Autohand.Demo {
public class XRControllerEvent : MonoBehaviour
{
public XRHandControllerLink link;
public CommonButton button;
public UnityEvent Pressed;
public UnityEvent Released;
bool pressed = false;
private void Update()
{
if (link.ButtonPressed(button) && !pressed)
{
Pressed?.Invoke();
pressed = true;
}
else if (!link.ButtonPressed(button) && pressed)
{
Released?.Invoke();
pressed = false;
}
}
}
}