Support => NGUI 3 Support => Topic started by: hermitbab on May 28, 2014, 02:36:56 AM
Title: Fixed size of Background picture
Post by: hermitbab on May 28, 2014, 02:36:56 AM
Hi guys,
Thanks for taking your time.
I'm working on a mobile game and want to release it on iPhones. So I have problem with the screen size, I've searched the forum and couldn't find the answer.
I have a picture with 1136*640 and want to show it perfectly as background without scaling on iphone5 but can be cut on both sides when is shown on iphone4. I've tried perfect size on UIRoot, as well as fixed size, but when it shows perfectly on iphone5, it just couldn't cut the sides on iphone4, which means it just shrinks and the picture is scaling. On the other hand, when it cuts the sides on iphone4, it also cuts the sides on iphone5 and scaling the picture. It is strange that in unity game view, it show's perfect and the problem can only occur on real machine, which is painful.
Can any buddy here help? Thanks a lot! I'm using landscape left.
Title: Re: Fixed size of Background picture
Post by: ArenMook on May 28, 2014, 06:35:15 AM
Anchor the widget's top and bottom, leaving left and right not anchored. Give it an aspect ratio of 1.775, and that should be it.
Title: Re: Fixed size of Background picture
Post by: hermitbab on May 28, 2014, 08:43:07 AM
Anchor the widget's top and bottom, leaving left and right not anchored. Give it an aspect ratio of 1.775, and that should be it.
Thank you very much for such quick reply. I use a sprite to show the picture as background and I can see the anchor on the inspector of the sprite. When you say leave left and right not anchored, could you please be more specific that what value I should set to them?
No I'm using the Unified type of the anchor and there are five options for left and right: Target's left, Target's right, Target's center, Custom and set to current position.
Thank you in advance!
Title: Re: Fixed size of Background picture
Post by: hkessock on May 28, 2014, 06:07:33 PM
For something as simple as a background image (I do this for a splashscreen) you can simply create your NGUI UITexture to your default target size (I use the iPad4's resolution of 2048x1536) and scale your NGUI Texture game object with the scale using something like this: