Hi, i want to draw all the BoxColliders in the Scene while i’m creating it, so i created the script below to draw a box using the Gizmos utility.
using UnityEngine;
[ExecuteInEditMode]
public class ShowCollider : MonoBehaviour
{
// The Collider itself
private BoxCollider _collider;
void Start()
{
_collider = GetComponent<BoxCollider>();
}
void OnDrawGizmos()
{
Gizmos.color = Color.blue;
Gizmos.DrawCube(_collider.center,_collider.size);
}
}
The problem is that i can’t add this script to any object because it is an “editor script”. I’m a bit confused on how should i use an “editor script” because from the documentation it looks like you can add an “editor scripts” to gameobjects, there is a manual entry here where they add an “editor script” to an object to keep it oriented towards a certain direction.
My script is in the ./Asset/Editor folder.
So what am i doing wrong?
My guess is that there is something wrong with the OnDrawGizmos function.