Open daltonbr opened 4 years ago
Orientation is correct on my side, but I do set the "Default Orientation" to "Landscape Left", which is required to use the vr camera. I'm going to update the document.
@daltonbr Can you confirm if it works on your side when app is locked to "Landscape Left"?
AutoRotation should not be used with this SDK. But, it is a nice-to-have feature, that device rotation matches in game camera with all device orientation.
Hi @cai-mobfish,
It worked perfectly when locking in LandscapeLeft, VR and NoVR.
Currently, I am locking the orientation in VR Mode and unlocking in NoVR.
In CardboardMainCamera.SetupEyeRenderTextureDescription()
I am picking the largest of the Screen.width
and Screen.height
to create the eyeRenderTextureDesc
.
private void SetupEyeRenderTextureDescription()
{
int biggerSide = Mathf.Max(Screen.width, Screen.height);
int smallerSide = Mathf.Min(Screen.width, Screen.height);
eyeRenderTextureDesc = new RenderTextureDescriptor()
{
dimension = TextureDimension.Tex2D,
width = biggerSide / 2,
height = smallerSide,
depthBufferBits = 16,
volumeDepth = 1,
msaaSamples = 1,
vrUsage = VRTextureUsage.OneEye
};
That solves a small bug when you initialize in Portrait and the turn VR mode on. This way when enabling VR I lock the orientation and I am good to go.
I manage to hack a way to compensate for the NoVR Camera projection.
private static void OverrideNoVRCameraRotation()
{
Vector3 rotation = Vector3.zero;
switch (Screen.orientation)
{
case ScreenOrientation.Portrait:
rotation = new Vector3(0, 0, 90);
break;
case ScreenOrientation.PortraitUpsideDown:
rotation = new Vector3(0, 0, -90);
break;
case ScreenOrientation.LandscapeLeft:
break;
case ScreenOrientation.LandscapeRight:
rotation = new Vector3(0, 0, 180);
break;
}
NOVRCamera.transform.localRotation = Quaternion.Euler(rotation);
}
I am not sure if Screen.orientation is reliable in all devices, but in my tests with an iPad and iPhone X, it worked ok.
I am updated with 0.7
When I am in 'No VR' mode, allowing AutoRotation on all orientations when I rotate my device the screen rotates mirrored to the wrong side. Like if I rotate clockwise, the screen rotates counterclockwise, so from the 4 possible orientations, I got one of them correct.
Even when the Camera is projecting in a wrong rotation (offset 90, -90, or 180 degrees), the camera rotation is following the gyro correctly. Meaning if I look up to the ceiling the screen rotates "up" locally.
CardboardHeadTracker.PauseTracker()
the screen rotates correctly, matching my current orientation, but I don't get the Camera tracking the gyro obviously.