using MRTK implementation add listener codes

63 views Asked by At
contactDetection.onTouch.AddListener(MyCallback);
contactDetection.onFirstTouch.AddListener(DoThisOnFirstTouch);
contactDetection.onLastUntouch.AddListener(DoThisOnLastUntouch);

I was using these lines of code for HPTK for oculus, but I want to do the same for MRTK. Can someone help me? How can I do that?

I was trying to know when my object was touches and left. When my cursor first touches my object, then when it lefts the touch of my object.

1

There are 1 answers

0
Shiwen Sun -MSFT On

In MRTK, you can use Interactable or ObjectManipulator to detect if an object is being touched. For more information, you can refer Buttons - MRTK 2 | Microsoft Learn and Object manipulator - MRTK 2 | Microsoft Learn. Regarding whether it's the first touch, maybe you can add a counter manually.