- Home /
Sprite texture size and padded size
While debugging a sprite shader I found a curious issue.
If I have a sprite that is not packed, its size gets padded to the next power of 2 size. This is expected.
If I do
mySprite.texture.width
or
mySprite.texture.height
I get the sprite width and height and not the padded texture size. eg a sprite that is 500x400 will give a texture size of 500x400 when the actual texture is 512x512.
Is there a way to get the true size of the texture?
Answer by curiouspers · Mar 02, 2015 at 07:33 PM
not sure what do you mean by padded texture size, but i get right texture sizes with this code:
void Start () {
SpriteRenderer sr = gameObject.GetComponent<SpriteRenderer> ();
Debug.Log (sr.sprite.textureRect);
}
Your answer
Follow this Question
Related Questions
Unity altering my sprites on import? 1 Answer
Difference between Sprite and Default texture types? 0 Answers
sprite animation not playings 0 Answers
Transparency Sort Axis on Y with Pivot instead of Center of object? 1 Answer
If I use Sprite Atlas, will the images that are part of the atlas still be included in build? 1 Answer