Author Topic: screen ratios make UI go werid - iphone, ipad  (Read 4868 times)

reis

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
screen ratios make UI go werid - iphone, ipad
« on: December 06, 2013, 11:12:33 AM »
hi,
All the automatic screen sizes do happen, but I have to click play on my Unity preview twice before they sync into the correct places, I've used Anchors too. But when playing on the devices, they work on some devices, for example my most current build works on iphone 4 and ipad 2 - however the build before that, the only difference I did was click play twice to update the screen size in iphone 4 - the UI was offset in the Y axis.

Can suggestions please as the UI keeps moving up and down in the Y axis? Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: screen ratios make UI go werid - iphone, ipad
« Reply #1 on: December 06, 2013, 02:18:29 PM »
That's a very long run-on sentence, and I am having trouble understanding what you wrote there.

reis

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: screen ratios make UI go werid - iphone, ipad
« Reply #2 on: December 09, 2013, 04:19:11 AM »
Sorry about that,

The issue is the UI isn't changing for different screen sizes, To update the screen size, I have to run Unity - play twice to update to the current screen size. As the first once offsets all the UI in the Y axis for some reason. I can provide screenshots if you like.

This has been partly fixed by un-ticking, "run only once" on the anchors.
I guess an alternative way around this would be to create a UI for each iOS screen size?

Hope this is more clear sorry.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: screen ratios make UI go werid - iphone, ipad
« Reply #3 on: December 09, 2013, 07:52:15 AM »
Anchors have become deprecated with 3.0.7. As for the screen size not updating the UI when you resize the screen... are you still on Unity 3.5? I fixed it on Unity's side a loooong time ago. Even in 3.5 you could just hit CTRL+S to force a refresh.

freeExec

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: screen ratios make UI go werid - iphone, ipad
« Reply #4 on: December 09, 2013, 08:07:26 AM »
As there is a problem when the panel instance of prefab. At OnEnable mRoot = null (in parents not UIRoot).
This code not run:
  1. UIPanel.GetViewSize
  2.                 if (!clip)
  3.                 {
  4. #if UNITY_EDITOR
  5.                         if (mRoot != null) size *= mRoot.GetPixelSizeAdjustment(Mathf.RoundToInt(size.y));
  6. #else
  7.                         if (mRoot != null) size *= mRoot.GetPixelSizeAdjustment(Screen.height);
  8. #endif
  9.                 }
Neither UIRect.Ivalidate nor UIRect.ParentHasChanged not modify mRoot.
Workaround gameObject.SetActive(false) + gameObject.SetActive(true). Or store off in prefab.