Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: elizeusz on August 17, 2012, 05:02:59 AM

Title: NGUI and screen resolution
Post by: elizeusz 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.
Title: Re: NGUI and screen resolution
Post by: ArenMook 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.
Title: Re: NGUI and screen resolution
Post by: elizeusz 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 ?
Title: Re: NGUI and screen resolution
Post by: nah0y 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.
Title: Re: NGUI and screen resolution
Post by: elizeusz 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...
Title: Re: NGUI and screen resolution
Post by: nah0y 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
Title: Re: NGUI and screen resolution
Post by: elizeusz on August 17, 2012, 12:21:09 PM
Yes this is very good explanation thank You :)
Title: Re: NGUI and screen resolution
Post by: nah0y on August 17, 2012, 12:22:32 PM
Nice ! No problem :)
Title: Re: NGUI and screen resolution
Post by: Divya Talluri 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.
Title: Re: NGUI and screen resolution
Post by: nah0y 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.
Title: Re: NGUI and screen resolution
Post by: Divya Talluri 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?
Title: Re: NGUI and screen resolution
Post by: ArenMook on November 05, 2012, 04:41:16 AM
If your UIRoot is automatic, you might want to put a UIStretch on your background texture.
Title: Re: NGUI and screen resolution
Post by: NGUIJeffS 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.
Title: Re: NGUI and screen resolution
Post by: ArenMook 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.
Title: Re: NGUI and screen resolution
Post by: NGUIJeffS 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.
Title: Re: NGUI and screen resolution
Post by: ArenMook on January 25, 2014, 02:36:35 AM
If you want consistency, set it to just "fixed size". But fixed size means that the size of the UI will stay proportional with the screen height, so if your widget takes 25% of the screen's height vertically, then it will still be 25% of the screen's height when the resolution goes up or down.
Title: Re: NGUI and screen resolution
Post by: NGUIJeffS on January 25, 2014, 10:03:38 AM
What I'm hearing you say is that if I use "fixed size" then the UI will not stretch to match to size the device screen height. Given this then the UI should match any device regardless of that devices screen size. Correct?
I think my problem is the aspect ration setting in Unity. When I use 320x480 portrait, which is the device screen size, the UI gets stretched in the Y-Axis, but when I use 600x1024 the UI is not stretched as much (it's almost the correct size.). I thought that screen resolution and aspect ratio where one and the same, but I guess they are not. Correct?

I'll try publishing with the 600x1024 portrait setting and see what happens.

Thanks for your help.
Title: Re: NGUI and screen resolution
Post by: Nicki on January 25, 2014, 10:17:30 AM
NGUI bases itself on the height of the device - that means if you use fixed size and it's set to use 50 % of the height, it will use 50 % of the height always.

Width is not automatically handled, so when the aspect ratio of the screen changed Say from ipad to iphone 5, it will still stay where you had originally placed it unless you do thing like anchor to the sides  - then the position will be determined by the anchor, while the size is still affected by the reported height.