/// <summary> /// Handle multiple panels open and changing languages /// </summary> /// <param name="languageChangedResult"></param> void HandleOnLanguageChanged(LanguageChangedResult languageChangedResult) { ISpeechDetectionPlugin plugin = EditorProxySpeechDetectionPlugin.GetInstance(); int languageIndex = _mLanguage; if (SpeechDetectionUtils.HandleOnLanguageChanged( ref _mLanguage, _mLanguages, ref _mDialect, _mDialects, _mLanguageResult, plugin, languageChangedResult)) { if (languageIndex != _mLanguage) { SpeechDetectionUtils.HandleLanguageChanged(_mLanguages, _mLanguage, out _mDialects, ref _mDialect, _mLanguageResult, plugin); } Repaint(); } }
/// <summary> /// Set the starting UI layout /// </summary> private void Awake() { // no need to display the summary if the plugin is missing SpeechDetectionUtils.SetActive(false, _mDropDownDialects, _mDropDownLanguages, _mTextDictation, _mTextSummary); }
// Use this for initialization IEnumerator Start() { // get the singleton instance _mSpeechDetectionPlugin = SpeechDetectionUtils.GetInstance(); // check the reference to the plugin if (null == _mSpeechDetectionPlugin) { Debug.LogError("WebGL Speech Detection Plugin is not set!"); yield break; } // wait for plugin to become available while (!_mSpeechDetectionPlugin.IsAvailable()) { yield return(null); } // subscribe to events _mSpeechDetectionPlugin.AddListenerOnDetectionResult(HandleDetectionResult); // A list of words to detect string[] wordsToDetect = { "Climb", "Crouch", "Jump", "Left", "Right", "Stand", "Run", "10", // match 10 before 1 "Ten", "1", "One", "2", "Two", "3", "Three", "4", "Four", "5", "Five", "6", "Six", "7", "Seven", "8", "Eight", "9", "Nine", }; foreach (string word in wordsToDetect) { _mWords.Add(word.ToLower()); } }
/// <summary> /// Handler for changing dialects /// </summary> public static void HandleDialectChanged(string[] dialectOptions, int dialectIndex, LanguageResult languageResult, ISpeechDetectionPlugin plugin) { if (null == dialectOptions) { Debug.LogError("The dialect options are not set!"); return; } if (null == languageResult) { Debug.LogError("The language result is not set!"); return; } string display = dialectOptions[dialectIndex]; Dialect dialect = null; if (dialectIndex > 0) { //Debug.Log(display); SetDefaultDialect(display); dialect = SpeechDetectionUtils.GetDialect(languageResult, display); if (null == dialect) { Debug.LogError("Did not find specified dialect!"); return; } //Debug.Log(dialect.name); if (null != plugin) { plugin.Abort(); plugin.SetLanguage(dialect.name); LanguageChangedResult languageChangedResult = new LanguageChangedResult(); languageChangedResult._mDialect = dialect.name; plugin.Invoke(languageChangedResult); } } }
/// <summary> /// Handler for changing dialects /// </summary> public static void HandleDialectChanged(Dropdown dropdownDialects, LanguageResult languageResult, ISpeechDetectionPlugin plugin) { if (null == dropdownDialects) { Debug.LogError("The dropdown for dialects is not set!"); return; } if (null == languageResult) { Debug.LogError("The language result is not set!"); return; } string display = dropdownDialects.options[dropdownDialects.value].text; Dialect dialect = null; if (dropdownDialects.value > 0) { //Debug.Log(display); SetDefaultDialect(display); dialect = SpeechDetectionUtils.GetDialect(languageResult, display); if (null == dialect) { Debug.LogError("Did not find specified dialect!"); return; } //Debug.Log(dialect.name); if (null != plugin) { plugin.Abort(); plugin.SetLanguage(dialect.name); LanguageChangedResult languageChangedResult = new LanguageChangedResult(); languageChangedResult._mDialect = dialect.name; plugin.Invoke(languageChangedResult); } } }
// Use this for initialization IEnumerator Start() { // get the singleton instance _mSpeechDetectionPlugin = SpeechDetectionUtils.GetInstance(); // check the reference to the plugin if (null == _mSpeechDetectionPlugin) { Debug.LogError("WebGL Speech Detection Plugin is not set!"); yield break; } // wait for plugin to become available while (!_mSpeechDetectionPlugin.IsAvailable()) { yield return(null); } // subscribe to events _mSpeechDetectionPlugin.AddListenerOnDetectionResult(HandleDetectionResult); }
private static void CreateDialectsDropdown() { EditorApplication.ExecuteMenuItem("GameObject/UI/Dropdown"); GameObject selection = Selection.activeGameObject; if (selection) { Dropdown dropdown = selection.GetComponent <Dropdown>(); if (dropdown) { selection.name = "DropdownDialects"; List <string> options = new List <string>(); options.Add("Dialect"); SpeechDetectionUtils.PopulateDropdown(dropdown, options); RectTransform rectTransform = dropdown.GetComponent <RectTransform>(); rectTransform.pivot = new Vector2(0.5f, 0.5f); rectTransform.localPosition = new Vector3(272, 231, 0); rectTransform.sizeDelta = new Vector2(267, 44); } } }
public static void PopulateLanguagesDropdown(Dropdown dropdownLanguages, LanguageResult languageResult) { if (null == dropdownLanguages) { Debug.LogError("The dropdown for languages is not set!"); return; } if (null == languageResult) { Debug.LogError("The language result is not set!"); return; } // prepare the language drop down items List <string> options = GetDefaultLanguageOptions(); if (null != languageResult) { if (null != languageResult.languages) { foreach (Language language in languageResult.languages) { if (!string.IsNullOrEmpty(language.display)) { options.Add(language.display); } else if (!string.IsNullOrEmpty(language.name)) { options.Add(language.name); } } } } SpeechDetectionUtils.PopulateDropdown(dropdownLanguages, options); }
/// <summary> /// Handler for changing languages /// </summary> public static void HandleLanguageChanged(string[] languageOptions, int languageIndex, out string[] dialectOptions, ref int dialectIndex, LanguageResult languageResult, ISpeechDetectionPlugin plugin) { List <string> options = GetDefaultDialectOptions(); dialectOptions = options.ToArray(); dialectIndex = 0; if (null == languageOptions) { Debug.LogError("The language options are not set!"); return; } if (null == dialectOptions) { Debug.LogError("The dialect options are not set!"); return; } if (null == languageResult) { Debug.LogError("The language result is not set!"); return; } string display = languageOptions[languageIndex]; //Debug.Log(display); SetDefaultLanguage(display); Language language = null; if (languageIndex > 0) { language = SpeechDetectionUtils.GetLanguage(languageResult, display); if (null == language) { Debug.LogError("Did not find specified language!"); } else { LanguageChangedResult languageChangedResult = new LanguageChangedResult(); languageChangedResult._mLanguage = language.name; plugin.Invoke(languageChangedResult); } } if (languageIndex > 0 && null != language && null != language.dialects && language.dialects.Length > 0) { foreach (Dialect dialect in language.dialects) { if (!string.IsNullOrEmpty(dialect.display)) { options.Add(dialect.display); } else if (!string.IsNullOrEmpty(dialect.description)) { options.Add(dialect.description); } else if (!string.IsNullOrEmpty(dialect.name)) { options.Add(dialect.name); } } } dialectOptions = options.ToArray(); if (dialectOptions.Length > 1) { dialectIndex = 1; } HandleDialectChanged(dialectOptions, dialectIndex, languageResult, plugin); }
/// <summary> /// Handler for changing languages /// </summary> public static void HandleLanguageChanged(Dropdown dropdownLanguages, Dropdown dropdownDialects, LanguageResult languageResult, ISpeechDetectionPlugin plugin) { if (null == dropdownLanguages) { Debug.LogError("The dropdown for languages is not set!"); return; } if (null == dropdownDialects) { Debug.LogError("The dropdown for dialects is not set!"); return; } if (null == languageResult) { Debug.LogError("The language result is not set!"); return; } string display = dropdownLanguages.options[dropdownLanguages.value].text; //Debug.Log(display); SetDefaultLanguage(display); Language language = null; if (dropdownLanguages.value > 0) { language = SpeechDetectionUtils.GetLanguage(languageResult, display); if (null == language) { Debug.LogError("Did not find specified language!"); } else { LanguageChangedResult languageChangedResult = new LanguageChangedResult(); languageChangedResult._mLanguage = language.name; plugin.Invoke(languageChangedResult); } } List <string> options = SpeechDetectionUtils.GetDefaultDialectOptions(); if (dropdownLanguages.value > 0 && null != language && null != language.dialects && language.dialects.Length > 0) { foreach (Dialect dialect in language.dialects) { if (!string.IsNullOrEmpty(dialect.display)) { options.Add(dialect.display); } else if (!string.IsNullOrEmpty(dialect.description)) { options.Add(dialect.description); } else if (!string.IsNullOrEmpty(dialect.name)) { options.Add(dialect.name); } } } SpeechDetectionUtils.PopulateDropdown(dropdownDialects, options); SpeechDetectionUtils.SetInteractable(options.Count > 1, dropdownDialects); SpeechDetectionUtils.SelectIndex(dropdownDialects, 1); HandleDialectChanged(dropdownDialects, languageResult, plugin); }
/// <summary> /// Disable the dialects UI when not available /// </summary> public static void DisableDialects(Dropdown dropdown) { SpeechDetectionUtils.PopulateDropdown(dropdown, SpeechDetectionUtils.GetDefaultDialectOptions()); SpeechDetectionUtils.SetInteractable(false, dropdown); }
/// <summary> /// Reinitialize the editor proxy when enabled and not compiling /// </summary> private void Update() { bool enabled = EditorProxySpeechDetectionPlugin.IsEnabled(); if (!enabled || EditorApplication.isCompiling) { _mInitialized = false; return; } // handle init EditorProxySpeechDetectionPlugin plugin = EditorProxySpeechDetectionPlugin.GetInstance(); if (null != plugin) { if (!_mInitialized) { if (!plugin.IsAvailable()) { return; } //Debug.LogFormat("Update: Plugin is available"); plugin.GetLanguages((languageResult) => { _mLanguageResult = languageResult; // populate the language options SpeechDetectionUtils.PopulateLanguages(out _mLanguages, out _mLanguage, languageResult); // Restore the default language SpeechDetectionUtils.RestoreLanguage(_mLanguages, out _mLanguage); // Handle setting the default language SpeechDetectionUtils.PausePlayerPrefs(true); SpeechDetectionUtils.HandleLanguageChanged(_mLanguages, _mLanguage, out _mDialects, ref _mDialect, _mLanguageResult, plugin); SpeechDetectionUtils.PausePlayerPrefs(false); // Restore the default dialect SpeechDetectionUtils.RestoreDialect(_mDialects, out _mDialect); // Update UI Repaint(); }); // subscribe to events plugin.AddListenerOnDetectionResult(HandleDetectionResult); // get on language changed events plugin.AddListenerOnLanguageChanged(HandleOnLanguageChanged); //Debug.Log("Update: HandleDetectionResult subscribed"); _mInitialized = true; Repaint(); } } // Check timers to deactivate button after delay bool doRepaint = false; foreach (KeyValuePair <string, MethodInfo> kvp in _mEditorCommands) { DateTime timer = _mTimers[kvp.Key]; if (timer != DateTime.MinValue && timer < DateTime.Now) { _mTimers[kvp.Key] = DateTime.MinValue; doRepaint = true; } } if (doRepaint) { Repaint(); } // run pending UI actions while (_mPendingActions.Count > 0) { Action action = _mPendingActions[0]; _mPendingActions.RemoveAt(0); action.Invoke(); } }
// Use this for initialization IEnumerator Start() { // get the singleton instance _mSpeechDetectionPlugin = SpeechDetectionUtils.GetInstance(); // check the reference to the plugin if (null == _mSpeechDetectionPlugin) { Debug.LogError("WebGL Speech Detection Plugin is not set!"); yield break; } // wait for plugin to become available while (!_mSpeechDetectionPlugin.IsAvailable()) { yield return(null); } // no need to display a warning if the plugin is available SpeechDetectionUtils.SetActive(false, _mTextWarning); // make the dropdowns non-interactive SpeechDetectionUtils.SetInteractable(false, _mDropDownLanguages, _mDropDownDialects); // show UI controls SpeechDetectionUtils.SetActive(true, _mDropDownDialects, _mDropDownLanguages, _mImageWords, _mTextSummary); // subscribe to events _mSpeechDetectionPlugin.AddListenerOnDetectionResult(HandleDetectionResult); // Get languages from plugin, _mSpeechDetectionPlugin.GetLanguages((languageResult) => { _mLanguageResult = languageResult; // prepare the language drop down items SpeechDetectionUtils.PopulateLanguagesDropdown(_mDropDownLanguages, _mLanguageResult); // make the dropdowns interactive SpeechDetectionUtils.SetInteractable(true, _mDropDownLanguages, _mDropDownDialects); // subscribe to language change events if (_mDropDownLanguages) { _mDropDownLanguages.onValueChanged.AddListener(delegate { SpeechDetectionUtils.HandleLanguageChanged(_mDropDownLanguages, _mDropDownDialects, _mLanguageResult, _mSpeechDetectionPlugin); }); } // subscribe to dialect change events if (_mDropDownDialects) { _mDropDownDialects.onValueChanged.AddListener(delegate { SpeechDetectionUtils.HandleDialectChanged(_mDropDownDialects, _mLanguageResult, _mSpeechDetectionPlugin); }); } // Disabled until a language is selected SpeechDetectionUtils.DisableDialects(_mDropDownDialects); // set the default language SpeechDetectionUtils.RestoreLanguage(_mDropDownLanguages); // set the default dialect SpeechDetectionUtils.RestoreDialect(_mDropDownDialects); }); // get all the words in the UI foreach (Example02Word word in GameObject.FindObjectsOfType <Example02Word>()) { Text text = word.GetComponentInChildren <Text>(); if (text) { _mWords[text.text.ToLower()] = word; } } }
/// <summary> /// Display GUI in the editor panel /// </summary> private void OnGUI() { EditorProxySpeechDetectionPlugin plugin = EditorProxySpeechDetectionPlugin.GetInstance(); bool enabled = EditorProxySpeechDetectionPlugin.IsEnabled(); if (!enabled) { if (null != plugin) { // unsubscribe to events plugin.RemoveListenerOnDetectionResult(HandleDetectionResult); } } bool isCompiling = EditorApplication.isCompiling; if (isCompiling) { GUI.enabled = false; } bool newEnabled = GUILayout.Toggle(enabled, "Enabled"); if (newEnabled != enabled) { EditorProxySpeechDetectionPlugin.SetEnabled(newEnabled); } if (isCompiling) { GUI.enabled = true; } if (null != plugin && plugin.IsAvailable()) { GUILayout.Label("IsAvailable: true"); } else { GUILayout.Label("IsAvailable: false"); } if (isCompiling || !newEnabled) { GUI.enabled = false; } if (GUILayout.Button("Open Browser Tab")) { if (null != plugin) { SetTextStatus("Open Browser Tab"); plugin.ManagementOpenBrowserTab(); } } if (GUILayout.Button("Close Browser Tab")) { if (null != plugin) { SetTextStatus("Close Browser Tab"); plugin.ManagementCloseBrowserTab(); } } GUILayout.BeginHorizontal(GUILayout.Width(position.width)); int port = 5000; if (null != plugin) { port = plugin._mPort; } string strPort = GUILayout.TextField(string.Format("{0}", port)); if (int.TryParse(strPort, out port)) { if (null != plugin) { plugin._mPort = port; } } if (GUILayout.Button("Set Proxy Port")) { if (null != plugin) { SetTextStatus(string.Format("Set Proxy Tab: port={0}", plugin._mPort)); plugin.ManagementSetProxyPort(plugin._mPort); } } GUILayout.EndHorizontal(); if (GUILayout.Button("Launch Proxy")) { if (null != plugin) { SetTextStatus("Launch Proxy"); plugin.ManagementLaunchProxy(); } } if (GUILayout.Button("Close Proxy")) { if (null != plugin) { SetTextStatus("Close Proxy"); plugin.ManagementCloseProxy(); } } int newLanguage = EditorGUILayout.Popup(_mLanguage, _mLanguages); if (_mLanguage != newLanguage) { _mLanguage = newLanguage; if (null != plugin) { SpeechDetectionUtils.HandleLanguageChanged(_mLanguages, _mLanguage, out _mDialects, ref _mDialect, _mLanguageResult, plugin); } } if (!isCompiling && newEnabled) { GUI.enabled = _mLanguage != 0; } int newDialect = EditorGUILayout.Popup(_mDialect, _mDialects); if (_mDialect != newDialect) { _mDialect = newDialect; if (null != plugin) { SpeechDetectionUtils.HandleDialectChanged(_mDialects, _mDialect, _mLanguageResult, plugin); } } if (!isCompiling && newEnabled) { GUI.enabled = true; } for (int index = 0; index < _mWords.Count; ++index) { GUILayout.Label(_mWords[index]); } GUILayout.Label(_sTextStatus, GUILayout.Width(position.width), GUILayout.Height(40)); if (isCompiling || !newEnabled) { GUI.enabled = true; } }
/// <summary> /// Reinitialize the editor proxy when enabled and not compiling /// </summary> private void Update() { bool enabled = EditorProxySpeechDetectionPlugin.IsEnabled(); if (!enabled || EditorApplication.isCompiling) { _mInitialized = false; return; } EditorProxySpeechDetectionPlugin plugin = EditorProxySpeechDetectionPlugin.GetInstance(); if (null != plugin) { if (!_mInitialized) { if (!plugin.IsAvailable()) { return; } //Debug.LogFormat("Update: Plugin is available"); // Reset the detection list _mWords.Clear(); _mWords.Add("Say something..."); plugin.GetLanguages((languageResult) => { _mLanguageResult = languageResult; // populate the language options SpeechDetectionUtils.PopulateLanguages(out _mLanguages, out _mLanguage, languageResult); // Restore the default language SpeechDetectionUtils.RestoreLanguage(_mLanguages, out _mLanguage); // Handle setting the default language SpeechDetectionUtils.PausePlayerPrefs(true); SpeechDetectionUtils.HandleLanguageChanged(_mLanguages, _mLanguage, out _mDialects, ref _mDialect, _mLanguageResult, plugin); SpeechDetectionUtils.PausePlayerPrefs(false); // Restore the default dialect SpeechDetectionUtils.RestoreDialect(_mDialects, out _mDialect); // Update UI Repaint(); }); // subscribe to events plugin.AddListenerOnDetectionResult(HandleDetectionResult); // get on language changed events plugin.AddListenerOnLanguageChanged(HandleOnLanguageChanged); //Debug.Log("Update: HandleDetectionResult subscribed"); _mInitialized = true; Repaint(); } } // run pending UI actions while (_mPendingActions.Count > 0) { Action action = _mPendingActions[0]; _mPendingActions.RemoveAt(0); action.Invoke(); } }
/// <summary> /// Display GUI in the editor panel /// </summary> private void OnGUI() { EditorProxySpeechDetectionPlugin plugin = EditorProxySpeechDetectionPlugin.GetInstance(); bool enabled = EditorProxySpeechDetectionPlugin.IsEnabled(); if (!enabled) { if (null != plugin) { // unsubscribe to events plugin.RemoveListenerOnDetectionResult(HandleDetectionResult); } } bool isCompiling = EditorApplication.isCompiling; if (isCompiling) { GUI.enabled = false; } bool newEnabled = GUILayout.Toggle(enabled, "Enabled"); if (newEnabled != enabled) { EditorProxySpeechDetectionPlugin.SetEnabled(newEnabled); } if (isCompiling) { GUI.enabled = true; } if (null != plugin && plugin.IsAvailable()) { GUILayout.Label("IsAvailable: true"); } else { GUILayout.Label("IsAvailable: false"); } if (isCompiling || !newEnabled) { GUI.enabled = false; } if (GUILayout.Button("Open Browser Tab")) { if (null != plugin) { SetTextStatus("Open Browser Tab"); plugin.ManagementOpenBrowserTab(); } } if (GUILayout.Button("Close Browser Tab")) { if (null != plugin) { SetTextStatus("Close Browser Tab"); plugin.ManagementCloseBrowserTab(); } } GUILayout.BeginHorizontal(GUILayout.Width(position.width)); int port = 5000; if (null != plugin) { port = plugin._mPort; } string strPort = GUILayout.TextField(string.Format("{0}", port)); if (int.TryParse(strPort, out port)) { if (null != plugin) { plugin._mPort = port; } } if (GUILayout.Button("Set Proxy Port")) { if (null != plugin) { SetTextStatus(string.Format("Set Proxy Tab: port={0}", plugin._mPort)); plugin.ManagementSetProxyPort(plugin._mPort); } } GUILayout.EndHorizontal(); if (GUILayout.Button("Launch Proxy")) { if (null != plugin) { SetTextStatus("Launch Proxy"); plugin.ManagementLaunchProxy(); } } if (GUILayout.Button("Close Proxy")) { if (null != plugin) { SetTextStatus("Close Proxy"); plugin.ManagementCloseProxy(); } } int newLanguage = EditorGUILayout.Popup(_mLanguage, _mLanguages); if (_mLanguage != newLanguage) { _mLanguage = newLanguage; if (null != plugin) { SpeechDetectionUtils.HandleLanguageChanged(_mLanguages, _mLanguage, out _mDialects, ref _mDialect, _mLanguageResult, plugin); } } if (!isCompiling && newEnabled) { GUI.enabled = _mLanguage != 0; } int newDialect = EditorGUILayout.Popup(_mDialect, _mDialects); if (_mDialect != newDialect) { _mDialect = newDialect; if (null != plugin) { SpeechDetectionUtils.HandleDialectChanged(_mDialects, _mDialect, _mLanguageResult, plugin); } } if (!isCompiling && newEnabled) { GUI.enabled = true; } GUI.skin.label.wordWrap = true; GUILayout.Label("Say any of the following words which will highlight when detected.", GUILayout.Width(position.width), GUILayout.Height(40)); GUI.skin.label.wordWrap = false; Color oldColor = GUI.backgroundColor; foreach (KeyValuePair <string, MethodInfo> kvp in _mEditorCommands) { DateTime timer = _mTimers[kvp.Key]; if (timer > DateTime.Now) { GUI.backgroundColor = Color.red; } else { GUI.backgroundColor = oldColor; } GUILayout.Button(kvp.Key); } GUI.backgroundColor = oldColor; GUILayout.Label(_sTextStatus, GUILayout.Width(position.width), GUILayout.Height(40)); if (isCompiling || !newEnabled) { GUI.enabled = true; } }
// Use this for initialization IEnumerator Start() { // get the singleton instance _mSpeechDetectionPlugin = SpeechDetectionUtils.GetInstance(); // check the reference to the plugin if (null == _mSpeechDetectionPlugin) { Debug.LogError("Proxy Speech Detection Plugin is not set!"); yield break; } // wait for plugin to become available while (!_mSpeechDetectionPlugin.IsAvailable()) { yield return(null); } // no need to display a warning if the plugin is available SpeechDetectionUtils.SetActive(false, _mTextWaiting); // display the UI controls SpeechDetectionUtils.SetActive(true, _mDropDownDialects, _mDropDownLanguages, _mTextDictation, _mTextSummary); // subscribe to events _mSpeechDetectionPlugin.AddListenerOnDetectionResult(HandleDetectionResult); // Get languages from plugin, _mSpeechDetectionPlugin.GetLanguages((languageResult) => { _mLanguageResult = languageResult; // prepare the language drop down items SpeechDetectionUtils.PopulateLanguagesDropdown(_mDropDownLanguages, _mLanguageResult); // subscribe to language change events if (_mDropDownLanguages) { _mDropDownLanguages.onValueChanged.AddListener(delegate { SpeechDetectionUtils.HandleLanguageChanged(_mDropDownLanguages, _mDropDownDialects, _mLanguageResult, _mSpeechDetectionPlugin); }); } // subscribe to dialect change events if (_mDropDownDialects) { _mDropDownDialects.onValueChanged.AddListener(delegate { SpeechDetectionUtils.HandleDialectChanged(_mDropDownDialects, _mLanguageResult, _mSpeechDetectionPlugin); }); } // Disabled until a language is selected SpeechDetectionUtils.DisableDialects(_mDropDownDialects); // set the default language SpeechDetectionUtils.RestoreLanguage(_mDropDownLanguages); // set the default dialect SpeechDetectionUtils.RestoreDialect(_mDropDownDialects); }); }
// Use this for initialization IEnumerator Start() { // get the singleton instance _mSpeechDetectionPlugin = SpeechDetectionUtils.GetInstance(); // check the reference to the plugin if (null == _mSpeechDetectionPlugin) { Debug.LogError("Proxy Speech Detection Plugin is not set!"); yield break; } // proxy needs to be launched before it's available if (_mButtonLaunchProxy) { _mButtonLaunchProxy.onClick.AddListener(() => { _mSpeechDetectionPlugin.ManagementLaunchProxy(); }); } // wait for plugin to become available while (!_mSpeechDetectionPlugin.IsAvailable()) { yield return(null); } if (_mButtonCloseBrowserTab) { _mButtonCloseBrowserTab.onClick.AddListener(() => { _mSpeechDetectionPlugin.ManagementCloseBrowserTab(); }); } if (_mButtonCloseProxy) { _mButtonCloseProxy.onClick.AddListener(() => { _mSpeechDetectionPlugin.ManagementCloseProxy(); }); } if (_mButtonOpenBrowserTab) { _mButtonOpenBrowserTab.onClick.AddListener(() => { _mSpeechDetectionPlugin.ManagementOpenBrowserTab(); }); } if (_mButtonSetProxyPort && _mInputPort) { _mButtonSetProxyPort.onClick.AddListener(() => { int port; if (int.TryParse(_mInputPort.text, out port)) { _mSpeechDetectionPlugin.ManagementSetProxyPort(port); } else { _mInputPort.text = "5000"; } }); } }