All the tutorials only tell us how to resize it in editor, but in my case, I need to resize it in code. How to do this simply?
The .localscale property should do that nicely for you.
but I do not wanna change localscale. When I change an image’s sprite to another one which size is different, I only wanna to make new sprite turn to it’s current size, and keep it’s position, scale, etc.
call image.SetNativeSize()
or
change rectTransform`s sizeDelta
from script
thanks. I got it.
1 Like