2D Toolkit Forum

2D Toolkit => Support => Topic started by: Majicpanda on May 14, 2014, 11:04:47 pm

Title: Polygon colliders disable on parent object disable?
Post by: Majicpanda on May 14, 2014, 11:04:47 pm
I have a scene that I have created polygon colliders on objects for like an anvil etc and when I close the window through the editor or use a script (Door collider sends a gameObject.SetActive(false) to parent) and try to come back into the scene the colliders are not displaying data any longer.  Clicking on the objects in the scene view shows no editor "green" lines for a mesh collider.

Edit: To add to this, what we've done is create a large canvas for our 2d scene and the images are all exported as full canvas transparent space included.  This allows pixel perfect adding of the images to the scene without having to line anything up even with trimming I've noticed.  In the atlas I made polygon colliders and they work great unless you disable and then enable the object again.

I changed the colliders to box trimmed and it works with zero issues, so there's something going on when you make a polygon collider and then disable and re-enable the sprite.
Title: Re: Polygon colliders disable on parent object disable?
Post by: unikronsoftware on May 15, 2014, 10:14:02 pm
The collider is only destroyed in ondestroy, its suspicious if it gets destroyed otherwise. Add some code to track it, eg. disable and immediately check if its gone missing, etc. Polygon colliders are shared between sprites, so if you destroy one that is instantiated from a scene object, it can destroy other instances of it.
Title: Re: Polygon colliders disable on parent object disable?
Post by: Majicpanda on May 16, 2014, 12:35:03 am
will try to do some testing soon.. one thing I noticed is I have 3 polygon colliders in my scene in the same atlas, when I disable and re-enable the parent of all 3 and click on any of them... the mesh green line data displays for the same object every time.