Search code examples
unity-game-engineindexoutofboundsexceptionvirtual-reality

Added a cube inside Unity XR's Left/Right Hand and it gave me an Index Out of Range error despite me not even coding yet


Index Out of Range Bug

Ignore the camera warning.

I already clicked the warnings and it brought me to this code in Unity's XRPass script:

       public Rect GetViewport(int viewIndex = 0)
        {
            return m_Views[viewIndex].viewport;
        }

I don't even know what this is and it doesn't throw an error in Visual Studio.


Solution

  • It is a bug in new versions of Unity. When you click an object that has a renderer in play mode, an error shows up. The bug has been reported and will be fixed soon. You can check here until the bug is fixed: Bug