question

Juan-1088 avatar image
0 Votes"
Juan-1088 asked SethDu-MSFT edited

InputActionHandler script in MRTK throwing IndexOutOfRangeException when setting Input Action

I am trying to develop a HoloLens 2 app using MRTK in Unity. My goal is to execute a function when holding/air tapping, so I have followed this tutorial. I have added a new Input Action, marked it as "Digital", and linked it to the Hold gesture Action under the Gestures drop down. However, when I try to assign it to the InputActionHandler script (which is in my camera object), it throws the following error whenever I select my custom Action from the drop down:

 IndexOutOfRangeException: Index was outside the bounds of the array.
 Microsoft.MixedReality.Toolkit.Input.Editor.InputActionPropertyDrawer.OnGUI (UnityEngine.Rect rect, UnityEditor.SerializedProperty property, UnityEngine.GUIContent content)

Selecting other default actions doesn't give this error, and since I can see my Action in the dropdown, I'm assuming it may be a bug.

Any help is appreciated, thank you.



hololens-development
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Forgot to attatch some pictures in case they're needed:
199707-image.png

199732-image.png

199700-image.png

Note in my camera object that the Input Action is set to "None" because I can't set up my action (which is named "Fire Raycast").


0 Votes 0 ·
image.png (45.7 KiB)

Hi, I have tried to reproduce this issue by creating a customized input and mapping it to a hold gesture. However, this issue doensn't occur in my testing environment. The input action handler reponds expectedly when Hold action is triggered.
I notice that one of the screenshots that you are about to share didn't upload successfuly. Would you share it again?
It is also recommended to share a minimal, reproducible example with us. Thansk for your understanding.

0 Votes 0 ·

Mhm, when I posted the comment, the pictures were visible, I don't know what happened to them...

Anyways, I tried to make a minimal reproducible example as you suggested and the bug didn't occur, so I attatch a copy of my project with most of the assets removed, to see if I messed it up at some point.

Download link: https://drive.google.com/file/d/1Ub3eyGsKVnlbaBPQpNvA4PC65ybeita3/view?usp=sharing

Also, is there anything wrong with having the InputActionHandler in the camera itself? I'm assuming the script checks constantly for the actions anywhere in the scene, or does it only check the actions on itself, so I won't be able to "hold" the camera, and therefore trigger the action?

0 Votes 0 ·

1 Answer

SethDu-MSFT avatar image
0 Votes"
SethDu-MSFT answered SethDu-MSFT edited

Hello, welcome to Microsoft Q&A,

I can reproduce the issue you have described above. According to my test experience, it can be caused by corrupted MRTK configuration files.

To solve this issue, simply delete the Fire Raycast and add a new Action then reimport the assets. To reproduce and test this issue I have done the following steps then the issue is solved.

  1. Add a new Action. Close and re-open the project. Fire Raycast now can be selected in Input Action Handler, but my customized action is unable to select, there is no error in the console.

  2. Delete both actions then add Fire Raycast again. Reimport the assets and refresh the project.

  3. Input Action Handle and Fire Raycast work fine now.


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

This does seem to fix the error bug, but nothing seems to happen when performing the hold action, not even a simple Debug.Log command executes...

0 Votes 0 ·

I notice your proejct doesn't contain AsyncCoroutineRunner. Attaching this script to any game object in the scene should solve gesture not being triggered.

0 Votes 0 ·

That didn't solve it. I've noticed that using the default "Select" action (which is Digital type) works as expected, even without the AsyncCoroutineRunner script. It seems to me this whole part of MRTK is quite bugged...

0 Votes 0 ·

I re-download your proejct in the commnet and do the following steps:

  1. Open with Unity LTS verion (2020.3.33f1)

  2. Delete Fire Raycast input action in MRTK. Reimport the proejct.

  3. Add new input "FireRayCast" then reimport the proejct again. (Name is slightly different to distinguesh)

  4. In the Gestures section of MRTK, select FireRayCast as Hold action.

  5. remove rigidbody of MiCubo1 and ajust postion for testing.

  6. remove the missing script component of "Main Camera"

  7. Add On Input Action in Input Handler, drag and drop Main Camera and select the Raycast() function.

  8. Uncheck "Is Focus Required" (you may enable it later, let's test Hold gesture)

If you have any issues, try to reimport and refresh the project before moving to the next step. And you are correct about AsyncCoroutineRunner, it is not compulsory for this feature.


0 Votes 0 ·