- Home /
Getting height of a sprite
Hello all , I am trying to get the height of a sprite so I can use it in my pooling script . Usually we do :
platformHeight = platform.GetComponent<BoxCollider2D>().size.y * platform.GetComponent<Transform>().localScale.y ;
However , this time I am pooling something else (something related to scenery) and it does not have a collider on it how do I get the same size given by above line of code when there is no collider applied? also note that the object was resized (scaled in the x and y).
Thanks for all in advance!
Answer by Larry-Dietz · Dec 21, 2017 at 06:46 PM
The sprite object has a bounds property with a size component. That might get you what you are wanting. I haven't tested this, but it looks promising.
mySprite.bounds.size
should give you a Vector3
hope this helps, -Larry
LOL @$$anonymous$$onomira beat me by a few seconds :)
Decided to stop just looking, and start helping where I can :)
Your answer
![](https://koobas.hobune.stream/wayback/20220612145007im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
failing to access height of a capsuller collider 1 Answer
Terrain collider slow framerate at height 0 Answers
Change unity's first person controller collider size 2 Answers
Internal collisions 1 Answer
Determine Distance to Top of Collider? 2 Answers