Search code examples
unity-game-enginehololensmrtk

using tracking function on mrtk v2 within unity


I have been trying to figure out if it's even possible to check and handle tracked joint updates within the unity editor, every function I found in the hand tracking guide on the mrkt docs all never get called. am I using them wrong or does it just not work in the editor?

I currently use:

     public void OnHandJointsUpdated(InputEventData<IDictionary<TrackedHandJoint,           
     MixedRealityPose>> eventData)
    {
        Debug.Log("does this get called?");
        Debug.log(eventData.Handedness.ToString());
    }

Am I supposed to turn something on maybe that I am not currently doing? The hololens 2 is not yet in so I can't check if the functions work in the hololens itself.


Solution

  • To enable global events, make sure to register your component with the input system. You'll need to register every handler this way. I generally follow this pattern:

    private void OnEnable()
    {
        CoreServices.InputSystem.RegisterHandler<IMixedRealityHandJointHandler>(this);
    }
    
    private void OnDisable()
    {
        CoreServices.InputSystem.RegisterHandler<IMixedRealityHandJointHandler>(this);
    }
    

    More here: https://microsoft.github.io/MixedRealityToolkit-Unity/Documentation/Architecture/InputSystem/CoreSystem.html