Skip to content

Commit

Permalink
Continuous interactable and XRPokeFilter play nice with each other
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-shariff committed Jan 17, 2024
1 parent a2fa64b commit c7f7743
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Documentation~/docs/usage.md
Original file line number Diff line number Diff line change
@@ -3,10 +3,10 @@ This can be imported as a git package in Unity. The package is built to use [Uni

## Scene setup
- Setup the Scene with an XR Origin & XR Interaction Manager (see documentation [XRI documentation for more details](https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@3.0/manual/general-setup.html#create-the-xr-origin-camera-rig-for-tracked-devices)).
- Add the `HandJointData` in the scene.
- Setup the `HPUIInteractor`
- For each hand, add `hpuiinteractorright` and `HPUIInteractorLeft` prefabs to the scene.
- Setup an HPUI Interactable. (TODO)
- HPUIInteractor is an extention of `XRPokeInteractor`. You would be able to use `XRPokeFilter` on any of the HPUI Interactables. Note that, with the `HPUIContinuousInteractable`, the associated `XRPokeFilter` needs to be enabled after the surface is created. By default, once the surface is created, it will enable any XRPokeFilter component on the same GameObject, right before `continuousSurfaceCreatedEvent` is invoked.

## Interactables
TODO
10 changes: 10 additions & 0 deletions Runtime/Interaction/HPUIContinuousInteractable.cs
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
using UnityEngine;
using UnityEngine.XR.Hands;
using UnityEngine.XR.Interaction.Toolkit;
using UnityEngine.XR.Interaction.Toolkit.Filtering;

namespace ubco.ovilab.HPUI.Interaction
{
@@ -68,6 +69,10 @@ protected override void Awake()
/// <inheritdoc />
public override Transform GetAttachTransform(IXRInteractor interactor)
{
if (interactor == null)
{
return this.transform;
}
// NOTE: This also should allow the XRPokeFilter to work with ContinuousInteractable, I think!
return GetDistance(interactor.GetAttachTransform(this).transform.position).collider.transform;
}
@@ -182,6 +187,11 @@ private IEnumerator DelayedExecuteCalibration(float x_size, float y_size, List<T
OnDisable();
OnEnable();

XRPokeFilter pokeFilter = GetComponent<XRPokeFilter>();
if (pokeFilter != null)
{
pokeFilter.enabled = true;
}
continuousSurfaceCreatedEvent?.Invoke(new HPUIContinuousSurfaceCreatedEventArgs(this));
}
}

0 comments on commit c7f7743

Please sign in to comment.