Author Topic: Universal NGUI for iPad&iPhone  (Read 52583 times)

Tim

  • Guest
Re: Universal NGUI for iPad&iPhone
« Reply #15 on: April 20, 2012, 08:52:33 AM »
Nicki, kind of going off what you posted, shouldn't you be able to do something like:

  1. myUIRoot.manualHeight = Mathf.RoundToInt((float)Screen.height * RefAtlases[0].pixelSize);

I build everything in 960x640.  RefAtlas being the SD, HD, or UHD atlas with the pixel size of (in my case) 2, 1, 0.5.  Then shouldn't that manual height work for any aspect ratio or resolution?  I think your equation of (myUIRoot.manualHeight * 16 / 15) will only work for portrait, but i could be wrong...

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Universal NGUI for iPad&iPhone
« Reply #16 on: April 22, 2012, 01:04:44 PM »
Hmm. Lemme just do some napkin math

480 * 16 / 15 = 512 (high res -> 1024)
320 *16 / 15 = 341,33.. (high res -> 682) le fail

Yeah, your math is better, more general.

But really, we should not necessarily cover all resolutions, and in that sense it's smarter to just calculate it before hand and set it directly. (Not that it's especially costly though).

Tim

  • Guest
Re: Universal NGUI for iPad&iPhone
« Reply #17 on: April 22, 2012, 05:44:27 PM »
Ok, just making sure I wasn't missing anything.  I agree there is no need to cover all resolutions, but this same code I can put in my UIController and use in any project, no matter what they are targeting.

Thanks!

BevelGames

  • Guest
Re: Universal NGUI for iPad&iPhone
« Reply #18 on: January 11, 2014, 01:11:49 PM »
You use 3 different atlases.

SD - for ipods, low res iphones
HD - for iphone retina, ipad
UD (ultra def) - for ipad retina.

in the atlas prefab, you set the pixel size to respectively 1, .5f, .25f.

Thank's Nicki. I was kind struggling how to go about it but that bit inspired me to actually get it as follows:
  1. definition |   resolutions   | pixel size
  2. -----------+-----------------+------------
  3.     SD     |   960 x 640 px  |    1.25
  4.     HD     |  1024 x 768 px  |    1.0       <- HD is my default atlas
  5.     UD     |  2048 x 1536 px |    0.5
  6.  

And to be honest it works great not only for Unity but also for my HTML5 experiments.
So far it is the best way to solve different resolutions for all devices (not only Apple devices). I put together little post:  Handling resolutions and aspect ratio of common mobile devices for web, application and game development  for those who need more info on the topic.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Universal NGUI for iPad&iPhone
« Reply #19 on: January 11, 2014, 04:04:32 PM »
I would actually use the same assets for the 960x640 and 1024x768 and call the really low res assets for 480x320 SD and set the pixel size to 2.0.

But then you can also just introduce a 4th atlas CrapD - for very low res devices. ;)