public override void OnInspectorGUI() { if (!handler.wit) { GUILayout.Label( "Wit component is not present in the scene. Add wit to scene to get intent and entity suggestions.", EditorStyles.helpBox); } if (handler && handler.wit && null == intentNames) { if (handler.wit is IWitRuntimeConfigProvider provider && null != provider.RuntimeConfiguration && provider.RuntimeConfiguration.witConfiguration) { provider.RuntimeConfiguration.witConfiguration.UpdateData(); intentNames = provider.RuntimeConfiguration.witConfiguration.intents.Select(i => i.name).ToArray(); intentIndex = Array.IndexOf(intentNames, handler.intent); } } WitEditorUI.FallbackPopup(serializedObject, "intent", intentNames, ref intentIndex); var confidenceProperty = serializedObject.FindProperty("confidence"); EditorGUILayout.PropertyField(confidenceProperty); GUILayout.Space(16); var eventProperty = serializedObject.FindProperty("onIntentTriggered"); EditorGUILayout.PropertyField(eventProperty); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { var handler = target as SimpleStringEntityHandler; if (!handler) { return; } if (!handler.wit) { GUILayout.Label("Wit component is not present in the scene. Add wit to scene to get intent and entity suggestions.", EditorStyles.helpBox); } var intentChanged = WitEditorUI.FallbackPopup(serializedObject, "intent", intentNames, ref intentIndex); if (intentChanged || null != intentNames && intentNames.Length > 0 && null == entityNames) { if (handler && handler.wit && null == intentNames) { if (handler.wit is IWitRuntimeConfigProvider provider && null != provider.RuntimeConfiguration && provider.RuntimeConfiguration.witConfiguration) { var entities = provider.RuntimeConfiguration.witConfiguration.intents[intentIndex]?.entities; if (null != entities) { entityNames = entities.Select((e) => e.name).ToArray(); entityIndex = Array.IndexOf(entityNames, handler.entity); } } } } WitEditorUI.FallbackPopup(serializedObject, "entity", entityNames, ref entityIndex); var confidenceProperty = serializedObject.FindProperty("confidence"); EditorGUILayout.PropertyField(confidenceProperty); EditorGUILayout.Space(16); var formatProperty = serializedObject.FindProperty("format"); EditorGUILayout.PropertyField(formatProperty); GUILayout.Space(16); var eventProperty = serializedObject.FindProperty("onIntentEntityTriggered"); EditorGUILayout.PropertyField(eventProperty); serializedObject.ApplyModifiedProperties(); }