- Home /
NGUI sprite size
Hi, I have a problem with ngui sprite. After I click the button - sprite1 changes to the sprite2. Then I click again and sprite2 changes to sprite3 and so on. It works, but sprite2 comes lower, it's picture size becomes bigger (however, no changes in transform are shown). In fact, I can't even properly say what exactly changes. How can I prevent it? before:
after:
I'm not sure I'm completely onto your problem. But I noticed the two sprites in your images are not the same size. $$anonymous$$by that is your problem?
yes, that's the problem. well, than. before adding those to ngui atlas - sizes of pictures were the same 454x340, also, they had empty space(transparent). but after adding - ngui cut that empty place and size reduced. what can I do?
Answer by Sisso · Apr 07, 2014 at 05:34 PM
Like @Simon Larsen said, both images have different size but you are showing in same size, so it need to be scaled. In atlas object you can manipulate sprite size, border, etc.
For a better GUI you should use texture images in same size in pixel that you will render. Sprites have MakePixelPerfect() method that rescale its object to correct size when you change it.
all images were 454x340 before adding to atlas. after adding to atlas ngui cuts their transparent place as much as possible (before touching solid color). so the first sprite now is 454x155, second - 454x188, third - 454x221. only the last one (the biggest) remained the same - 454x340. I tried to change Height of Outer Rect from 155 to 320 and as the result - it grabs the second sprite
or maybe I don't understand what to do?.. :(
Which NGUI version are you using? Appear to be a very old one.
PS: I receive only now the comment notification from unity3d answer.
yeah, seems to be old. I thought it was the latest, but it appeared to be 1.60 what $$anonymous$$imal version on NGUI do I need to make that thing work properly? (if that is a problem)
Your answer
![](https://koobas.hobune.stream/wayback/20220613140943im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
NGUI resizes fine in engine but not on actual devices 1 Answer
NGUI sprite scale aspect ratio 0 Answers
Help finding the right scale for an icon inside a backgorund sprite 1 Answer
How to align the bottom of a GameObject with the ground? 1 Answer
why the real size of a object doesn't show in the inspector? 0 Answers