Log in or register to post comments

Changing Screen.orientation at Runtime

March 15, 2013 - 4:23am #1

Hey guys,

currently we're developing an iOS AR app, which should be capable of changing the screen orientation at runtime. We're loading additional scenes with AR content and before these scenes are loaded, we change the orientation between portrait or landscape (depending on the loaded scene) using Unity's "Screen.orientation". Somehow Vuforia doesn't synch it's orientation with the unity screen.orientation. It just takes the value from the "default orientation" in the player settings (which is "Portrait" in our case). When switching to landscape mode, the camera image is rotated by 90 degrees.

Is there a way to force the vuforia plugin to switch to a specific screen orientation at runtime? I didn't find a proper method which does this, nor do I find some helpful posts in this forum regarding this issue.

Thanks for any advice.

 

Best regards,

Daniel

Changing Screen.orientation at Runtime

June 3, 2017 - 11:41am #14

Hi Nalim,do you still have the AROrientationTest.unitypackage?

Changing Screen.orientation at Runtime

June 3, 2017 - 11:40am #13

Hi Nalim,do you still have the AROrientationTest.unitypackage?

Changing Screen.orientation at Runtime

August 27, 2014 - 7:25pm #12

Hi,

I have the same problem, How can I change the UIOrientation at runtime in iOS.

The Unity view is in a ViewController in a StoryBoard this must be in Portrait and the other ViewControllers in Landscape.

Help please, thanks.

Unity 4.3.4 
Xcode 5.1.1

Changing Screen.orientation at Runtime

May 8, 2013 - 12:53am #11

No problem, glad it was a simple fix ;)

You'll have to do this manually until the next release when I will ensure it goes into the PostProcessBuildPlayer script.

N

Changing Screen.orientation at Runtime

May 6, 2013 - 1:56am #10

Hi Nalin, 

 

thanks very much for the workaround :-)

Is there also a way to fix this issue from within the unity codebase (via a C# script) so that I don't have to change the "AppController.mm" manually each time when I did a build of the project?

Changing Screen.orientation at Runtime

May 2, 2013 - 6:57am #9

Hi Daniel,

This should fix it:

Around line 735 in AppController.mm locate this line:

 

        UnitySetScreenOrientation(requestedOrient);

and after it add the following:

 

        QCARUnityPlayer::getInstance().QCARSetOrientation(requestedOrient);

 

This worked for me.

 

HTH

N

 

Changing Screen.orientation at Runtime

May 2, 2013 - 2:14am #8

Hi Nalin,

sorry, I forgot to mention, that I'm using Unity 3.5.7 and not the newest Unity 4 version.

I downloaded the current version of vuforia but the error still occurs. Can you check it again with Unity 3.5.7 or is this impossible?

Thanks again  :-)

Changing Screen.orientation at Runtime

May 1, 2013 - 8:10am #7

When I loaded up the unity package and compiled in XCode, I got build errors.

This indicates that you are using an old version of Vuforia and possibly even an old version of Unity.

When I upgraded the various components it built properly and pressing the orientation button toggles as expected.  The camera seems to render fin in both cases.

 

Could you please upgrade to the latest version of Unity and Vuforia and then try again.  First with the test App and then your other App.

 

thanks,

N

Changing Screen.orientation at Runtime

April 30, 2013 - 3:59am #6

Hi Nalin,

I exported a simple test project to a unity package, which you can download from

download.realtimelabs.de/AROrientationTest.unitypackage

This project contains a very simple scene with just the ARCamera inside and a small script which changes orientation on a button click. As you can see, after changing the orientation from portrait to landscape, the device camera doesn't render properly anymore. When switching back to portrait everything works fine again.

Changing Screen.orientation at Runtime

April 30, 2013 - 3:13am #5

Hi Daniel,

In the Unity generated Xcode project search for:

 

QCARUnityPlayer::getInstance().QCARSetOrientation

..as this currently mirrors all changes to orientation.

It could be that you have a case that this does not catch, in which case it would be helpful if you can put together a simple repro  project based on Image Targets, and send me a link to download so I can investigate further.

 

cheers

N

 

Changing Screen.orientation at Runtime

April 30, 2013 - 2:43am #4

Hi,

I observed when the default orientation in the ios player settings is set to "Autorotate" and both landscape and portrait are enabled at startup, then the device camera works as expected in landscape mode if you rotate the device in landscape mode before activating AR for the first time. The second time when trying this in portrait mode, the error occurs as described in my initial post. So I think if the Autorotate flag is set when starting the app, the orientation of the AR  camera is depending on the current device orientation when activating AR. But when initialized once, it never changes its orientation except for a complete restart of the app.

Is there a way to call the same routine manually which is executed for the first time when AR gets initialized? 

 

Thanks a lot.

Changing Screen.orientation at Runtime

March 18, 2013 - 11:57am #3

I'm not sure this is solely a Vuforia issue. I find that whenever I switch the screen orientation, that the Screen.height and Screen.width values are still set according to the default orientation.

Changing Screen.orientation at Runtime

March 18, 2013 - 2:26am #2

Let me check with the Unity team and get back to you.

N

Log in or register to post comments