Reputation: 174
I had HoloToolkit-Unity-2017.4.3.0-Refresh
in my project but some in the built in scripts has gone obsolete. I worked around this and recently added an OnInputClicked
method but when trying to build this there were so many error in other scripts that I changed to MRTK v2.
I looked around a bit but couldn't seem to find any tutorials on how to make a click event for HoloLens device in any of MRTK v2s documentation. IInputHandler
is no longer in the MRTK, but does IMixedRealityInputHandler
work the same?
The code below is how the clickEvent used to look like with the HoloToolkit
. Is it still the same with MRTK v2?
public void OnInputClicked(InputEventData eventData)
{
...
}
Also is this sufficient enough to trigger other methods or do I have to add the click event in the void Update()
-ish? Another also - is this enough for triggering a click event through the hololens?
Thanks!
Upvotes: 0
Views: 2136
Reputation: 73
There's an HTK to MRTK porting guide in the documentation: https://microsoft.github.io/MixedRealityToolkit-Unity/Documentation/HTKToMRTKPortingGuide.html#interface-and-event-mappings
This contains an interface mapping table, which should help migrate prefabs and interfaces from HTK to MRTK v2.
As far as this specific case, IMixedRealityPointerHandler
is indeed what you're looking for, if you need to know when a specific button (assigned to a specific pointer) has been clicked. If you're just looking to know when any button has been released, IMixedRealityInputHandler
might be a better choice for you.
Upvotes: 1
Reputation: 90580
I looked into it and apprently it changed (?) to
public class NewBehaviourScript : MonoBehaviour, IMixedRealityInputHandler
{
public void OnInputUp(InputEventData eventData)
{
}
public void OnInputDown(InputEventData eventData)
{
}
}
Or maybe you rather want the IMixedRealityPointerHandler
public class NewBehaviourScript : MonoBehaviour, IMixedRealityPointerHandler
{
public void OnPointerUp(MixedRealityPointerEventData eventData)
{
}
public void OnPointerDown(MixedRealityPointerEventData eventData)
{
}
public void OnPointerClicked(MixedRealityPointerEventData eventData)
{
}
}
and than yes that should afaik be enough to get those methods called (ofcourse it also needs a Collider somewhere on the GameObject or its children).
Here you can find a complete overview over what Input is available in MRTK 2 and how to set it up.
Upvotes: 1