#How to find out whether the player is in VR?

2 messages · Page 1 of 1 (latest)

slim nebula
slim nebula
#

I just found a "hack" to make it work... I checked whether the 2 matrix's from left and right eye are the same... If they are, we are not on VR. If they are not, we are in VR:

`leftProjMatrix = SpatialBridge.cameraService.GetStereoProjectionMatrix(Camera.StereoscopicEye.Left);
rightProjMatrix = SpatialBridge.cameraService.GetStereoProjectionMatrix(Camera.StereoscopicEye.Right);

matricesAreDifferent = AreMatricesDifferent(leftProjMatrix, rightProjMatrix);

....

// Helper function to compare two matrices
bool AreMatricesDifferent(Matrix4x4 matrixA, Matrix4x4 matrixB)
{
for (int i = 0; i < 16; i++)
{
if (matrixA[i] != matrixB[i])
{
return true; // Matrices are different
}
}
return false; // Matrices are the same
}

string MatrixToString(Matrix4x4 matrix)
{
return $"{matrix.m00:F3}, {matrix.m01:F3}, {matrix.m02:F3}, {matrix.m03:F3}\n" +
$"{matrix.m10:F3}, {matrix.m11:F3}, {matrix.m12:F3}, {matrix.m13:F3}\n" +
$"{matrix.m20:F3}, {matrix.m21:F3}, {matrix.m22:F3}, {matrix.m23:F3}\n" +
$"{matrix.m30:F3}, {matrix.m31:F3}, {matrix.m32:F3}, {matrix.m33:F3}";
}
`