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!
GetComponent<Sprite>().bounds.size.y
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