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

@@ -13,7 +13,7 @@
* klaas on näha temast eespool * klaas on näha temast eespool
* voicelines: list listidest, mille hulgast saab valida * voicelines: list listidest, mille hulgast saab valida
* shape detection: * shape detection:
* raadio nupp võiks töötada recording mode'is, mitte streamina - kui lased lahti, siis hakkab processima * võiks olla näha visuaalselt, millal raadio transmittib
* professor võiks öelda "good job, continue..." pärast esimest successi * professor võiks öelda "good job, continue..." pärast esimest successi
* kui kõik configurationid tehtud, siis professor ütleb "thank you" * kui kõik configurationid tehtud, siis professor ütleb "thank you"
* peab mängijale kuidagi selgitama, kuidas scale'ida prinditud objekte * peab mängijale kuidagi selgitama, kuidas scale'ida prinditud objekte

View File

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

View File

@@ -14,11 +14,14 @@ public class RadioTransmitter : XRGrabInteractable
public ReleasableButton radioButton; public ReleasableButton radioButton;
public TextMeshProUGUI computerScreen; public TextMeshProUGUI computerScreen;
private bool isProcessing;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
radioButton.OnButtonPressed += OnRadioButtonPressed; radioButton.OnButtonPressed += OnRadioButtonPressed;
radioButton.OnButtonReleased += OnRadioButtonReleased; radioButton.OnButtonReleased += OnRadioButtonReleased;
isProcessing = false;
} }
// Update is called once per frame // Update is called once per frame
@@ -35,28 +38,35 @@ public class RadioTransmitter : XRGrabInteractable
private void OnRadioButtonPressed() private void OnRadioButtonPressed()
{ {
fmodWhisperBridge.OnWhisperSegmentUpdated += OnPlayerSpeechUpdated;
fmodWhisperBridge.OnWhisperSegmentFinished += OnPlayerSpeechFinished;
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.RadioButton, gameObject); AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.RadioButton, gameObject);
fmodWhisperBridge.ActivateRecording(); if (!isProcessing)
{
isProcessing = true;
fmodWhisperBridge.OnWhisperSegmentUpdated += OnPlayerSpeechUpdated;
fmodWhisperBridge.OnWhisperSegmentFinished += OnPlayerSpeechFinished;
fmodWhisperBridge.ActivateRecording();
}
} }
private void OnRadioButtonReleased() private void OnRadioButtonReleased()
{ {
fmodWhisperBridge.OnWhisperSegmentUpdated -= OnPlayerSpeechUpdated;
fmodWhisperBridge.OnWhisperSegmentFinished -= OnPlayerSpeechFinished;
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.RadioButton, gameObject); AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.RadioButton, gameObject);
fmodWhisperBridge.DeactivateRecording();
} }
private void OnPlayerSpeechUpdated(string text) private void OnPlayerSpeechUpdated(string text)
{ {
computerScreen.text = text; computerScreen.text = text;
OnPlayerFinishedSpeaking?.Invoke(); //OnPlayerFinishedSpeaking?.Invoke();
} }
private void OnPlayerSpeechFinished(string playerText) private void OnPlayerSpeechFinished(string playerText)
{ {
computerScreen.text = playerText;
isProcessing = false;
OnPlayerFinishedSpeaking?.Invoke(); OnPlayerFinishedSpeaking?.Invoke();
fmodWhisperBridge.OnWhisperSegmentUpdated -= OnPlayerSpeechUpdated;
fmodWhisperBridge.OnWhisperSegmentFinished -= OnPlayerSpeechFinished;
fmodWhisperBridge.DeactivateRecording();
} }
} }