9 [CustomEditor(typeof(SpeechInputSource))]
12 private SerializedProperty persistentKeywordsProperty;
13 private SerializedProperty recognizerStart;
14 private SerializedProperty confidenceLevel;
15 private SerializedProperty keywordsAndKeys;
17 private void OnEnable()
19 persistentKeywordsProperty = serializedObject.FindProperty(
"PersistentKeywords");
20 recognizerStart = serializedObject.FindProperty(
"RecognizerStart");
21 confidenceLevel = serializedObject.FindProperty(
"recognitionConfidenceLevel");
22 keywordsAndKeys = serializedObject.FindProperty(
"Keywords");
27 serializedObject.Update();
30 EditorGUILayout.PropertyField(persistentKeywordsProperty);
31 EditorGUILayout.PropertyField(recognizerStart);
32 EditorGUILayout.PropertyField(confidenceLevel);
35 ShowList(keywordsAndKeys);
36 serializedObject.ApplyModifiedProperties();
39 if (keywordsAndKeys.arraySize == 0)
41 EditorGUILayout.HelpBox(
"No keywords have been assigned!", MessageType.Warning);
45 private static GUIContent removeButtonContent =
new GUIContent(
"-",
"Remove keyword");
46 private static GUIContent addButtonContent =
new GUIContent(
"+",
"Add keyword");
47 private static GUILayoutOption miniButtonWidth = GUILayout.Width(20.0f);
49 private static void ShowList(SerializedProperty list)
52 EditorGUILayout.PropertyField(list);
56 EditorGUI.indentLevel++;
59 EditorGUILayout.BeginHorizontal();
60 EditorGUILayout.LabelField(
"Keyword");
61 EditorGUILayout.LabelField(
"Key Shortcut");
62 EditorGUILayout.EndHorizontal();
65 for (
int index = 0; index < list.arraySize; index++)
67 EditorGUILayout.BeginHorizontal();
69 EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(index));
71 if (GUILayout.Button(removeButtonContent, EditorStyles.miniButton, miniButtonWidth))
73 list.DeleteArrayElementAtIndex(index);
75 EditorGUILayout.EndHorizontal();
79 EditorGUILayout.BeginHorizontal();
80 GUILayout.FlexibleSpace();
82 if (GUILayout.Button(addButtonContent, EditorStyles.miniButton, miniButtonWidth))
84 list.InsertArrayElementAtIndex(list.arraySize);
86 EditorGUILayout.EndHorizontal();
88 EditorGUI.indentLevel--;