1
0
forked from cgvr/DeltaVR

radio button is disabled before radio is grabbed

This commit is contained in:
2026-03-06 17:06:41 +02:00
parent ba4c7ed631
commit 1bef5a6815
3 changed files with 21 additions and 5 deletions

View File

@@ -12,6 +12,7 @@ public class ReleasableButton : MonoBehaviour
public float moveDuration = 0.25f;
public float moveAmount = 0.05f;
private bool isLocked;
private float upPositionY;
private float downPositionY;
@@ -43,7 +44,7 @@ public class ReleasableButton : MonoBehaviour
private void OnTriggerEnter(Collider collider)
{
// if button is up, start moving down
if (buttonState == 0 && collider.gameObject.tag.EndsWith("Hand"))
if (buttonState == 0 &&!isLocked && collider.gameObject.tag.EndsWith("Hand"))
{
Activate();
OnButtonPressed?.Invoke();
@@ -53,7 +54,7 @@ public class ReleasableButton : MonoBehaviour
private void OnTriggerExit(Collider collider)
{
// if button is down, start moving up
if (buttonState == 1 && collider.gameObject.tag.EndsWith("Hand"))
if (buttonState == 1 && !isLocked && collider.gameObject.tag.EndsWith("Hand"))
{
Deactivate();
OnButtonReleased?.Invoke();
@@ -81,4 +82,14 @@ public class ReleasableButton : MonoBehaviour
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Click, gameObject);
}
public void Lock()
{
isLocked = true;
}
public void Unlock()
{
isLocked = false;
}
}