Author Topic: PSA: iOS 8 + Unity 4.5 + Screen dimensions  (Read 2773 times)

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
PSA: iOS 8 + Unity 4.5 + Screen dimensions
« on: September 28, 2014, 05:38:13 PM »
Just a PSA to maybe save some people a lot of wasted effort...

iOS 8 broke the behavior of Screen.width / Screen.height when reading the value before the first scene had finished loading entirely. So any code that used those values in an OnEnable or Awake handler would return weird values. Unity 4.5.4 patch notes were far too vague and had said...

Quote
iOS: Fixed handling of resolution preset in Player Settings.
iOS: Fixed startup orientation handling on iOS 8.

However, they failed to mention specifically that Unity 4.5.4 also fixed the problem with Screen.width / Screen.height giving incorrect values in Awake/OnEnable

TL;DR: Use Unity 4.5.4 if you are getting weird values for screen dimensions in your initialization code. Unity 4.6 beta 17 does not yet have these fixes, AFAIK.

kid

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: PSA: iOS 8 + Unity 4.5 + Screen dimensions
« Reply #1 on: November 17, 2014, 04:52:36 AM »
thx for sharing!

huixiong

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: PSA: iOS 8 + Unity 4.5 + Screen dimensions
« Reply #2 on: November 27, 2014, 03:00:01 AM »
Just a PSA to maybe save some people a lot of wasted effort...

iOS 8 broke the behavior of Screen.width / Screen.height when reading the value before the first scene had finished loading entirely. So any code that used those values in an OnEnable or Awake handler would return weird values. Unity 4.5.4 patch notes were far too vague and had said...

However, they failed to mention specifically that Unity 4.5.4 also fixed the problem with Screen.width / Screen.height giving incorrect values in Awake/OnEnable

TL;DR: Use Unity 4.5.4 if you are getting weird values for screen dimensions in your initialization code. Unity 4.6 beta 17 does not yet have these fixes, AFAIK.
谢谢