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.LayoutSerializedObjectPopup(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.LayoutSerializedObjectPopup(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();
        }
Ejemplo n.º 2
0
 // Custom GUI
 private bool OnInspectorCustomGUI(FieldInfo fieldInfo)
 {
     // Custom layout
     if (string.Equals(fieldInfo.Name, "intent"))
     {
         EditorGUILayout.Space();
         EditorGUILayout.LabelField("Intent", EditorStyles.boldLabel);
         WitEditorUI.LayoutSerializedObjectPopup(serializedObject, "intent",
                                                 _intentNames, ref _intentIndex);
         return(true);
     }
     // Layout intent triggered
     return(false);
 }