14 [RequireComponent (typeof(CompoundButton))]
35 public string Keyword =
string.Empty;
40 private string prevButtonText;
45 private string keyWord;
60 if (Microphone.devices.Length == 0) {
68 keyWord =
string.Empty;
71 m_button = GetComponent<CompoundButton>();
72 m_button_text = GetComponent<CompoundButtonText>();
74 switch (KeywordSource)
78 keyWord = prevButtonText = m_button_text.
Text;
93 prevButtonText != null &&
94 m_button_text.
Text != prevButtonText)
96 prevButtonText = m_button_text.
Text;
100 private void OnDestroy()
102 if (
string.IsNullOrEmpty(this.keyWord))
113 if (!gameObject.activeSelf || !enabled)
125 public class CustomEditor : MRTKEditor
127 protected override void DrawCustomFooter() {
130 bool microphoneEnabled =
UnityEditor.PlayerSettings.WSA.GetCapability(
UnityEditor.PlayerSettings.WSACapability.Microphone);
131 if (!microphoneEnabled) {
132 DrawWarning(
"Microphone capability not present. Speech recognition will be disabled.");
143 DrawError(
"No CompoundButtonText component found.");
144 }
else if (
string.IsNullOrEmpty(text.
Text)) {
145 DrawWarning(
"No keyword found in button text.");
156 UnityEditor.EditorGUILayout.LabelField(
"(Speech control disabled)",
UnityEditor.EditorStyles.miniBoldLabel);
161 private void EnableMicrophone() {
165 private void AddText() {