Unity Community

Register or Sign In:

+ Reply to Thread
Results 1 to 9 of 9

  1. Location
    Toronto, Ontario
    Posts
    184

    OpenFeint iPad screen orientation on startup?

    I already have my game detecting iPad orientation and rotating properly. And I have the Unity splash screen orienting to proper rotation on app startup.

    But I can't figure out how to force the OpenFeint login screen to rotate to the current orientation on app startup. It always opens according to the "Initial Dashboard Orientation" that's set in OpenFeint settings. This means if I have the iPad in the opposite orientation (upside down) when I launch the game, the OF Login screen will be displayed upside down. This is the screen that comes up immediately before/as the game starts -- apparently the login dashboard is called before any game scripts are executed so I can't even get it to check SetDashboardOrientation() before it launches.

    I'm using

    Code:  
    1. OpenFeint.SetDashboardOrientation(iPhoneInput.orientation);

    before launching the Dashboard from menus inside the game so that the dashboard at least gets the proper orientation. But when the OF window is up, it doesn't rotate with the iPad.

    Any thoughts on how to handle either of the above issues?


  2. Location
    Boston, MA
    Posts
    69
    Hi,

    I ended up working around this issue in AppController+OpenFeint.mm by keeping track of the UIDevice orientation property and when it differs/changes from the last time I checked it, I close the OF dashboard altogether. This doesn't rotate the dashboard, but it will at least close it when it's open and the orientation changes, and Apple did approve my iPad game which employed this workaround.

    For example, here's the code for an app that uses Portrait and PortraitUpsideDown (change as needed for Landscape variants):

    Code:  
    1. UIDeviceOrientation origDeviceOrientation;
    2. NSTimer *orientationTimer;
    3.  
    4. // OpenFeintDelegate //
    5. - (void)dashboardWillAppear
    6. {
    7.     origDeviceOrientation = [UIDevice currentDevice].orientation;
    8.     if (origDeviceOrientation == UIDeviceOrientationPortraitUpsideDown)
    9.     {
    10.         [OpenFeint setDashboardOrientation:UIInterfaceOrientationPortraitUpsideDown];
    11.     }
    12.     else
    13.     {
    14.         [OpenFeint setDashboardOrientation:UIInterfaceOrientationPortrait];
    15.     }
    16.     orientationTimer = [NSTimer scheduledTimerWithTimeInterval:0.2f
    17.             target:self selector:@selector(checkOrientation:)
    18.             userInfo:nil repeats:YES];
    19.    
    20.     unityPaused = YES;
    21.     UnitySetAudioSessionActive(false);
    22.     UnityPause(true);
    23. }
    24.  
    25. - (void)dashboardDidDisappear
    26. {
    27.     [orientationTimer invalidate];
    28.     unityPaused = NO;
    29.     UnitySetAudioSessionActive(true);
    30.     UnityPause(false);
    31. }
    32.  
    33. - (void) checkOrientation:(NSTimer *) theTimer
    34. {
    35.     UIDeviceOrientation dor = [UIDevice currentDevice].orientation;
    36.     if (dor != origDeviceOrientation && (dor == UIDeviceOrientationPortrait || dor == UIDeviceOrientationPortraitUpsideDown))
    37.     {
    38.         [OpenFeint dismissDashboard];
    39.     }
    40. }

    As for launching the dashboard in the correct orientation to begin with, I also used code similar to that which you referenced, but I specifically set the orientation in it.

    For example, I have the following attached to my main Camera in one of my scenes:

    Code:  
    1. {
    2.     if ((iPhoneInput.orientation == iPhoneOrientation.Portrait) && (iPhoneSettings.screenOrientation != iPhoneScreenOrientation.Portrait))
    3.     {
    4.         iPhoneSettings.screenOrientation = iPhoneScreenOrientation.Portrait;
    5.         OpenFeint.SetDashboardOrientation(iPhoneOrientation.Portrait);
    6.     }
    7.     else if ((iPhoneInput.orientation == iPhoneOrientation.PortraitUpsideDown) && (iPhoneSettings.screenOrientation != iPhoneScreenOrientation.PortraitUpsideDown))
    8.     {
    9.         iPhoneSettings.screenOrientation = iPhoneScreenOrientation.PortraitUpsideDown;
    10.        OpenFeint.SetDashboardOrientation(iPhoneOrientation.PortraitUpsideDown);
    11.     }
    12. }

    Add in the required Info.plist changes to launch in the correct orientations and the iPhoneKeyboard.autorotate* properties to prevent the outer app frame from rotating, and Apple approved the resulting behavior in my OF-enabled iPad game so although this is a workaround maybe it will also work for you.

    Cheers,
    Sean


  3. Location
    Toronto, Ontario
    Posts
    184
    Thanks, Sean! That's just the information I needed. Everything is working better now, tho it would be nice if there were a way to rotate OF rather than just closing it. Hopefully the OF guys will figure this out.

  4. Banned
    Posts
    12
    Thanks a lot for the information, it really saved me some time!

    I am having a few issues thought.. I have added the following key to my Info.plist

    Code:  
    1. <key>UISupportedInterfaceOrientations</key>
    2.     <array>
    3.     <string>UIInterfaceOrientationPortrait</string>
    4.     <string>UIInterfaceOrientationPortraitUpsideDown</string>
    5.     <string>UIInterfaceOrientationLandscapeLeft</string>
    6.     <string>UIInterfaceOrientationLandscapeRight</string>
    7.     </array>

    Which gets my splash screen and initial orientation to look correct. I have also added these 2 lines to my main Start() method on my game script:

    Code:  
    1. iPhoneSettings.screenOrientation = (iPhoneScreenOrientation)iPhoneInput.orientation;
    2. OpenFeint.SetDashboardOrientation(iPhoneInput.orientation);

    When the application launches the splash screen looks fine, the initial game screen looks fine, but when the OF "Welcome Back" notification pops up it is upside down and comes from the bottom (instead of the top as it should). If I click the OpenFeint button to launch the dashboard the dashboard launches fine but the OS Status bar is shown upside down on the bottom of the screen. If I close the OF dashboard and then re-launch it everything looks fine. Any suggestions?


  5. Location
    Toronto, Ontario
    Posts
    184
    I use the following code to make my screen flip when the device is rotated and it should also make sure that the OpenFeint Dashboard and Achievement prompts are oriented properly when they display:

    Code:  
    1. function FixedUpdate() {
    2.     if ((iPhoneInput.orientation == iPhoneOrientation.LandscapeLeft) && (iPhoneSettings.screenOrientation != iPhoneScreenOrientation.LandscapeLeft)){
    3.         iPhoneSettings.screenOrientation = iPhoneScreenOrientation.LandscapeLeft;
    4.         OpenFeint.SetDashboardOrientation(iPhoneOrientation.LandscapeLeft);
    5.     }
    6.     if ((iPhoneInput.orientation == iPhoneOrientation.LandscapeRight) && (iPhoneSettings.screenOrientation != iPhoneScreenOrientation.LandscapeRight)){
    7.         iPhoneSettings.screenOrientation = iPhoneScreenOrientation.LandscapeRight;
    8.         OpenFeint.SetDashboardOrientation(iPhoneOrientation.LandscapeRight);
    9.     }
    10. }

  6. ss ss is offline

    Posts
    8
    I've got it all working correctly thanks to you guys! - Except the OpenFeint.
    In LandscapeRight the OpenFeint "welcome back" and "dashboard" are displayed upside down?
    Any help would be greatly apprieciated...Thanks


  7. Location
    India
    Posts
    9
    Write the code as below and it will work…no need to close the openfient dashboard:

    Code:  
    1. - (void) checkOrientation:(NSTimer *) theTimer
    2. {
    3.     origDeviceOrientation = [UIDevice currentDevice].orientation;
    4.     if (origDeviceOrientation == UIDeviceOrientationPortraitUpsideDown)
    5.     {
    6.         [OpenFeint setDashboardOrientation:UIInterfaceOrientationPortraitUpsideDown];
    7.     }
    8.     else
    9.     {
    10.         [OpenFeint setDashboardOrientation:UIInterfaceOrientationPortrait];
    11.     }
    12. }

    Enjoy!!!!!

    Regards,
    Prakaash
    Last edited by Prakash; 10-29-2010 at 06:21 AM.


  8. Posts
    8
    Quote Originally Posted by Prakash View Post
    Write the code as below and it will work…no need to close the openfient dashboard:

    Code:  
    1. - (void) checkOrientation:(NSTimer *) theTimer
    2. {
    3.     origDeviceOrientation = [UIDevice currentDevice].orientation;
    4.     if (origDeviceOrientation == UIDeviceOrientationPortraitUpsideDown)
    5.     {
    6.         [OpenFeint setDashboardOrientation:UIInterfaceOrientationPortraitUpsideDown];
    7.     }
    8.     else
    9.     {
    10.         [OpenFeint setDashboardOrientation:UIInterfaceOrientationPortrait];
    11.     }
    12. }

    Enjoy!!!!!

    Regards,
    Prakaash

    Prakaash, what file do we add this code to?


  9. Posts
    56
    For those still interested..

    Using OF SDK 2.10, just change AppController+Openfeint.mm (line 1033) to something like this:

    Code:  
    1. - (void)deviceOrientationChanged:(NSNotification*)notification
    2. {
    3.     UIInterfaceOrientation orientation = (UIInterfaceOrientation)[[UIDevice currentDevice] orientation];
    4.     if(orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
    5.         [OpenFeint setDashboardOrientation:orientation];
    6.     }
    7. // Original code...
    8. //  if(orientation >= UIInterfaceOrientationPortrait && orientation <= UIInterfaceOrientationLandscapeLeft) {
    9. //      [OpenFeint setDashboardOrientation:orientation];
    10. //  }
    11. }