Skip to content

Commit

Permalink
Added interactor list scrolling to MRTK3 (experimental) (#11642)
Browse files Browse the repository at this point in the history
## Overview
This adds an experimental method of scrolling through a Unity `ScrollRect` using XRI interactors.  The sample scene demonstrates how to scroll through a canvas `SrollRect` using both the poke and hand ray interactors.

![An animated image demonstrating scrolling with Unity XRI interactors](https://github.com/microsoft/MixedRealityToolkit-Unity/assets/36461279/ce1c487a-502e-477a-96e0-bda910bfc20f)

To accomplish this, the new experimental component `InteractableEventRouter` was added. The `InteractableEventRouter` component routes child XRI events to other child and parent game objects that contain the `IXRInteractableEventRouteTarget` component.

The following image shows a sample usage of this component.  In this usage, the `InteractableEventRouter` is configured to bubble up select and hover events from child games objects.

![Shows a sample usage of this component.  In this usage, the `InteractableEventRouter` is configured to bubble up select and hover events from child games objects](https://github.com/microsoft/MixedRealityToolkit-Unity/assets/36461279/7119b208-b79c-44bc-851d-9f2374a95e1c)

## Fixes
- #10736

## Known Limitations
The `InteractbleEventRouter` currently can't handle `IXRInteractableEventRouteTargets` being dynamically added. So, this may limit some use cases, such as wanting to trickle down events to children added dynamically.  

## Verification
- Unit Tests in progress
  • Loading branch information
AMollis authored Jun 26, 2023
1 parent 81698f0 commit aeadb57
Show file tree
Hide file tree
Showing 40 changed files with 124,956 additions and 24 deletions.
7 changes: 4 additions & 3 deletions UnityProjects/MRTKDevTemplate/Assets/BuildAssets/BuildApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public static class BuildApp
private static string[] scenes = {
"Assets/Scenes/Audio/AudioLoFiExample.unity",
"Assets/Scenes/Audio/AudioOcclusionExample.unity",
"Assets/Scenes/Experimental/ScrollingExample.unity",
"Assets/Scenes/Experimental/NonNativeKeyboard.unity",
"Assets/Scenes/Experimental/VirtualizedScrollRectList.unity",
"Assets/Scenes/BoundsControlExamples.unity",
"Assets/Scenes/CanvasExample.unity",
"Assets/Scenes/CanvasUITearsheet.unity",
Expand Down Expand Up @@ -42,9 +45,7 @@ public static class BuildApp
"Assets/Scenes/TapToPlaceExample.unity",
"Assets/Scenes/ToggleCollectionExample.unity",
"Assets/Scenes/TopNavigationExample.unity",
"Assets/Scenes/VanillaUGUIExample.unity",
"Assets/Scenes/Experimental/VirtualizedScrollRectList.unity",
"Assets/Scenes/Experimental/NonNativeKeyboard.unity" };
"Assets/Scenes/VanillaUGUIExample.unity" };

private static string buildPath = "build";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3750633563503633563
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3750633563503633560}
m_Layer: 0
m_Name: ColorChangingCubeWithDescription
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3750633563503633560
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3750633563503633563}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3750633563654491887}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &3750633563654491886
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3750633563654491887}
- component: {fileID: 3750633563654491885}
- component: {fileID: 3750633563654491884}
m_Layer: 0
m_Name: ColorChangingCubeDescription
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &3750633563654491887
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3750633563654491886}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.01, y: 0.01, z: 0.01}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4546248010104760701}
m_Father: {fileID: 3750633563503633560}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 20, y: 5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!23 &3750633563654491885
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3750633563654491886}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: -1005824763306460071, guid: 533bdd8d5c92b52448ee2ecf7bd828a4, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
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
m_AdditionalVertexStreams: {fileID: 0}
--- !u!114 &3750633563654491884
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3750633563654491886}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9541d86e2fd84c1d9990edf0852d74ab, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Color Change on StatefulInteractable's OnClick() Event
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 533bdd8d5c92b52448ee2ecf7bd828a4, type: 2}
m_sharedMaterial: {fileID: -1005824763306460071, guid: 533bdd8d5c92b52448ee2ecf7bd828a4, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 8
m_fontSizeBase: 8
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 0
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 1, y: 0, z: -1.5926552, w: 3.7221162}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
_SortingLayer: 0
_SortingLayerID: 0
_SortingOrder: 0
m_hasFontAssetChanged: 0
m_renderer: {fileID: 3750633563654491885}
m_maskType: 0
--- !u!1001 &3750633563840459380
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 3750633563654491887}
m_Modifications:
- target: {fileID: 593722386012418505, guid: 7d421b6091df2b5439be946871d23d28, type: 3}
propertyPath: m_Name
value: ColorChangingCube
objectReference: {fileID: 0}
- target: {fileID: 593722386012418505, guid: 7d421b6091df2b5439be946871d23d28, type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 800348947636869897, guid: 7d421b6091df2b5439be946871d23d28, type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 800348947636869897, guid: 7d421b6091df2b5439be946871d23d28, type: 3}
propertyPath: m_LocalScale.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 800348947636869897, guid: 7d421b6091df2b5439be946871d23d28, type: 3}
propertyPath: m_LocalScale.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 800348947636869897, guid: 7d421b6091df2b5439be946871d23d28, type: 3}
propertyPath: m_LocalScale.z
value: 1
objectReference: {fileID: 0}
- target: {fileID: 800348947636869897, guid: 7d421b6091df2b5439be946871d23d28, type: 3}
propertyPath: m_LocalPosition.x
value: -10
objectReference: {fileID: 0}
- target: {fileID: 800348947636869897, guid: 7d421b6091df2b5439be946871d23d28, type: 3}
propertyPath: m_LocalPosition.y
value: 1.8
objectReference: {fileID: 0}
- target: {fileID: 800348947636869897, guid: 7d421b6091df2b5439be946871d23d28, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 800348947636869897, guid: 7d421b6091df2b5439be946871d23d28, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 800348947636869897, guid: 7d421b6091df2b5439be946871d23d28, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 800348947636869897, guid: 7d421b6091df2b5439be946871d23d28, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 800348947636869897, guid: 7d421b6091df2b5439be946871d23d28, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 800348947636869897, guid: 7d421b6091df2b5439be946871d23d28, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 800348947636869897, guid: 7d421b6091df2b5439be946871d23d28, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 7d421b6091df2b5439be946871d23d28, type: 3}
--- !u!4 &4546248010104760701 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 800348947636869897, guid: 7d421b6091df2b5439be946871d23d28, type: 3}
m_PrefabInstance: {fileID: 3750633563840459380}
m_PrefabAsset: {fileID: 0}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit aeadb57

Please sign in to comment.