Hi!
I’m creating a script that draws gizmos for all 2D colliders in my 2D scene.
My question is: how do I draw a gizmo for a 2D circle the same way you see gizmos when
selecting an object?
The only function in Gizmos that I find close to this is “DrawWireSphere()” but it draws a sphere and i can only give it a position and radius and not a rotation.
Here’s what I want (from a 3D perspective):
Here’s what I have right now (from a 3D perspective):
So I simply just want to draw the circle in the xy-plane and have the options to rotate on any axis.
To see the Z-rotation from a 2D-perspective I will just draw lines like a cross over the circle. I can do that now aswell but it will be confusing to see all the sphere circles at the same time.
EDIT:
The circle i want to draw should be for all game objects in the scene and not only targeted game objects.
SOLUTION
As suggested by buckius82 below, a solution for this is to make a monobehavior script that retrieves all CircleCollider2D’s in the scene and then draw wire discs (UnityEdtior.Handles.DrawWireDisc) under the OnDrawGizmos() method.
Example:
private void OnDrawGizmos(){
UnityEditor.Handles.color = Color.yellow;
CircleCollider2D[] colliders = FindObjectsOfType (typeof(CircleCollider2D)) as Collider2D[];
foreach(CircleCollider2D collider in colliders){
UnityEditor.Handles.DrawWireDisc(collider.transform.position ,Vector3.back, collider.radius);
}
}
Note that this may take some performance if there are alot of colliders in the scene.