Author Topic: adjust by DPI option  (Read 12092 times)

briangibson

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 26
    • View Profile
adjust by DPI option
« on: March 30, 2014, 09:42:47 PM »
I just had a chance to test this out- I'm not sure what it's supposed to be doing, but I think it's not doing the right thing. I've been designing my app with minimum/maximum height as 640x1136 (testing on an iphone5), with PixelPerfect mode. I've got things anchored relative to the top/left/sides etc. When I click 'adjust by DPI' and build to an iPad 2 (the non HD iPad), all my ui elements are offscreen. What should I expect to have happen- is this just a bug?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: adjust by DPI option
« Reply #1 on: March 31, 2014, 06:33:08 AM »
Adjust by DPI experimental option will scale your UI Root on top of its ordinary scaling. That is, you'd design your UI in Pixel Perfect mode and on iPad Retina you'd get the screen size that matches the non-retina resolution. It basically takes pixel density into consideration, making your UI be based on screen DPI, not just screen resolution.

Tiktaalik

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 39
    • View Profile
Re: adjust by DPI option
« Reply #2 on: March 31, 2014, 05:08:54 PM »
I'm having trouble following. What is BrianGibson doing wrong and how should he fix it?

I'm not having the exact same problem, but at the moment I'm building a mobile game and I'd like to strive for a system that is resolution independent where scale is modified at runtime based on the device. There's been quite a bit of NGUI changes in the last several months and it's not at all clear to me what is considered to be the right way to go about doing this. Given that Unity is used for mobile a lot, and these sort of questions appear pretty frequently, I think some sort of short "How to setup for cross platform mobile" tutorial/doc with a section on supporting Retina would be super helpful to everyone.

Tiktaalik

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 39
    • View Profile
Re: adjust by DPI option
« Reply #3 on: March 31, 2014, 05:29:25 PM »
Bringing up the code at UIRoot line 93 it looks like adjustByDPI doesn't affect FixedSize at all?

r.pedra

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 20
  • Posts: 131
    • View Profile
Re: adjust by DPI option
« Reply #4 on: April 01, 2014, 03:10:40 AM »
Do you mean that if we design our app for an iPad2 on Pixel Perfect mode with Adjust by DPI activated, if we switch on iPad Retina, everything will be at the right size, like if we were choosing FixedSize ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: adjust by DPI option
« Reply #5 on: April 01, 2014, 08:22:49 AM »
Fixed Size keeps the root the same size regardless. DPI adjustment is for resizing UI, not fixed size.

iPad 2 is 1024x768 with DPI of 132.
iPad Retina is 2048x1536 with DPI of 264.

If you create a pixel-perfect UI without DPI adjustment, then the UIRoot will believe that its resolution is 1024x768 on iPad 2, and 2048x1536 on the iPad Retina.

If you create a pixel-perfect UI with the DPI adjustment turned on, then the UIRoot will believe that its resolution is the same on both. How same? That's determined by NGUIMath.AdjustByDPI function, and is where the "experimental" part comes in. Currently it just uses 96 / DPI setting, which results in 96/132 on the iPad 2, and 96/264 adjustment on the iPad Retina.

So even though the retina device has double the resolution, as far as NGUI is concerned it will have the same screen size as the non-retina device due to the DPI adjustment.

r.pedra

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 20
  • Posts: 131
    • View Profile
Re: adjust by DPI option
« Reply #6 on: April 02, 2014, 03:20:36 AM »
But what will the DPI of textures be?
I believe that it works like the positioning and sizing on native code(I use Admob Plugin and, for example, on iPad Retina, my ads are displaying at the same sizes than on iPad 2 because it's working with Points and not Pixels).
Concretely, what this feature is changing in UI development? Working easier by using only one size of UI?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: adjust by DPI option
« Reply #7 on: April 02, 2014, 04:30:31 PM »
Setting UIRoot to Fixed Size will give you the same exact "points, not pixels" effect without having to muck with DPI at all. DPI setting is for very advanced functionality when you are fine-tuning pixel-perfect atlases with HD/SD/UD versions.

r.pedra

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 20
  • Posts: 131
    • View Profile
Re: adjust by DPI option
« Reply #8 on: April 03, 2014, 03:05:45 AM »
Excuse me, you're going to be pissed, but I still don't understand.
Do you have an example of the difference between Pixel Perfect and Pixel Perfect with DPI Adjust?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: adjust by DPI option
« Reply #9 on: April 03, 2014, 08:47:27 PM »
I already explained it the best I can:
Quote
Fixed Size keeps the root the same size regardless. DPI adjustment is for resizing UI, not fixed size.

iPad 2 is 1024x768 with DPI of 132.
iPad Retina is 2048x1536 with DPI of 264.

If you create a pixel-perfect UI without DPI adjustment, then the UIRoot will believe that its resolution is 1024x768 on iPad 2, and 2048x1536 on the iPad Retina.

If you create a pixel-perfect UI with the DPI adjustment turned on, then the UIRoot will believe that its resolution is the same on both. How same? That's determined by NGUIMath.AdjustByDPI function, and is where the "experimental" part comes in. Currently it just uses 96 / DPI setting, which results in 96/132 on the iPad 2, and 96/264 adjustment on the iPad Retina.

So even though the retina device has double the resolution, as far as NGUI is concerned it will have the same screen size as the non-retina device due to the DPI adjustment.
If you still don't understand... then don't use it. Stick to Fixed Size UIRoot.