I was trying to make some simple scripts to test stuff out, but for some reason OnDrawGizmos() is never being called. I’ve even created a basic script, that contains nothing but OnDrawGizmos(), and nothing is happening:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GizmoTest : MonoBehaviour
{
void OnDrawGizmos()
{
print("Drawing Gizmos!");
Gizmos.color = Color.white;
Gizmos.DrawSphere(Vector3.zero, 1f);
}
}
If I understand Unity scripting right, this should create a white sphere, one unit in radius, at the zero point of the scene, even when in edit mode. Further, it should print “Drawing Gizmos!” to the console constantly, so I can see it’s functioning. But the script does nothing, in both edit mode AND play mode. No sphere is visible, nothing is output to the console.
Is there some visibility setting for Gizmos, that I’m unaware of? That’s the only explanation I can think of for why this script isn’t working. I even tried upgrading to the latest Unity build (2018.2.15f1 at the time of writing) and the script still does not work.