- Home /
Check Collision In Editor Mode
Hi,
Is there a way to check object collision in Editor mode? Right now I have a custom inspector that instantiates a bunch of cubes, and I want to delete the cubes that collide with previously existing level geometry. Thanks.
Answer by Tuck · Mar 21, 2011 at 11:56 PM
The ExecuteInEditMode didn't work for collision functions, so what I ended up doing was using Physics.OverlapSphere to check for colliders in approximately the area of each cube before I spawned it. This is a bit rough since it uses a sphere instead of a cube, but it works fine for what I need.
It works perfectly for me, put the OverlapBox inside the OnDrawGizmos method, it works like magic, thanks !
Answer by DaveA · Mar 21, 2011 at 05:30 AM
This will probably help: http://unity3d.com/support/documentation/ScriptReference/ExecuteInEditMode.html
I had tried using ExecuteInEditor$$anonymous$$ode previously, but it only seems to make the Update, FixedUpdate, and OnGUI functions be called in Edit mode, not any of the Collision functions.
The solution I'm considering is using Physics.OverlapSphere to approximate the collision area of the cube ins$$anonymous$$d of OnCollisionEnter or OnTriggerEnter.