I’m building an iOS app in Unity that uses the Cardboard SDK and the Cardboard scene is being crushed horizontally when I transition from a scene that runs in portrait orientation, to the cardboard scene that runs in landscape. Here’s what it looks like crushed…
and here’s what it should look like…
In the Player Settings, I have the default orientation for my Unity project set to portrait, since that’s orientation my starts with to display the 2D mobile interface that takes the user to the cardboard scene. In the cardboard scene, I force landscape orientation using the following code…
void Awake () {
Screen.orientation = ScreenOrientation.LandscapeLeft;
}
I also tried forcing rotation sooner, in the portrait scene right before loading the cardboard scene, and I’m having the same issue.
Your thoughts? Should I be forcing landscape orientation sooner? Other ideas?
I found the same problem. It seems that on ios cardboard uses the orientation when it is created the first time to resize the vr view. I created a prefab of the cardboard main game object and then instantiated this after the device finished switching orientation (in a coroutine). This is a bit of a hack, but it works. The alternative would prob be to change something in cardboard’s code. There doesn’t seem to be a method in cardboard to re-init the display. Maybe I just missed it
I had the very same problem in my recent project, developing for both: Android and iOS.
The problem lies in the fact that Cardboard sdk doesn’t support any orientation except for landscape left. Any attempt to use another orientation will lead to a cropped view like the screenshots you posted.
If you don’t need a portrait mode, the problem is easily fixed by choosing landscape left mode in Unity’s player settings (note that using auto rotation and just allowing landscape left doesn’t work for me on iOS as the Xcode throws an error about auto rotation, not sure why. Android doesn’t suffer of this, so you can choose whatever you want).
However, if you like me, do need portrait and landscape mode for certain scenes, then you need to take further steps.
According to this thread (I suggest you to read it) you need to change the screen orientation to landscape left as stated above, before you load you cardboard camera VR (GvrMain prefab), that way it will start with the appropriate orientation and wont give you troubles.
So they suggested to change the GvrMain cardboard script to add this line:
Screen.orientation = ScreenOrientation.LandscapeLeft;
However it was not clear for me where exactly does the line should be added and I ended up putting in several places until it worked, but turns out that what worked for Android, doesn’t worked for iOS.
For android, I added the line in the Awake function just at the beginning and it worked well.
For iOS, after spend a whole day, trying to figure out why it wasn’t working, I ended up with some kind of cheat, since my app had several scenes and I needed to change from one to another from portrait to landscape (which was causing the trouble) So, basically I changed the orientation before the scene loads, just before the line that loads the desired scene and it turns out that worked pretty well on iOS since it follows the condition stated above for the GvrMain.
Hope this helps someone with the same problem.
Thanks @spieluhr_x , it also works for my android project!