Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: echeg on October 03, 2012, 02:11:51 AM

Title: Resize background
Post by: echeg on October 03, 2012, 02:11:51 AM
I have:
UIRoot automatic: off, manual h : 760
background 1140x760px added like sprite and attach UIStretch script

How to scale the image to the pixel size (aspect ratio) did not change?
Example:
Device 2280x760px: bg image scale*2 and cut the Y-axis
Device 1140x380px: bg image scale*2 and cut the X-axis




Title: Re: Resize background
Post by: ArenMook on October 03, 2012, 02:58:40 AM
I'm confused. You ask how to scale the image, and at the same time you mention pixel size, which implies pixel-perfectness. What is it you're trying to do?
Title: Re: Resize background
Post by: echeg on October 03, 2012, 03:44:47 AM
Sorry pixel size is incorrect wording.
I say that if the aspect ratio of the image 11 to 7 after scaling it should stay the same. Just one of the axes will go beyond the scope of the camera.
Title: Re: Resize background
Post by: mdeletrain on October 03, 2012, 04:13:42 AM
I think you're talking about a way to specify the scaling mode, am I right ?
Something similar to iOS's API :
  - stretch : aspect ratio not preserved, fill target
  - fit : aspect ratio preserved, smallest image's dimension scaled so that it fills corresponding target's dimension
  - fill : aspect ratio preserved, largest image's dimension scaled so that it fills corresponding target's dimension
  - center : do not scale, just keep centered
  - top : do not scale, just keep top-centered
  - etc... : same for all 7 others positions

Would be quite useful indeed !
Title: Re: Resize background
Post by: ArenMook on October 03, 2012, 06:56:19 AM
I can probably add that kind of functionality, yeah.

In any case, for the time being though -- you will simply scale your widget manually if you want its aspect ratio to be preserved.
Title: Re: Resize background
Post by: echeg on October 03, 2012, 07:11:03 AM
thx. And then I thought that it was already implemented. and I'm just doing something wrong

Just one question how do I get the size of the sprite?(1140x760px)
Title: Re: Resize background
Post by: ArenMook on October 03, 2012, 07:34:54 AM
relativeSize scaled by transform.localScale.