public override void OnInspectorGUI() { CompoundButtonSpeech speechButton = (CompoundButtonSpeech)target; bool microphoneEnabled = PlayerSettings.WSA.GetCapability(PlayerSettings.WSACapability.Microphone); if (!microphoneEnabled) { HUXEditorUtils.WarningMessage("Microphone capability not present. Speech recognition will be disabled.", "Enable Microphone Capability", EnableMicrophone); HUXEditorUtils.SaveChanges(target); return; } HUXEditorUtils.BeginSectionBox("Keyword source"); speechButton.KeywordSource = (CompoundButtonSpeech.KeywordSourceEnum)EditorGUILayout.EnumPopup(speechButton.KeywordSource); CompoundButtonText text = speechButton.GetComponent <CompoundButtonText>(); switch (speechButton.KeywordSource) { case CompoundButtonSpeech.KeywordSourceEnum.ButtonText: default: if (text == null) { HUXEditorUtils.ErrorMessage("No CompoundButtonText component found.", AddText); } else if (string.IsNullOrEmpty(text.Text)) { HUXEditorUtils.WarningMessage("No keyword found in button text."); } else { EditorGUILayout.LabelField("Keyword: " + text.Text); } break; case CompoundButtonSpeech.KeywordSourceEnum.LocalOverride: speechButton.Keyword = EditorGUILayout.TextField(speechButton.Keyword); break; case CompoundButtonSpeech.KeywordSourceEnum.None: HUXEditorUtils.DrawSubtleMiniLabel("(Speech control disabled)"); break; } HUXEditorUtils.EndSectionBox(); HUXEditorUtils.SaveChanges(target); }
protected override void DrawCustomFooter() { CompoundButtonSpeech speechButton = (CompoundButtonSpeech)target; bool microphoneEnabled = UnityEditor.PlayerSettings.WSA.GetCapability(UnityEditor.PlayerSettings.WSACapability.Microphone); if (!microphoneEnabled) { DrawWarning("Microphone capability not present. Speech recognition will be disabled."); return; } UnityEditor.EditorGUILayout.LabelField("Keyword source", UnityEditor.EditorStyles.miniBoldLabel); speechButton.KeywordSource = (CompoundButtonSpeech.KeywordSourceEnum)UnityEditor.EditorGUILayout.EnumPopup(speechButton.KeywordSource); CompoundButtonText text = speechButton.GetComponent <CompoundButtonText>(); switch (speechButton.KeywordSource) { case CompoundButtonSpeech.KeywordSourceEnum.ButtonText: default: if (text == null) { DrawError("No CompoundButtonText component found."); } else if (string.IsNullOrEmpty(text.Text)) { DrawWarning("No keyword found in button text."); } else { UnityEditor.EditorGUILayout.LabelField("Keyword: " + text.Text); } break; case CompoundButtonSpeech.KeywordSourceEnum.LocalOverride: speechButton.Keyword = UnityEditor.EditorGUILayout.TextField(speechButton.Keyword); break; case CompoundButtonSpeech.KeywordSourceEnum.None: UnityEditor.EditorGUILayout.LabelField("(Speech control disabled)", UnityEditor.EditorStyles.miniBoldLabel); break; } }
public override void OnInspectorGUI() { CompoundButtonSpeech speechButton = (CompoundButtonSpeech)target; HUXEditorUtils.BeginSectionBox("Keyword source"); speechButton.KeywordSource = (CompoundButtonSpeech.KeywordSourceEnum)EditorGUILayout.EnumPopup(speechButton.KeywordSource); CompoundButtonText text = speechButton.GetComponent <CompoundButtonText>(); switch (speechButton.KeywordSource) { case CompoundButtonSpeech.KeywordSourceEnum.ButtonText: default: if (text == null) { HUXEditorUtils.ErrorMessage("No CompoundButtonText component found.", AddText); } else if (string.IsNullOrEmpty(text.Text)) { HUXEditorUtils.WarningMessage("No keyword found in button text."); } else { EditorGUILayout.LabelField("Keyword: " + text.Text); } break; case CompoundButtonSpeech.KeywordSourceEnum.LocalOverride: speechButton.Keyword = EditorGUILayout.TextField(speechButton.Keyword); break; case CompoundButtonSpeech.KeywordSourceEnum.None: HUXEditorUtils.DrawSubtleMiniLabel("(Speech control disabled)"); break; } HUXEditorUtils.EndSectionBox(); HUXEditorUtils.SaveChanges(target); }
private void AddText() { CompoundButtonSpeech speechButton = (CompoundButtonSpeech)target; speechButton.gameObject.AddComponent <CompoundButtonText>(); }