diff --git a/3d-generation-pipeline/README.md b/3d-generation-pipeline/README.md index 203da4cb..4590cddf 100644 --- a/3d-generation-pipeline/README.md +++ b/3d-generation-pipeline/README.md @@ -13,7 +13,7 @@ * klaas on näha temast eespool * voicelines: list listidest, mille hulgast saab valida * 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 * kui kõik configurationid tehtud, siis professor ütleb "thank you" * peab mängijale kuidagi selgitama, kuidas scale'ida prinditud objekte diff --git a/Assets/_PROJECT/Scripts/ModeGeneration/ReleasableButton.cs b/Assets/_PROJECT/Scripts/ModeGeneration/ReleasableButton.cs index d8f2baf0..114cbf01 100644 --- a/Assets/_PROJECT/Scripts/ModeGeneration/ReleasableButton.cs +++ b/Assets/_PROJECT/Scripts/ModeGeneration/ReleasableButton.cs @@ -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); diff --git a/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/RadioTransmitter.cs b/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/RadioTransmitter.cs index 8e06528f..dfaf2761 100644 --- a/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/RadioTransmitter.cs +++ b/Assets/_PROJECT/Scripts/ModeGeneration/ShapeDetection/RadioTransmitter.cs @@ -14,11 +14,14 @@ public class RadioTransmitter : XRGrabInteractable public ReleasableButton radioButton; public TextMeshProUGUI computerScreen; + private bool isProcessing; + // Start is called before the first frame update void Start() { radioButton.OnButtonPressed += OnRadioButtonPressed; radioButton.OnButtonReleased += OnRadioButtonReleased; + isProcessing = false; } // Update is called once per frame @@ -35,28 +38,35 @@ public class RadioTransmitter : XRGrabInteractable private void OnRadioButtonPressed() { - fmodWhisperBridge.OnWhisperSegmentUpdated += OnPlayerSpeechUpdated; - fmodWhisperBridge.OnWhisperSegmentFinished += OnPlayerSpeechFinished; AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.RadioButton, gameObject); - fmodWhisperBridge.ActivateRecording(); + if (!isProcessing) + { + isProcessing = true; + fmodWhisperBridge.OnWhisperSegmentUpdated += OnPlayerSpeechUpdated; + fmodWhisperBridge.OnWhisperSegmentFinished += OnPlayerSpeechFinished; + fmodWhisperBridge.ActivateRecording(); + } } private void OnRadioButtonReleased() { - fmodWhisperBridge.OnWhisperSegmentUpdated -= OnPlayerSpeechUpdated; - fmodWhisperBridge.OnWhisperSegmentFinished -= OnPlayerSpeechFinished; AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.RadioButton, gameObject); - fmodWhisperBridge.DeactivateRecording(); } private void OnPlayerSpeechUpdated(string text) { computerScreen.text = text; - OnPlayerFinishedSpeaking?.Invoke(); + //OnPlayerFinishedSpeaking?.Invoke(); } private void OnPlayerSpeechFinished(string playerText) { + computerScreen.text = playerText; + isProcessing = false; OnPlayerFinishedSpeaking?.Invoke(); + + fmodWhisperBridge.OnWhisperSegmentUpdated -= OnPlayerSpeechUpdated; + fmodWhisperBridge.OnWhisperSegmentFinished -= OnPlayerSpeechFinished; + fmodWhisperBridge.DeactivateRecording(); } }