public async void play(SpeechIn speechIn, SpeechOut speechOut, bool silent = false) { asr = speechIn; tts = speechOut; if (!silent & sentences != "") { await tts.Speak(sentences); } if (soundSource && soundSource.clip) { await playSound(); } if (action != null) { await action.Invoke(actionarg); } string recognized; switch (options.Count) { case 0: //no options, endNode return; case 1: //single option, listen without return DialogOption singleOption = options.ToArray()[0]; if (singleOption.commands == null) //option has no commands, move on to next node { singleOption.next.play(asr, tts); return; } recognized = await asr.Listen(singleOption.commands.ToArray()); if (checkMetaCommands(recognized) == false) { singleOption.next.play(asr, tts); } break; default: // various options recognized = await asr.Listen(generateCommandArray()); foreach (DialogOption option in options) { if (option.commands.Contains(recognized)) { option.next.play(asr, tts); } } checkMetaCommands(recognized); return; } }
public void OnGUI() { GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Field Name"); UserText = EditorGUILayout.TextField(Label, UserText); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Accept")) { onClose?.Invoke(UserText); Close(); } else if (GUILayout.Button("Cancel")) { Close(); } GUILayout.EndHorizontal(); }