Esempio n. 1
0
        protected override void OnHandleResponse(WitResponseNode response)
        {
            var intentNode = WitResultUtilities.GetFirstIntent(response);

            if (intent == intentNode["name"].Value && intentNode["confidence"].AsFloat > confidence)
            {
                onIntentTriggered.Invoke();
            }
        }
Esempio n. 2
0
        protected override void OnHandleResponse(WitResponseNode response)
        {
            var intentNode = WitResultUtilities.GetFirstIntent(response);

            if (intent == intentNode["name"].Value && intentNode["confidence"].AsFloat > confidence)
            {
                var entityValue = WitResultUtilities.GetFirstEntityValue(response, entity);
                if (!string.IsNullOrEmpty(format))
                {
                    onIntentEntityTriggered.Invoke(format.Replace("{value}", entityValue));
                }
                else
                {
                    onIntentEntityTriggered.Invoke(entityValue);
                }
            }
        }
Esempio n. 3
0
        private void ShowNodeMenu(WitResponseNode node, string path)
        {
            GenericMenu menu = new GenericMenu();

            menu.AddItem(Content.createStringValue, false, () => WitDataCreation.CreateStringValue(path));
            menu.AddItem(Content.createIntValue, false, () => WitDataCreation.CreateIntValue(path));
            menu.AddItem(Content.createFloatValue, false, () => WitDataCreation.CreateFloatValue(path));
            menu.AddSeparator("");
            menu.AddItem(Content.copyPath, false, () =>
            {
                EditorGUIUtility.systemCopyBuffer = path;
            });
            menu.AddItem(Content.copyCode, false, () =>
            {
                EditorGUIUtility.systemCopyBuffer = WitResultUtilities.GetCodeFromPath(path);
            });

            if (Selection.activeGameObject)
            {
                menu.AddSeparator("");

                var label =
                    new GUIContent($"Add response matcher to {Selection.activeObject.name}");

                menu.AddItem(label, false, () =>
                {
                    var valueHandler           = Selection.activeGameObject.AddComponent <WitResponseMatcher>();
                    valueHandler.intent        = response.GetIntentName();
                    valueHandler.valueMatchers = new ValuePathMatcher[]
                    {
                        new ValuePathMatcher()
                        {
                            path = path
                        }
                    };
                });

                AddMultiValueUpdateItems(path, menu);
            }

            menu.ShowAsContext();
        }
Esempio n. 4
0
        public void UpdateColor(WitResponseNode response)
        {
            var intent = WitResultUtilities.GetIntentName(response);

            if (intent == "change_color")
            {
                var colorString = WitResultUtilities.GetAllEntityValues(response, "color:color");
                var shapeString = WitResultUtilities.GetAllEntityValues(response, "shape:shape");

                if (colorString.Length != shapeString.Length)
                {
                    Debug.LogWarning("Mismatched entity pairings.");
                    return;
                }
                else
                {
                    for (var entity = 0; entity < shapeString.Length; entity++)
                    {
                        if (ColorUtility.TryParseHtmlString(colorString[entity], out var color))
                        {
                            if (string.IsNullOrEmpty(shapeString[entity]))
                            {
                                for (int i = 0; i < transform.childCount; i++)
                                {
                                    SetColor(transform.GetChild(i), color);
                                }
                            }
                            else
                            {
                                var shape = transform.Find(shapeString[entity]);
                                if (shape)
                                {
                                    SetColor(shape, color);
                                }
                            }
                        }
                    }
                }
            }
        }