- Home /
How to find the edge of a sprite in local space.
Hey guys I feel like this is a stupid question but what's a quick way to get the bounds of a sprite in local space?
Answer by Wolfdog · Jun 19, 2015 at 08:03 PM
I just did this when I had to get the bounds:
public float centerToTop; // manual input eg 1
public float centerToSide; // manual input eg 2
// then later on I got
float topBound = transform.position.y + centerToTop;
float bottomBound = transform.position.y - centerToTop;
float rightBound = transform.position.x + centerToSide;
float leftBound = transform.position.x - centerToSide;
// now I used to check if one of the bounds is outside of the screen
EDIT:
Mesh.bounds
might be what you're looking for without manual input. Here is a link: http://docs.unity3d.com/ScriptReference/Mesh-bounds.html
I was kind of hoping to find a solution that doesn't require manual input. I've been stumped all day on this one lol.
I think that $$anonymous$$esh.bounds
might be somewhat useful if you don't want to manually input the values.
Your answer
Follow this Question
Related Questions
Metal texture validation failure 2 Answers
Rendering an animated sprite multiple times 1 Answer
Losing sprite quality when load .png from url 4 Answers
Cut holes in sprite using other sprites 2 Answers
Sprite Editor not slicing correctly 1 Answer