private void Start() { speechInputHandler = GetComponent <SpeechInputHandler>(); solverHandler = GetComponent <SolverHandler>(); speechInputHandler.AddResponse("Snap", ToggleSnap); }
void ConfigSpeechInputHandler() { SpeechInputHandler sih = GetComponent <SpeechInputHandler>(); UnityAction action = model.GetComponent <StepToggle>().NextStep; sih.AddResponse("Next", action); action = model.GetComponent <StepToggle>().LastStep; sih.AddResponse("Last", action); action = GetComponent <ModelPicker>().Drop; sih.AddResponse("Drop", action); action = GetComponent <ModelPicker>().ModelReturn; sih.AddResponse("Come Back", action); }
private void ShowList(SerializedProperty list) { using (new EditorGUI.IndentLevelScope()) { // keyword rows for (int index = 0; index < list.arraySize; index++) { // the element SerializedProperty speechCommandProperty = list.GetArrayElementAtIndex(index); bool elementExpanded = false; bool elementRemoved = false; using (new EditorGUILayout.HorizontalScope()) { elementExpanded = EditorGUILayout.PropertyField(speechCommandProperty, false); GUILayout.FlexibleSpace(); // the remove element button elementRemoved = GUILayout.Button(RemoveButtonContent, EditorStyles.miniButton, MiniButtonWidth); } if (elementRemoved) { list.DeleteArrayElementAtIndex(index); if (index == list.arraySize) { return; } } SerializedProperty keywordProperty = speechCommandProperty.FindPropertyRelative("keyword"); if (!distinctRegisteredKeywords?.Contains(keywordProperty.stringValue) ?? true) { EditorGUILayout.HelpBox("Registered keyword is not recognized in the speech command profile!", MessageType.Error); } if (!elementRemoved && elementExpanded) { // remove the keywords already assigned from the registered list SpeechInputHandler handler = (SpeechInputHandler)target; SpeechKeywordUtility.RenderKeywordsExcept(handler.Keywords?.Select(keywordAndResponse => keywordAndResponse.Keyword)?.ToArray(), keywordProperty); SerializedProperty responseProperty = speechCommandProperty.FindPropertyRelative("response"); EditorGUILayout.PropertyField(responseProperty, true); } } // add button row using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); // the add element button if (GUILayout.Button(AddButtonContent, EditorStyles.miniButton, MiniButtonWidth)) { var index = list.arraySize; list.InsertArrayElementAtIndex(index); var elementProperty = list.GetArrayElementAtIndex(index); SerializedProperty keywordProperty = elementProperty.FindPropertyRelative("keyword"); keywordProperty.stringValue = string.Empty; } } } }