Author Topic: iPhone 5 Height and different aspect ratio  (Read 15425 times)

bitomule

  • Guest
iPhone 5 Height and different aspect ratio
« on: October 07, 2012, 02:20:42 PM »
Hi,

I'm developing a simple unity game and designing interface based on old iphone's screen ratio. NGUI Anchors and scale works as expected but puts buttons out of screen on iPhone5. Seems like it keeps old iPhone aspect ratio. How can I fix that so my gui can take advantage of the extra height but no more width?

Thanks :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 270
  • -Receive: 1132
  • Posts: 21,846
  • Toronto, Canada
    • View Profile
Re: iPhone 5 Height and different aspect ratio
« Reply #1 on: October 07, 2012, 07:34:23 PM »
UIRoot and anchors are always based on screen's width and height, so assuming Unity is reporting it correctly, everything should work just fine.

bitomule

  • Guest
Re: iPhone 5 Height and different aspect ratio
« Reply #2 on: October 08, 2012, 01:46:27 AM »
Anchors works well, the problem is that I'm using center anchor to place some elements, those elements are near left and right borders. On iPhone 5 those elements are placed on the center, but not scaled enough to fit screen width. Maybe I'm doing something wrong. Should I combine anchor center and anchor left/right?

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 32
  • -Receive: 140
  • Posts: 1,761
    • View Profile
Re: iPhone 5 Height and different aspect ratio
« Reply #3 on: October 08, 2012, 03:37:25 AM »
iphone 5 is 1136x640 (or flipped).

If you have not updated your unity, the old unity will only recognize it as a regular iphone 4s and give your letterboxing around your stuff.

When you have update your unity you can figure out the formfactor by looking at

  1. iPhone.generation == iPhoneGeneration.iPhone5

If your xcode build does not make a Default-h2[somenumbers]@x2.png, it will force letter boxing as well. (If you want to force it, just delete this file if it makes it.

NGUI only has access to the Screen.height and Screen.width that unity provides and that depends on the version of unity.

I hope this helps.

bitomule

  • Guest
Re: iPhone 5 Height and different aspect ratio
« Reply #4 on: October 08, 2012, 04:01:11 AM »
Thanks Nicki,

but I've update Unity (I have iPhone5 screen ratios on Unity play window).

I've added 2 images to show the problem. First one is iPhone3g/3gs/4/4s aspect, looks perfect. Second one is with iPhone5 aspect ratio, buttons are out of screen space.

   

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 270
  • -Receive: 1132
  • Posts: 21,846
  • Toronto, Canada
    • View Profile
Re: iPhone 5 Height and different aspect ratio
« Reply #5 on: October 08, 2012, 04:16:39 AM »
That looks perfectly normal to me. iPhone 5 is narrower, so the view can't fit both buttons. Design your UI on the iPhone 5, and it will just have some extra space on earlier iPhones, which is better than it being cropped like that.

bitomule

  • Guest
Re: iPhone 5 Height and different aspect ratio
« Reply #6 on: October 08, 2012, 04:31:45 AM »
The question is. Is there any way with NGUI that I can scale down those buttons to fit iPhone5 screen width? Or maybe fake NGUI screen width and height so it scales content like on iPhone 4, not iPhone5.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 32
  • -Receive: 140
  • Posts: 1,761
    • View Profile
Re: iPhone 5 Height and different aspect ratio
« Reply #7 on: October 08, 2012, 06:42:09 AM »
Set manual height of your UIRoot from 480 to 568 for iphone 5 (assuming you have a highres atlas with 0.5 pixel density).

mdeletrain

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 71
    • View Profile
Re: iPhone 5 Height and different aspect ratio
« Reply #8 on: October 10, 2012, 06:49:18 AM »
IMHO, this is related to the fact that NGUI only takes an height as a size reference.
In this particular case the size reference should be the width.
I already depicted the problem on another post, and I think this needs UIRoot not to have two but four scaling options : automatic height, automatic width, manual height, manual width.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 32
  • -Receive: 140
  • Posts: 1,761
    • View Profile
Re: iPhone 5 Height and different aspect ratio
« Reply #9 on: October 10, 2012, 06:58:23 AM »
If you had both height and width to set, it would make pixels non-square. This is generally bad.

mdeletrain

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 71
    • View Profile
Re: iPhone 5 Height and different aspect ratio
« Reply #10 on: October 10, 2012, 08:36:23 AM »
Just as 'automatic' and 'manual height' are mutually exclusive, 'automatic height' 'manual height' 'automatic width' and 'manual width' would be too : there should actually be a combo box with those for scaling modes.
« Last Edit: October 10, 2012, 08:38:30 AM by mdeletrain »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 270
  • -Receive: 1132
  • Posts: 21,846
  • Toronto, Canada
    • View Profile
Re: iPhone 5 Height and different aspect ratio
« Reply #11 on: October 10, 2012, 09:37:04 AM »
As Nicki said, non square pixels = very bad. And it breaks clipping.

mdeletrain

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 71
    • View Profile
Re: iPhone 5 Height and different aspect ratio
« Reply #12 on: October 10, 2012, 12:36:16 PM »
Yes but why are you talking about non square pixels ?
If you scale everything based on screen's width OR height (being it automatically or manually set), the only thing that changes is the reference dimension.
I really don't talk about being able to set both the width and the height reference at the same time.

You'll find screen capture of what I have in mind as attachments.
« Last Edit: October 10, 2012, 12:38:16 PM by mdeletrain »

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 32
  • -Receive: 140
  • Posts: 1,761
    • View Profile
Re: iPhone 5 Height and different aspect ratio
« Reply #13 on: October 10, 2012, 05:37:42 PM »
Ok, this makes sense to me.

I'm not sure it's the best solution, but it's a nice option to have for developers.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 270
  • -Receive: 1132
  • Posts: 21,846
  • Toronto, Canada
    • View Profile
Re: iPhone 5 Height and different aspect ratio
« Reply #14 on: October 11, 2012, 04:41:22 AM »
Remind me to look into it after the 12th