1
0
forked from cgvr/DeltaVR

radio transmitter keeps transmitting until text processing is completed

This commit is contained in:
2026-03-05 12:52:29 +02:00
parent 22f6982c4c
commit 33b86e09ae
3 changed files with 33 additions and 14 deletions

View File

@@ -14,13 +14,18 @@ public class ReleasableButton : MonoBehaviour
private float upPositionY;
private float downPositionY;
private bool isButtonDown;
// button state:
// 0 - up
// 1 - down
// 2 - moving
private int buttonState;
private void Awake()
{
upPositionY = movableParts.localPosition.y;
downPositionY = movableParts.localPosition.y - moveAmount;
isButtonDown = false;
buttonState = 0;
}
// Start is called before the first frame update
@@ -37,7 +42,8 @@ public class ReleasableButton : MonoBehaviour
private void OnTriggerEnter(Collider collider)
{
if (!isButtonDown && collider.gameObject.tag.EndsWith("Hand"))
// if button is up, start moving down
if (buttonState == 0 && collider.gameObject.tag.EndsWith("Hand"))
{
Activate();
OnButtonPressed?.Invoke();
@@ -46,7 +52,8 @@ public class ReleasableButton : MonoBehaviour
private void OnTriggerExit(Collider collider)
{
if (isButtonDown && collider.gameObject.tag.EndsWith("Hand"))
// if button is down, start moving up
if (buttonState == 1 && collider.gameObject.tag.EndsWith("Hand"))
{
Deactivate();
OnButtonReleased?.Invoke();
@@ -55,9 +62,10 @@ public class ReleasableButton : MonoBehaviour
private void Activate()
{
buttonState = 2;
movableParts.DOLocalMoveY(downPositionY, moveDuration).OnComplete(() =>
{
isButtonDown = true;
buttonState = 1;
});
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Click, gameObject);
@@ -65,9 +73,10 @@ public class ReleasableButton : MonoBehaviour
private void Deactivate()
{
buttonState = 2;
movableParts.DOLocalMoveY(upPositionY, moveDuration).OnComplete(() =>
{
isButtonDown = false;
buttonState = 0;
});
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Click, gameObject);