- Home /
The question is answered and the right answer was accepted
How can I get the height of a sprite?
I've found some very complex workarounds for this, but I'm hoping someone's found something simpler than this: http://answers.unity3d.com/questions/641006/is-there-a-way-to-get-a-sprites-current-widthheigh.html
I need to get the height of my sprite so I can place another sprite relative to it. Is there a nice simple way of doing this? I'm aware of renderer.bounds but I can't figure out how to work it. The script reference could do with a few more examples for non-experts like myself.
Thanks very much!
Romano
EDIT: I'm keen not to place it relative to the sprite's transform.position for boring reasons that'd take a while to explain and complicate matters.
Answer by Eric5h5 · Mar 12, 2014 at 10:45 AM
var height = renderer.bounds.size.y;
That's great thank you. I see it in the reference now here : http://docs.unity3d.com/Documentation/ScriptReference/Bounds-size.html
Follow this Question
Related Questions
In Sprite Editor, how can I get theese values by code? (screenshot) 1 Answer
Sprite slicing problem 1 Answer
How to level different sprites to one height 0 Answers
How to scale all sprites, gui buttons, texts, images, 3d objects proportional to the screen height 1 Answer
Weird y scaling issue 0 Answers