- Home /
How to get the bounds of an actual sprite, not it's bounding box.
Hello everyone! This question may sound a little confusing at first, but let me explain...
I need to find the bounds of a sprite, not the bounds of its bounding box. While spriterenderer.bounds.min
and spriterenderer.bounds.max
work just fine for sprites that are not rotated, the values become skewed if the sprites are rotated, since the bounding box stretches to encapsulate the entire sprite.
I'll use a line renderer set to the sprite bounds dragged from left-to-right to demonstrate:
Notice how the line renderer does not follow the sprite, it follows the bounding box instead. I need the actual bounds of the sprite itself, not the bounds of the bounding box. Confusing question, I know, but I'd love to see if you guys have any solutions.
The line renderer should have ended up pointing here: http://i.imgur.com/3DedtUv.png
Here is a video of the line renderer progressing over the sprite. Notice how the line follows the top of the bounding box, and not the top of the sprite.
This is quite a tricky question to Google for! Thank you.
Your answer
Follow this Question
Related Questions
Displaying Prefab Sprite as Texture on GUI Elements 0 Answers
hide animated Sprite by code (SpriteRenderer) 2 Answers
[2D] [C#] Sprite disappears after changing position 1 Answer
How to choose a size/resolution for the sprites used as game assets in Unity2D ? 2 Answers
Outline set of tiled sprites 0 Answers