URP and camera stacking works as expected … untill we initalize XR display and then its a mess.
The base camera doesn’t render at all only 1 overlay camera renders and which one seems to be a guessing game and it only renders to 1 eye. Now if we go single camera it works as expected.
For note we are using Windows Mixed Reality at the moment for testing and having tons of issues … for example the head set tracks fine using the Track Pose componenet but the controllers do not. I have gotten the
InputDevices.GetDeviceAtXRNode
to work (return the device) for left and right hand but
device.TryGetFeatureValue(CommonUsages.devicePosition, out position)
returns false e.g. cant get position or rotaiton manually and as noted the Track Pose componenet just doesn’t work at all for the controllers.
Since we are having so many issues we have just droped the idea of multiple cameras for now and are struggling to get the controllers to track. Got to say, we built a few simple VR apps on Unity; god years ago at this point using the DK2 Dev kit (really early days) and it was far far easier to get going than Unity XR has been so far. I like the idea of it but its really hard to find accurate information. Documentation doesn’t line up with what we see in code, cant find code examples that work either and poking at it till it works is a bunch of running into depricated messages and bits like finding the device using GetDeviceAtXRNode … for the left hand and then that device not having postion and rotaiton???
Just to be sure its not just my bone headed coding … which 20 years software engineering I would have thought I could get it … but I did go ahead and pull a few VR assets off the store to see what they where doing, if they would work … and no … they are doing very similar to what I am trying and it does not work.
I assume its a code problem since somethings work and some things dont but with broken docs and no code samples + the depricated code in the engine its a real strugle to figure out by pokeing at it.
[[Edit]]
device = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
Is returning an invalid device … sware it was valid before but fine that at least explains why I cant get positon … but when I iterate over my devices I do see 3 being the headset and left and right controllers … so what gives?
[[Edit]]
Okay I managed to get my devices reasonably reliably
To do so I get all instances of XRInputSubsystem … even though there should onyl be 3 this is returning 7. Its returning 3 sets of the hand controlls … not sure whats going on with that.
Any way once you have that you can loop through the inputs and get the devices for that input. Next you need to test if it has the right flags e.g. HeldInHand, TrackedDevice and Left or Right.
So to make that simpler I added 3 InputDevice fields to our SystemSettings … its just a ScriptableObject that gets intialized on bootstrap of the game. Within that I have a bit of code that looks like the following
var inputs = new List<XRInputSubsystem>();
SubsystemManager.GetInstances(inputs);
bool canTest = false;
bool result = false;
if (inputs.Count > 0)
{
List<InputDevice> devices = new List<InputDevice>();
foreach (var input in inputs)
{
if (input.TryGetInputDevices(devices))
{
foreach (var d in devices)
{
if ((d.characteristics & (InputDeviceCharacteristics.HeldInHand | InputDeviceCharacteristics.TrackedDevice | InputDeviceCharacteristics.Left)) == (InputDeviceCharacteristics.HeldInHand | InputDeviceCharacteristics.TrackedDevice | InputDeviceCharacteristics.Left))
leftHandInput = d;
if ((d.characteristics & (InputDeviceCharacteristics.HeldInHand | InputDeviceCharacteristics.TrackedDevice | InputDeviceCharacteristics.Right)) == (InputDeviceCharacteristics.HeldInHand | InputDeviceCharacteristics.TrackedDevice | InputDeviceCharacteristics.Right))
rightHandInput = d;
if ((d.characteristics & (InputDeviceCharacteristics.HeadMounted | InputDeviceCharacteristics.TrackedDevice)) == (InputDeviceCharacteristics.HeadMounted | InputDeviceCharacteristics.TrackedDevice))
headSetInput = d;
if (d.TryGetFeatureValue(CommonUsages.userPresence, out bool userPresent))
{
canTest = true;
if (userPresent)
result = true;
}
}
}
}
}
That is hackish and messy and there must be a better way of doing it but so far this is the only thing that has worked to get the device of the hand controllers so I can set position.