Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started 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
-
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?
-
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.
-
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 !
-
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.
-
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)
-
relativeSize scaled by transform.localScale.