OnMouseOver Polygon Collider2D "Layer order"?
i have several objects on a table, each object has a PolygonCollider2D and a script, with the following:
void OnMouseOver ()
{
SpriteRenderer[] spriterenderers;
spriterenderers = GetComponentsInChildren<SpriteRenderer>();
foreach (SpriteRenderer x in spriterenderers)
x.color = Color.blue;
}
void OnMouseExit ()
{
SpriteRenderer[] spriterenderers;
spriterenderers = GetComponentsInChildren<SpriteRenderer>();
foreach (SpriteRenderer x in spriterenderers)
x.color = Color.white;
}
some objects receive the OnMouseOver events but some do not. the ipad for example dose not receive the OnMouseover, but instead the table gets it. the computer however does not have this problem. the telephone has this problem too but does get OnMouseOver events in the part that is not overlapping with the table.
i have tried adjusting the order in layer in the respective sprite renderers but it makes no difference.
how can i control the "layer" order of objects in this case?
i'm using unity5.6 on macos Sierra
Answer by ewanuno · May 11, 2017 at 04:17 PM
resolved, polygon colliders with holes in them don't stack properly. this may be a bug in polygon2d but i'm not sure what the expected behavior is.
Your answer
Follow this Question
Related Questions
No errors console but Physics2D.IgnoreCollision does not work 0 Answers
Physics.IgnoreCollision between rigidebody2d+polygone collider 2d and edge collider 2d doesn't work? 1 Answer
How do I make Polygon Collider 2D more smooth? 0 Answers
What can I do to fix it? (Polygon Collisor shape equals shape sprite) 0 Answers
C# script of Obstruction 0 Answers