Author Topic: NGUI and screen resolution  (Read 42344 times)

elizeusz

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
NGUI and screen resolution
« on: August 17, 2012, 05:02:59 AM »
Hi i am new to NGUI and i want to do start menu in my game. I have done it but now on mobiles ( with different resolustion screen ) it looks not good. What i need to do ? Prepare more than one set of start menu? For example i have backroung which is 1024 by 1024 but my screnn resolution is 480 by 800.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI and screen resolution
« Reply #1 on: August 17, 2012, 09:52:52 AM »
Yes, that's generally how mobile development works. You can either make your UI modular using UIAnchor components, set the UIRoot to be manually sized (and lose pixel perfection), or you can create different layouts. One layout for the iPhone, and another for iPad, for example.

elizeusz

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: NGUI and screen resolution
« Reply #2 on: August 17, 2012, 11:02:31 AM »
Thank You for Your answer. Then only thing which i need to do is to set off automatic option on UIroot script ? After this my backround sprite and buttons will match screen resolution ?

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: NGUI and screen resolution
« Reply #3 on: August 17, 2012, 11:29:46 AM »
In our project, everything is done pixel perfect for the iPad size (1024x768). That means graphists creates everything with the iPad size in mind. A 200x200px image will have a 200x200px size in the game.

We have our UIRoot set to manual (automatic is unchecked), and a manual height of 768.

So if you are running the game on a screen size different than the iPad, it will keep the height and adjust everything with the ratio of the iPad (1.3).

Let's say you're on an iPhone (ratio 1.5), you will have a larger screen, but keep the same height. So your UI will appear exactly at the same positions as one an iPad, except you will have a little bit more space to the left and right of the screen.

elizeusz

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: NGUI and screen resolution
« Reply #4 on: August 17, 2012, 11:52:15 AM »
Ok maybe You can help me more with setup. I have simple menu where i have UIRoot Camera Panel Buttons and Sprite ( sprite is my backround ) can You tell me how i have toset up camera ? my backround image is 1024 by 768 like You said.  I have problem with this setup can i resize my sprite or camera ? Or both ? Sorry if those questions sound naive...

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: NGUI and screen resolution
« Reply #5 on: August 17, 2012, 11:58:41 AM »
No problem !

You don't need to resize anything manually, you just have to set your UIRoot as I told you.
You sprite will take all the screen on your iPad, but if you're on an iPhone, it will be automatically resized to be relative to the height of 768. So if the resolution of the iPhone is 960x640, you will have :
960 -> 640
?? -> 768
?? = 768 * 960 / 640 = 1152

So instead of having your background at the size 1024x768, it should be displayed at 1152x768 (if I'm right...)

So you don't need to resize anything.

But maybe I didn't understand your question :s
« Last Edit: August 28, 2012, 02:40:38 AM by nah0y »

elizeusz

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: NGUI and screen resolution
« Reply #6 on: August 17, 2012, 12:21:09 PM »
Yes this is very good explanation thank You :)

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: NGUI and screen resolution
« Reply #7 on: August 17, 2012, 12:22:32 PM »
Nice ! No problem :)

Divya Talluri

  • Guest
Re: NGUI and screen resolution
« Reply #8 on: November 03, 2012, 08:12:35 AM »
hi guys

I too have same situation now with two types of resolutions 1280x800 and 1024x600..
I have done my backgrounds with the 1280x800 resolution and game will also have same resolution backgrounds.
shall I do the same caluculation procedure used above for my situation? help me guys its urgent.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: NGUI and screen resolution
« Reply #9 on: November 04, 2012, 01:27:07 PM »
What's the size you set on your UIRoot ? With that you can calculate what will be the "virtual" size used by your texture and see if it fits in both 1280x800 and 1024x600.

Divya Talluri

  • Guest
Re: NGUI and screen resolution
« Reply #10 on: November 05, 2012, 12:20:57 AM »
I set the UIRoot Height to automatic(334).my texture height is 1280x800,

1280-800
?-600 = 1280X600/800 = 960.
so I have to set  960x600 to the texture.

Is this the right calculation?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI and screen resolution
« Reply #11 on: November 05, 2012, 04:41:16 AM »
If your UIRoot is automatic, you might want to put a UIStretch on your background texture.

NGUIJeffS

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: NGUI and screen resolution
« Reply #12 on: January 23, 2014, 03:56:00 PM »
Hi, Is this conversation valid for NGUI 3.07? I see no automatic setting for UIRoot. Just PixelPerfect, FixedSize and FixedSizeOnMobile. I tried all of the setting and am currently set to FixedSizeOnMobile and set all heights (Manual,Min and Max) to 480. I had this working a few months ago (pre-update to v3.0.7, I think. I'm sure it's me and not the update), but something has changed so now everything is stretched. I'm running remotely on my Android (320x480) for testing. Searching for info on this site I see discussions on Anchors to resolve aspect ratios issues. Do I need to recreate everything with an anchor of some sort? Any guidance, links, etc is appreciated. Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI and screen resolution
« Reply #13 on: January 24, 2014, 10:21:58 AM »
I don't even rememebr what "automatic" was anymore. I think it was = Pixel Perfect?

Fixed Size on Mobile acts the same as "Fixed Size" when on mobile platforms, and "Pixel perfect" when on desktop / web.

NGUIJeffS

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: NGUI and screen resolution
« Reply #14 on: January 24, 2014, 10:54:10 AM »
Hi Aren,
Thanks for responding. I've got things set to FixedSizeOnMobile, which made sense since I'm working on a mobile game, but when I run it on the mobile device the screen is stretched in the Y-Axis. I've searched the site for info to correct this (aspect ratio, resolution, etc..) and have come up empty (all references refer to the old solution). Any info or reference link(s) you can share so I can size my screen correctly are greatly appreciated. If I find a solution in the mean time I'll post it here. Thanks again.