protected IEnumerator DoMicrophoneTest() { microphoneTestMessage.SetActive(true); bool repeat = false; string wavFilePath; do { yield return(PressAnyKey("Press any key to record a sound after the beep.")); lowBeep.Play(); textDisplayer.DisplayText("microphone test recording", "Recording..."); textDisplayer.ChangeColor(Color.red); yield return(new WaitForSeconds(lowBeep.clip.length)); wavFilePath = System.IO.Path.Combine(UnityEPL.GetDataPath(), "microphone_test_" + DataReporter.RealWorldTime().ToString("yyyy-MM-dd_HH_mm_ss") + ".wav"); soundRecorder.StartRecording(wavFilePath); yield return(new WaitForSeconds(MICROPHONE_TEST_LENGTH)); soundRecorder.StopRecording(); textDisplayer.ClearText(); yield return(new WaitForSeconds(MICROPHONE_TEST_GAP)); textDisplayer.DisplayText("microphone test playing", "Playing..."); textDisplayer.ChangeColor(Color.green); audioPlayback.clip = soundRecorder.AudioClipFromDatapath(wavFilePath); audioPlayback.Play(); yield return(new WaitForSeconds(MICROPHONE_TEST_LENGTH)); textDisplayer.ClearText(); textDisplayer.OriginalColor(); SetRamulatorState("WAITING", true, new Dictionary <string, object>()); textDisplayer.DisplayText("microphone test confirmation", "Did you hear the recording? \n(Y=Continue / N=Try Again / C=Cancel)."); while (!Input.GetKeyDown(KeyCode.Y) && !Input.GetKeyDown(KeyCode.N) && !Input.GetKeyDown(KeyCode.C)) { yield return(null); } textDisplayer.ClearText(); SetRamulatorState("WAITING", false, new Dictionary <string, object>()); if (Input.GetKey(KeyCode.C)) { Quit(); } repeat = Input.GetKey(KeyCode.N); }while (repeat); if (!System.IO.File.Exists(wavFilePath)) { yield return(PressAnyKey("WARNING: Wav output file not detected. Sounds may not be successfully recorded to disk.")); } microphoneTestMessage.SetActive(false); }
public void ShowText(string tag, string text, string color) { if (textDisplayer == null) { throw new Exception("No text displayer in current scene"); } else { Color myColor = Color.clear; ColorUtility.TryParseHtmlString(color, out myColor); textDisplayer.ChangeColor(myColor); textDisplayer.DisplayText(tag, text); } }