- Home /
Question by
Sir Reepicheep · Jul 26, 2015 at 05:45 PM ·
spriteheightwidth
In Sprite Editor, how can I get theese values by code? (screenshot)
I searched the scripting API but I can't find the sprite's Width and Height variables (which are different from the rect that contains the sprite). Any clues?
sem-titulo.png
(62.8 kB)
Comment
Best Answer
Answer by nisovin · Jul 26, 2015 at 07:17 PM
This will return the rect that contains those values:
var rect = GetComponent<SpriteRenderer>().sprite.rect
It has x, y, width, and height values that correspond with the values in your screenshot.