Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Problem with changing screen orientation

Discussion in 'iOS and tvOS' started by Anipen, Oct 15, 2014.

  1. Anipen

    Anipen

    Joined:
    Oct 15, 2014
    Posts:
    12
    Now I'm developing an app that starting orientation is portrait and change it to landscape left on runtime manually by changing Screen.orientation value.

    The Screen view works well but a problem is that a cordinate of touch scrren.
    When the orientation is portrait(inital state), the touch position system works well. But after I changed the orientation to landscape left, the touch cordinates are still same to portait.

    It means that when the orientation is portrait, the width of screen is 640 piexls and the height of screen is 1136 on iphone 5(test phone). But I think it still remains same when I changed the orientation to landscape.

    I checked the touching position after I changed to landscape. I found that the maximum value of the width is still 640, not 1136 so the device reconiges all postion over 640 as 640. But sometimes when I trying touch several times, the device does in fact work and gives the correct position value, and sometimes not!

    I'v trying to find the solution on google and find this :
    http://forum.unity3d.com/threads/screen-orientation-gettouch-negative-value-problem.254648/

    but this one is already patched!
    but still doesn't work!

    I'm using unity 4.5.4f1, and Xcode 6.0.1 for ios8.

    Any ideas?

    Thanks for your help
     
  2. RobinCMR

    RobinCMR

    Joined:
    Sep 25, 2014
    Posts:
    6
    Last edited: Oct 15, 2014
  3. Mantas-Puida

    Mantas-Puida

    Unity Technologies

    Joined:
    Nov 13, 2008
    Posts:
    1,864
    Please try 4.5.5p1 patch release, if problem remains please submit bug report with small repro case attached.
    Thanks!
     
  4. Anipen

    Anipen

    Joined:
    Oct 15, 2014
    Posts:
    12
    I tried 4.5.5p1, but still the problem remains. And also found something insteresting. the position was still incorrect at toucheBegin event. but at touchMove and touchEnd event it worked! it got corrent position at that events. Please, check this point.
     
  5. RobinCMR

    RobinCMR

    Joined:
    Sep 25, 2014
    Posts:
    6
    Hello Mantas,

    We have tested on 4.5.5p1, 4.5.5p2, 4.6b21 (all latest versions of Unity as of writing this), the problem remains. Its still broken.

    Someone has submit bug report and yet receive any updates:
    http://forum.unity3d.com/threads/touch-events-are-disable-in-unity-4-5-4-for-ios-8.270047/
    (the bug case is: 635760).

    Please have a look at the comments at this issue tracker over here:
    http://issuetracker.unity3d.com/issues/ios-screen-dot-orientation-breaks-touch-input

    Can we have an ETA for this bug to be fixed? Its been quite a while.

    Look forward to hearing from soon.

    Thanks.
     
  6. Mantas-Puida

    Mantas-Puida

    Unity Technologies

    Joined:
    Nov 13, 2008
    Posts:
    1,864
    We are looking into it right now.
     
  7. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    663
    I actually have something else, but related i guess? my scenes are in landscape but i have a manual switch for those that want to reverse the landscape. (a physical button may be in the way or getting pressed by accident by the user).
    In any case, it's find on Android, but on iOS the accelerometer is always reversed... This started happening with the newest Xcode. And no the patches haven't fixed it.
     
  8. chorusgames

    chorusgames

    Joined:
    Jul 21, 2014
    Posts:
    15
    Same problem here! Issue with screen orientation switching on ios8 breaking touch input especially the lower half portion.
     
  9. chorusgames

    chorusgames

    Joined:
    Jul 21, 2014
    Posts:
    15
    Hi Mantas Puida any updates or ETA on when the bug will be fix? Because it is a game breaking bug and it has stop us from publishing our games out.

    And it seems that this bug that was reported on the issue tracker was deleted (which i voted on and was the hottest bug on the list last i checked) and the only one left is reported as resolved but all the comments on the post wrote otherwise. May i know what exactly is happening and how do we inform you if a bug which is reported as fixed has not been fixed?

    http://issuetracker.unity3d.com/issues/ios-screen-dot-orientation-breaks-touch-input
    case id: 617623
     
  10. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    663
    Well, mine is ok for now with 4.5.5 patch 2.
     
  11. Mantas-Puida

    Mantas-Puida

    Unity Technologies

    Joined:
    Nov 13, 2008
    Posts:
    1,864
    For touches and rotation issue, you can try following fix:
    a) Find Classes/UI/UnityViewControllerBase.mm in your Xcode project
    b) Find implementation of "ShouldAutorotate_DefaultImpl(id self_, SEL _cmd)" in that file
    c) Replace "return (UnityRequestedScreenOrientation() == autorotation);"
    with
    "return YES;"
     
  12. chorusgames

    chorusgames

    Joined:
    Jul 21, 2014
    Posts:
    15
    Hi mantas thanks for the reply.
    I have tried out the fix you suggested and manage to get the touch input working after a manual screen orientation change.
    BUT
    whenever i do a manual screen orientation, it will randomly do a auto-rotate to another orientation depending on how i hold the device. But this happens only once after a manual orientation change. Do you know whats going on?

    The steps:
    1. Do a manual orientation change in code.
    2. Touch input works on the entire screen (not just top half like last time)
    3. Rotate device in another position.
    4. App rotates to the device and locks the orientation there.
     
  13. Anipen

    Anipen

    Joined:
    Oct 15, 2014
    Posts:
    12
    Yes, exactly same problem! I've tried it out the fix, and happened same thing. Whenever I change a orientation of my app manually, it rotates to other orientation once automatically.
     
    chorusgames likes this.
  14. chorusgames

    chorusgames

    Joined:
    Jul 21, 2014
    Posts:
    15
    Any help please from unity moderators?
     
  15. jptsetung

    jptsetung

    Joined:
    Jan 12, 2013
    Posts:
    51
    I have the same problem. That's a blocking one for the project I'm currently working on.

    I tried the turn around suggested (modification of UnityViewControllerBase), it looked to work better for a while, but then I displayed an ad that forced the device in landscape mode. After that, the rendering was completly broken (back to portrait mode, but displaying an half hidden landscape view with bad proportions).
     
  16. tim-unity

    tim-unity

    Joined:
    Feb 22, 2013
    Posts:
    15
    We have exactly the same issue as you describe too. We need an urgent fix if possible as we are about to submit.

    EDIT : we updated the ad player native iOS lib and it has fixed this problem - phew!
     
    Last edited: Nov 4, 2014
  17. jptsetung

    jptsetung

    Joined:
    Jan 12, 2013
    Posts:
    51
    Any news ? ( I know I asked 2 days ago, but still, want to be sure you know there are people counting on you on this one :D )
     
    chorusgames likes this.
  18. chorusgames

    chorusgames

    Joined:
    Jul 21, 2014
    Posts:
    15
    yes some news please..
     
  19. nsandhu

    nsandhu

    Joined:
    Sep 24, 2012
    Posts:
    8
    I have the same issue for some reason the ScreenOrientation is correct for all modes except LandscapeLeft it's returning the generic value of Landscape when my device is actually rotated in the Left direction. Is there a fix for this?
     
    Last edited: Nov 7, 2014
  20. nsandhu

    nsandhu

    Joined:
    Sep 24, 2012
    Posts:
    8
    When you right click ScreenOrientation and select go to base you notice that Landscape = 3 and LandscapeLeft = 3 so there is a conflict here. It should have its own unique number like the other orientations do. As a result ScreenOrientation.LandscapeLeft always will return Landscape.
     
    Last edited: Nov 7, 2014
  21. gammaspace

    gammaspace

    Joined:
    Nov 9, 2014
    Posts:
    2
    I have been working on what I believe is the same problem for almost two weeks now, but I am working directly in Xcode with no Unity engine.

    No matter what I try, I have not been able to create a “view controller based” iOS 8 app that:

    1. Does not auto rotate, i.e. view controller’s shouldAutoRotate() returns NO.
    2. Supports all orientations, i.e. view controller’s supportedInterfaceOrientations() returns UIInterfaceOrientationMaskAll.
    3. Rotates programmatically using UIDeviceOrientationDidChangeNotification and calls to setStatusBarOrientation.
    4. Maintains proper touch coordinates and display of views on all combinations of rotating the device and opening/closing the app.

    I have tried every combination of setting the frame, transform, and center of the main window and all the views on receiving the device orientation did change notifications without any luck. I first tried creating the window, views, and view controller programmatically but then also tried .xib files, and then storyboards with similar problems.

    I thought maybe I was doing something wrong, but I am now leaning toward the idea that it is an iOS 8 bug.

    The only solution that I have found that solves all the problems is make sure the main window never gets assigned a root view controller. I get a warning message that the app is expected to have a root view controller but all works perfectly. I create the window and view programmatically, add the view as a subview to the window, and then handle device rotations as described in item 3 above.

    Hope this might help someone on the Unity team identify this issue and help Unity and/or Apple find a solution. If anybody finds a solution that does not require throwing out the view controller, I would love to hear about it.

    Thanks.
     
  22. chorusgames

    chorusgames

    Joined:
    Jul 21, 2014
    Posts:
    15
    Updated to 4.5.5p4 to check to see if screen orientation is fixed but gotten the same bug i had previously with the suggested fix which the screen does an auto-rotate after you manual rotate your device few seconds after orientation had been manually changed in code.
     
  23. jptsetung

    jptsetung

    Joined:
    Jan 12, 2013
    Posts:
    51
    Mantas (from Unity) posted here almost 2 months ago "We are looking into it right now", but I'm a bit worried not to see this problem solved in Unity 4.6 release note ( http://unity3d.com/unity/whats-new/unity-4.6 ). Is there some news on this issue?
     
  24. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,602
    Alas 4.6 was based on stock 4.5.5 (which has this problem)
    the full fix is available in 4.5.5p5 and will be available a bit later in 4.6p1
     
  25. jptsetung

    jptsetung

    Joined:
    Jan 12, 2013
    Posts:
    51
    OK, thanks for the info!
     
  26. gammaspace

    gammaspace

    Joined:
    Nov 9, 2014
    Posts:
    2
    Although I was addressing this issue without the Unity engine as seen in my prior post above, I thought I might provide an update to this somewhat dated issue from the Xcode side in case someone might find it useful.

    After upgrading to iOS 8.3, I saw a new offset issue with my custom OpenGL ES view in an app with no view controller and decided to try to get the app working again with a view controller. I have found now that I can get the app working properly with the view controller by applying the appropriate transform and center on the OpenGL ES view at launch based on the app's launch orientation.

    My view and graphics code has changed so much after updating to OpenGL ES 2.0 from 1.1 recently, that I don't know whether these changes fixed the issue or whether Apple made a fix in one of the iOS 8 updates. At least now using setStatusBarOrientation does not appear to create a problem for my app anymore. The view maintains proper touch coordinates and display on all combinations of rotating the device and opening/closing the app.
     
  27. zero_null

    zero_null

    Joined:
    Mar 11, 2014
    Posts:
    159
    Hey, I am still getting the same issue in Unity version 5.3.2f1 !
    Can you please tell me how you solved it?
    The same issue. Lower portion of screen not working after coming from a landscape mode. my problem is even worse. I can't even go to landscape mode visually. Although it works fine in android.
     
  28. povilas

    povilas

    Unity Technologies

    Joined:
    Jan 28, 2014
    Posts:
    427
    @ad_adnan Could you please submit a bug report and attach a small reproduction project to it? Please post the bug number here. Thanks
     
  29. zero_null

    zero_null

    Joined:
    Mar 11, 2014
    Posts:
    159
    hi Povilas !
    I am in a strange trouble. I have done all the hacks around but not getting it work. The worst thing is that it works fine when I make a demo for it.
    Is there any plugin that is causing issue?
    I am using UniWebview ! and iTween !
    are these cause of issue?
    Can someone suggest :(