Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.
Options

OnNavigationCanceled never firing when focus changes to other collider

trzytrzy ✭✭✭
edited September 2017 in Questions And Answers

I'm trying to use the navigation gesture on two different objects in close proximity. What can happen is that as the user is gesturing over one object, their gaze penetrates the other one, and what ends up happening is that focus switches to the other object. But no cancel or completion events are fired for the first. I've also noticed that with a single object, if the gesture is started but then finished off of the object, no callbacks get fired making it impossible to detect whether the gesture was actually completed.

Does anyone have a solution for this? I'm testing with Holographic emulation in Unity 2017.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using HoloToolkit.Unity.InputModule;

[System.Serializable]
public class MyFloatEvent : UnityEvent<float>
{
}

public class DragValue: MonoBehaviour, INavigationHandler, IInputClickHandler
{
  public float minValue = 0.5f;
  public float maxValue = 2f;

  public MyFloatEvent OnValueChanged;

  public void OnNavigationStarted(NavigationEventData eventData)
  {
    Debug.Log(gameObject.name + ": OnNavigationStarted");
  }

  public void OnNavigationUpdated(NavigationEventData eventData)
  {
    // Convert [-1,1] -> [minValue,maxValue]
    float delta = eventData.CumulativeDelta.y;
    float value = Mathf.Lerp(minValue, maxValue, 0.5f * (delta + 1));

    // Call handler
    if (OnValueChanged != null)
      OnValueChanged.Invoke(value);
  }

  public void OnNavigationCompleted(NavigationEventData eventData)
  {
    Debug.Log(gameObject.name + ": OnNavigationCompleted");
  }

  public void OnNavigationCanceled(NavigationEventData eventData)
  {
    Debug.Log(gameObject.name + ": OnNavigationCanceled");
  }

  public void OnInputClicked(InputClickedEventData eventData)
  {
    /*
    Debug.Log("got here");
    if (OnValueChanged != null)
      OnValueChanged.Invoke(0.5f);
      */
  }
}

Thank you!

Sign In or Register to comment.