diff --git a/Assets/MixedRealityAzure-Examples/LUIS/Scenes/LUISTest.unity b/Assets/MixedRealityAzure-Examples/LUIS/Scenes/LUISTest.unity
index 68410ae..9670f8c 100644
--- a/Assets/MixedRealityAzure-Examples/LUIS/Scenes/LUISTest.unity
+++ b/Assets/MixedRealityAzure-Examples/LUIS/Scenes/LUISTest.unity
@@ -113,6 +113,91 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
+--- !u!1 &393811213
+GameObject:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ serializedVersion: 5
+ m_Component:
+ - component: {fileID: 393811217}
+ - component: {fileID: 393811216}
+ - component: {fileID: 393811215}
+ - component: {fileID: 393811214}
+ m_Layer: 0
+ m_Name: Cylinder
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!23 &393811214
+MeshRenderer:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 393811213}
+ m_Enabled: 1
+ m_CastShadows: 1
+ m_ReceiveShadows: 1
+ m_DynamicOccludee: 1
+ m_MotionVectors: 1
+ m_LightProbeUsage: 1
+ m_ReflectionProbeUsage: 1
+ m_Materials:
+ - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
+ m_StaticBatchInfo:
+ firstSubMesh: 0
+ subMeshCount: 0
+ m_StaticBatchRoot: {fileID: 0}
+ m_ProbeAnchor: {fileID: 0}
+ m_LightProbeVolumeOverride: {fileID: 0}
+ m_ScaleInLightmap: 1
+ m_PreserveUVs: 1
+ m_IgnoreNormalsForChartDetection: 0
+ m_ImportantGI: 0
+ m_StitchLightmapSeams: 0
+ m_SelectedEditorRenderState: 3
+ m_MinimumChartSize: 4
+ m_AutoUVMaxDistance: 0.5
+ m_AutoUVMaxAngle: 89
+ m_LightmapParameters: {fileID: 0}
+ m_SortingLayerID: 0
+ m_SortingLayer: 0
+ m_SortingOrder: 0
+--- !u!136 &393811215
+CapsuleCollider:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 393811213}
+ m_Material: {fileID: 0}
+ m_IsTrigger: 0
+ m_Enabled: 1
+ m_Radius: 0.5
+ m_Height: 2
+ m_Direction: 1
+ m_Center: {x: 0, y: 0, z: 0}
+--- !u!33 &393811216
+MeshFilter:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 393811213}
+ m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
+--- !u!4 &393811217
+Transform:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 393811213}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: -2, y: 1, z: 2}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_Children: []
+ m_Father: {fileID: 0}
+ m_RootOrder: 5
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &664368916
GameObject:
m_ObjectHideFlags: 0
@@ -193,6 +278,92 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!1 &1043997299
+GameObject:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ serializedVersion: 5
+ m_Component:
+ - component: {fileID: 1043997303}
+ - component: {fileID: 1043997302}
+ - component: {fileID: 1043997301}
+ - component: {fileID: 1043997300}
+ m_Layer: 0
+ m_Name: Ground
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!23 &1043997300
+MeshRenderer:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 1043997299}
+ m_Enabled: 1
+ m_CastShadows: 1
+ m_ReceiveShadows: 1
+ m_DynamicOccludee: 1
+ m_MotionVectors: 1
+ m_LightProbeUsage: 1
+ m_ReflectionProbeUsage: 1
+ m_Materials:
+ - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
+ m_StaticBatchInfo:
+ firstSubMesh: 0
+ subMeshCount: 0
+ m_StaticBatchRoot: {fileID: 0}
+ m_ProbeAnchor: {fileID: 0}
+ m_LightProbeVolumeOverride: {fileID: 0}
+ m_ScaleInLightmap: 1
+ m_PreserveUVs: 1
+ m_IgnoreNormalsForChartDetection: 0
+ m_ImportantGI: 0
+ m_StitchLightmapSeams: 0
+ m_SelectedEditorRenderState: 3
+ m_MinimumChartSize: 4
+ m_AutoUVMaxDistance: 0.5
+ m_AutoUVMaxAngle: 89
+ m_LightmapParameters: {fileID: 0}
+ m_SortingLayerID: 0
+ m_SortingLayer: 0
+ m_SortingOrder: 0
+--- !u!64 &1043997301
+MeshCollider:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 1043997299}
+ m_Material: {fileID: 0}
+ m_IsTrigger: 0
+ m_Enabled: 1
+ serializedVersion: 2
+ m_Convex: 0
+ m_InflateMesh: 0
+ m_SkinWidth: 0.01
+ m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
+--- !u!33 &1043997302
+MeshFilter:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 1043997299}
+ m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
+--- !u!4 &1043997303
+Transform:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 1043997299}
+ m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
+ m_LocalPosition: {x: 0, y: -1, z: 0}
+ m_LocalScale: {x: 100, y: 100, z: 100}
+ m_Children: []
+ m_Father: {fileID: 0}
+ m_RootOrder: 3
+ m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!1 &1082056800
GameObject:
m_ObjectHideFlags: 0
@@ -258,6 +429,259 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
+--- !u!1 &1086835818
+GameObject:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ serializedVersion: 5
+ m_Component:
+ - component: {fileID: 1086835822}
+ - component: {fileID: 1086835821}
+ - component: {fileID: 1086835820}
+ - component: {fileID: 1086835819}
+ m_Layer: 0
+ m_Name: Cube
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!23 &1086835819
+MeshRenderer:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 1086835818}
+ m_Enabled: 1
+ m_CastShadows: 1
+ m_ReceiveShadows: 1
+ m_DynamicOccludee: 1
+ m_MotionVectors: 1
+ m_LightProbeUsage: 1
+ m_ReflectionProbeUsage: 1
+ m_Materials:
+ - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
+ m_StaticBatchInfo:
+ firstSubMesh: 0
+ subMeshCount: 0
+ m_StaticBatchRoot: {fileID: 0}
+ m_ProbeAnchor: {fileID: 0}
+ m_LightProbeVolumeOverride: {fileID: 0}
+ m_ScaleInLightmap: 1
+ m_PreserveUVs: 1
+ m_IgnoreNormalsForChartDetection: 0
+ m_ImportantGI: 0
+ m_StitchLightmapSeams: 0
+ m_SelectedEditorRenderState: 3
+ m_MinimumChartSize: 4
+ m_AutoUVMaxDistance: 0.5
+ m_AutoUVMaxAngle: 89
+ m_LightmapParameters: {fileID: 0}
+ m_SortingLayerID: 0
+ m_SortingLayer: 0
+ m_SortingOrder: 0
+--- !u!65 &1086835820
+BoxCollider:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 1086835818}
+ m_Material: {fileID: 0}
+ m_IsTrigger: 0
+ m_Enabled: 1
+ serializedVersion: 2
+ m_Size: {x: 1, y: 1, z: 1}
+ m_Center: {x: 0, y: 0, z: 0}
+--- !u!33 &1086835821
+MeshFilter:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 1086835818}
+ m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
+--- !u!4 &1086835822
+Transform:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 1086835818}
+ m_LocalRotation: {x: 0.35355338, y: 0.35355338, z: -0.1464466, w: 0.8535535}
+ m_LocalPosition: {x: 0, y: 1, z: 4}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_Children: []
+ m_Father: {fileID: 0}
+ m_RootOrder: 6
+ m_LocalEulerAnglesHint: {x: 45, y: 45, z: 0}
+--- !u!1 &1730099933
+GameObject:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ serializedVersion: 5
+ m_Component:
+ - component: {fileID: 1730099937}
+ - component: {fileID: 1730099936}
+ - component: {fileID: 1730099935}
+ - component: {fileID: 1730099934}
+ m_Layer: 0
+ m_Name: Sphere
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!23 &1730099934
+MeshRenderer:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 1730099933}
+ m_Enabled: 1
+ m_CastShadows: 1
+ m_ReceiveShadows: 1
+ m_DynamicOccludee: 1
+ m_MotionVectors: 1
+ m_LightProbeUsage: 1
+ m_ReflectionProbeUsage: 1
+ m_Materials:
+ - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
+ m_StaticBatchInfo:
+ firstSubMesh: 0
+ subMeshCount: 0
+ m_StaticBatchRoot: {fileID: 0}
+ m_ProbeAnchor: {fileID: 0}
+ m_LightProbeVolumeOverride: {fileID: 0}
+ m_ScaleInLightmap: 1
+ m_PreserveUVs: 1
+ m_IgnoreNormalsForChartDetection: 0
+ m_ImportantGI: 0
+ m_StitchLightmapSeams: 0
+ m_SelectedEditorRenderState: 3
+ m_MinimumChartSize: 4
+ m_AutoUVMaxDistance: 0.5
+ m_AutoUVMaxAngle: 89
+ m_LightmapParameters: {fileID: 0}
+ m_SortingLayerID: 0
+ m_SortingLayer: 0
+ m_SortingOrder: 0
+--- !u!135 &1730099935
+SphereCollider:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 1730099933}
+ m_Material: {fileID: 0}
+ m_IsTrigger: 0
+ m_Enabled: 1
+ serializedVersion: 2
+ m_Radius: 0.5
+ m_Center: {x: 0, y: 0, z: 0}
+--- !u!33 &1730099936
+MeshFilter:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 1730099933}
+ m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
+--- !u!4 &1730099937
+Transform:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 1730099933}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 2, y: 1, z: 2}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_Children: []
+ m_Father: {fileID: 0}
+ m_RootOrder: 4
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!1 &1764009440
+GameObject:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ serializedVersion: 5
+ m_Component:
+ - component: {fileID: 1764009443}
+ - component: {fileID: 1764009442}
+ - component: {fileID: 1764009441}
+ m_Layer: 0
+ m_Name: Text
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!102 &1764009441
+TextMesh:
+ serializedVersion: 3
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 1764009440}
+ m_Text: Hello World
+ m_OffsetZ: 0
+ m_CharacterSize: 1
+ m_LineSpacing: 1
+ m_Anchor: 4
+ m_Alignment: 0
+ m_TabSize: 4
+ m_FontSize: 50
+ m_FontStyle: 0
+ m_RichText: 1
+ m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
+ m_Color:
+ serializedVersion: 2
+ rgba: 4294967295
+--- !u!23 &1764009442
+MeshRenderer:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 1764009440}
+ m_Enabled: 1
+ m_CastShadows: 1
+ m_ReceiveShadows: 1
+ m_DynamicOccludee: 1
+ m_MotionVectors: 1
+ m_LightProbeUsage: 1
+ m_ReflectionProbeUsage: 1
+ m_Materials:
+ - {fileID: 10100, guid: 0000000000000000e000000000000000, type: 0}
+ m_StaticBatchInfo:
+ firstSubMesh: 0
+ subMeshCount: 0
+ m_StaticBatchRoot: {fileID: 0}
+ m_ProbeAnchor: {fileID: 0}
+ m_LightProbeVolumeOverride: {fileID: 0}
+ m_ScaleInLightmap: 1
+ m_PreserveUVs: 0
+ m_IgnoreNormalsForChartDetection: 0
+ m_ImportantGI: 0
+ m_StitchLightmapSeams: 0
+ m_SelectedEditorRenderState: 3
+ m_MinimumChartSize: 4
+ m_AutoUVMaxDistance: 0.5
+ m_AutoUVMaxAngle: 89
+ m_LightmapParameters: {fileID: 0}
+ m_SortingLayerID: 0
+ m_SortingLayer: 0
+ m_SortingOrder: 0
+--- !u!4 &1764009443
+Transform:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 1764009440}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: -2, y: 6, z: 9}
+ m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
+ m_Children: []
+ m_Father: {fileID: 0}
+ m_RootOrder: 7
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1776187684
GameObject:
m_ObjectHideFlags: 0
@@ -317,3 +741,4 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
luisManager: {fileID: 1776187685}
+ testUtterence: Set the box to blue
diff --git a/Assets/MixedRealityAzure/LUIS/Scripts/IIntentHandler.cs b/Assets/MixedRealityAzure/LUIS/Scripts/IIntentHandler.cs
index 6ca2bd4..9305594 100644
--- a/Assets/MixedRealityAzure/LUIS/Scripts/IIntentHandler.cs
+++ b/Assets/MixedRealityAzure/LUIS/Scripts/IIntentHandler.cs
@@ -29,13 +29,14 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using UnityEngine.EventSystems;
namespace Microsoft.MR.LUIS
{
///
/// The interface for a class that can handle a LUIS MR intent.
///
- public interface IIntentHandler
+ public interface IIntentHandler : IEventSystemHandler
{
///
/// Returns true if the handler can handle the specified intent.
diff --git a/Assets/MixedRealityAzure/LUIS/Scripts/IntentEventData.cs b/Assets/MixedRealityAzure/LUIS/Scripts/IntentEventData.cs
new file mode 100644
index 0000000..3c03721
--- /dev/null
+++ b/Assets/MixedRealityAzure/LUIS/Scripts/IntentEventData.cs
@@ -0,0 +1,49 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license.
+//
+// MIT License:
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Collections;
+using System.Collections.Generic;
+using Microsoft.Cognitive.LUIS;
+using UnityEngine;
+using UnityEngine.EventSystems;
+
+namespace Microsoft.MR.LUIS
+{
+ public class IntentEventData : BaseEventData
+ {
+ public LuisMRResult Result { get; private set; }
+
+ public Intent Intent { get; private set; }
+
+ public IntentEventData(EventSystem eventSystem) : base(eventSystem) { }
+
+ public void Initialize(Intent intent, LuisMRResult result)
+ {
+ Reset();
+ Result = result;
+ Intent = intent;
+ }
+ }
+}
diff --git a/Assets/MixedRealityAzure/LUIS/Scripts/IntentEventData.cs.meta b/Assets/MixedRealityAzure/LUIS/Scripts/IntentEventData.cs.meta
new file mode 100644
index 0000000..8c07235
--- /dev/null
+++ b/Assets/MixedRealityAzure/LUIS/Scripts/IntentEventData.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: ec83674a71bf53946a5e76b3c9aa1e83
+timeCreated: 1518635607
+licenseType: Pro
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/MixedRealityAzure/LUIS/Scripts/LuisManager.cs b/Assets/MixedRealityAzure/LUIS/Scripts/LuisManager.cs
index 676e6b0..4f2ff44 100644
--- a/Assets/MixedRealityAzure/LUIS/Scripts/LuisManager.cs
+++ b/Assets/MixedRealityAzure/LUIS/Scripts/LuisManager.cs
@@ -72,17 +72,7 @@ public class LuisManager : MonoBehaviour
[Tooltip("Whether to return full result of all intents not just the top scoring intent (for preview features only).")]
public bool Verbose = false;
- #endregion // Unity Inspector Variables
-
- #region Constructors
- ///
- /// Initializes a new instance.
- ///
- public LuisManager()
- {
- AddDefaultStrategies();
- }
- #endregion // Constructors
+ #endregion // Unity Inspector Variables
#region Internal Methods
///
@@ -127,7 +117,10 @@ protected virtual void Awake()
Debug.LogErrorFormat("'{0}' is required but is not set. {1} has been disabled.", "AppKey", this.GetType().Name);
this.enabled = false;
}
- }
+
+ // Add default strategies (can be overridden)
+ AddDefaultStrategies();
+ }
#endregion // Unity Overrides
#region Overridables / Event Triggers
diff --git a/Assets/MixedRealityAzure/LUIS/Scripts/ResolvedIntentForwarder.cs b/Assets/MixedRealityAzure/LUIS/Scripts/ResolvedIntentForwarder.cs
index d2ef435..2b2aa2b 100644
--- a/Assets/MixedRealityAzure/LUIS/Scripts/ResolvedIntentForwarder.cs
+++ b/Assets/MixedRealityAzure/LUIS/Scripts/ResolvedIntentForwarder.cs
@@ -4,6 +4,7 @@
using System.Text;
using System.Threading.Tasks;
using Microsoft.Cognitive.LUIS;
+using UnityEngine.EventSystems;
namespace Microsoft.MR.LUIS
{
@@ -15,6 +16,7 @@ public class ResolvedIntentForwarder : IIntentHandler
#region Member Variables
private List excludedIntents = new List();
private List includedIntents = new List();
+ private IntentEventData intentEventData;
#endregion // Member Variables
///
@@ -46,17 +48,42 @@ public void Handle(Intent intent, LuisMRResult result)
// Validate
if (intent == null) throw new ArgumentNullException(nameof(intent));
if (result == null) throw new ArgumentNullException(nameof(result));
+
+ // Make sure event data has been created
+ if (intentEventData == null)
+ {
+ intentEventData = new IntentEventData(EventSystem.current);
+ }
+
+ // Update event data to current values
+ intentEventData.Initialize(intent, result);
// Get all resolved entities
List resolvedEntities = result.GetAllEntities();
-
+
// Forward to all resolved entities
foreach (EntityMap map in resolvedEntities)
{
- // TODO: ExecuteEvents on map.GameObject
+ // Execute on the game object
+ if (SendToChildren)
+ {
+ ExecuteEvents.ExecuteHierarchy(map.GameObject, intentEventData, OnIntentHandler);
+ }
+ else
+ {
+ ExecuteEvents.Execute(map.GameObject, intentEventData, OnIntentHandler);
+ }
}
}
+ private static readonly ExecuteEvents.EventFunction OnIntentHandler =
+ delegate (IIntentHandler handler, BaseEventData eventData)
+ {
+ var casted = ExecuteEvents.ValidateEventData(eventData);
+ handler.Handle(casted.Intent, casted.Result);
+ casted.Use();
+ };
+
///
/// Gets the list of explicitly excluded intents.
///
@@ -69,5 +96,13 @@ public void Handle(Intent intent, LuisMRResult result)
/// If no intents are explicitly included, all intents will be forwarded.
///
public List IncludedIntents => includedIntents;
+
+ ///
+ /// Gets or set a value that indicates if events should be sent to child game objects.
+ ///
+ ///
+ /// true if if events should be sent to child game objects; otherwise false. The default is false.
+ ///
+ public bool SendToChildren { get; set; }
}
}