Background:
①I set “Run In Background” TRUE in “Player Setting”.
②I use PlayerInput as input event sender, and implement input classification with control scheme.Weather set “Requirments & Devices List” in “Controller Scheme” does not affect the occurrence of the problem.(My XR device is Oculus Quest 2)
Problem:
When I enter the scene, the device loads normally and the control scheme is correctly configured as shown in the code.I am also able to receive callbacks for input events normally.
input.SwitchCurrentControlScheme("Oculus", InputSystem.devices.ToArray());
When I click on other applications to let Unity run to the background, because I use “Run In Backgournd”, “Game” triggers “Application Pause”.When I go back to Unity Windows, application come back to normal,but I cannot get XR input callback anymore!
When I returned to the Unity window, I noticed that there was no longer XR info in “Devices”.
Test:
①When the scene is just loaded, I manually configure “Scheme” through code, and load “Devices” at this time.
So when in “Application Pause callback”, I also reconfigure “Scheme” using a similar method. But this method didn’t completely solve my problem.
private void OnApplicationPause(bool pause)
{
if (!pause)
{
input.SwitchCurrentControlScheme("Oculus", InputSystem.devices.ToArray());
}
}
②I compared the input from the keyboard, even if the above configuration is exactly the same, it will not fail to receive the callback due to the reason of switching to the background.
③There is also a less relevant thing. Since the XR device may not be activated when the scene is loaded, a timing method is made. Only when the XR device is detected ,can the “Scheme” be set.
Thanks a lot!!!
BTW,is there any PlayerInput with XR tutorial. :)