Switching from VR to non-VR mode at runtime
Enabling and disabling VR through keyboard input
-
Make sure you have both the XR Origin and non-VR player controllers set up in your Unity project. These controllers should be separate scripts or components attached to the player character.
-
Attach the "VRModeSwitcher" script to an empty GameObject in your scene.
-
In the Unity editor, drag and drop the XR Origin GameObject and the non-VR player controller GameObject into the appropriate fields of the "VRModeSwitcher" script component.
-
Save the script and return to the Unity editor.
-
Enter Play mode by clicking the Play button at the top of the Unity editor or by pressing Ctrl + P (Windows) or Command + P (Mac).
-
Press the (alphanumeric) 1 key to toggle between VR and non-VR modes at runtime. The corresponding player controller should be enabled or disabled based on the selected mode.