@@ -105,9 +105,9 @@ private void ShowList(SerializedProperty list)
105105 for ( int index = 0 ; index < list . arraySize ; index ++ )
106106 {
107107 // the element
108- SerializedProperty elementProperty = list . GetArrayElementAtIndex ( index ) ;
108+ SerializedProperty speechCommandProperty = list . GetArrayElementAtIndex ( index ) ;
109109 EditorGUILayout . BeginHorizontal ( ) ;
110- bool elementExpanded = EditorGUILayout . PropertyField ( elementProperty ) ;
110+ bool elementExpanded = EditorGUILayout . PropertyField ( speechCommandProperty ) ;
111111 GUILayout . FlexibleSpace ( ) ;
112112 // the remove element button
113113 bool elementRemoved = GUILayout . Button ( RemoveButtonContent , EditorStyles . miniButton , MiniButtonWidth ) ;
@@ -119,9 +119,25 @@ private void ShowList(SerializedProperty list)
119119
120120 EditorGUILayout . EndHorizontal ( ) ;
121121
122+ SerializedProperty keywordProperty = speechCommandProperty . FindPropertyRelative ( "keyword" ) ;
123+
124+ bool invalidKeyword = true ;
125+ foreach ( string keyword in registeredKeywords )
126+ {
127+ if ( keyword == keywordProperty . stringValue )
128+ {
129+ invalidKeyword = false ;
130+ break ;
131+ }
132+ }
133+
134+ if ( invalidKeyword )
135+ {
136+ EditorGUILayout . HelpBox ( "Registered keyword is not recognized in the speech command profile!" , MessageType . Error ) ;
137+ }
138+
122139 if ( ! elementRemoved && elementExpanded )
123140 {
124- SerializedProperty keywordProperty = elementProperty . FindPropertyRelative ( "keyword" ) ;
125141 string [ ] keywords = availableKeywords . Concat ( new [ ] { keywordProperty . stringValue } ) . OrderBy ( keyword => keyword ) . ToArray ( ) ;
126142 int previousSelection = ArrayUtility . IndexOf ( keywords , keywordProperty . stringValue ) ;
127143 int currentSelection = EditorGUILayout . Popup ( "keyword" , previousSelection , keywords ) ;
@@ -131,7 +147,7 @@ private void ShowList(SerializedProperty list)
131147 keywordProperty . stringValue = keywords [ currentSelection ] ;
132148 }
133149
134- SerializedProperty responseProperty = elementProperty . FindPropertyRelative ( "response" ) ;
150+ SerializedProperty responseProperty = speechCommandProperty . FindPropertyRelative ( "response" ) ;
135151 EditorGUILayout . PropertyField ( responseProperty , true ) ;
136152 }
137153 }
0 commit comments