public void Start() { // Disable if no microphone devices are found if (Microphone.devices.Length == 0) { enabled = false; return; } if (KeywordSource == KeywordSourceEnum.None) { return; } keyWord = string.Empty; // Assign internal cached components m_button = GetComponent <CompoundButton>(); m_button_text = GetComponent <CompoundButtonText>(); switch (KeywordSource) { case KeywordSourceEnum.ButtonText: default: keyWord = prevButtonText = m_button_text.Text; break; case KeywordSourceEnum.LocalOverride: keyWord = Keyword; break; } }
protected override void DrawCustomFooter() { ButtonTextProfile textProfile = (ButtonTextProfile)target; CompoundButtonText textButton = (CompoundButtonText)targetComponent; if (textButton == null || !textButton.OverrideOffset) { switch (textProfile.Anchor) { case TextAnchor.LowerCenter: textProfile.AnchorLowerCenterOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorLowerCenterOffset); break; case TextAnchor.LowerLeft: textProfile.AnchorLowerLeftOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorLowerLeftOffset); break; case TextAnchor.LowerRight: textProfile.AnchorLowerRightOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorLowerRightOffset); break; case TextAnchor.MiddleCenter: textProfile.AnchorMiddleCenterOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorMiddleCenterOffset); break; case TextAnchor.MiddleLeft: textProfile.AnchorMiddleLeftOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorMiddleLeftOffset); break; case TextAnchor.MiddleRight: textProfile.AnchorMiddleRightOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorMiddleRightOffset); break; case TextAnchor.UpperCenter: textProfile.AnchorUpperCenterOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorUpperCenterOffset); break; case TextAnchor.UpperLeft: textProfile.AnchorUpperLeftOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorUpperLeftOffset); break; case TextAnchor.UpperRight: textProfile.AnchorUpperRightOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorUpperRightOffset); break; } } }
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; } }