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: Code (CSharp): 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.
For some reason when I had that issue, adding a Start() method did the trick. You'll see the difference when you get the Checkbox to disable the script. Strange, but that's how Unity seems to roll. -ch
Okay, so I have been looking at some other elements of my project, and I believe I've found the problem. I was looking through the Scene View Gizmos drop-down, and couldn't find a "toggle all" button. But I did see the option for the Camera Gizmo, among others, and remembered that Unity's base components use lots of of Gizmos themselves. I noticed then that neither the Camera nor the Directional Light in my scene were displaying any Gizmos, nor did they have any visible icons to show their positions in 3D space. Which, okay, if OnDrawGizmos() isn't being called for my scripts, why would it be any different for Unity's default components? But what seemed strange to me, was that earlier today I was fiddling with a different project I created some time (and several Unity updates) ago, and all the Gizmos in that project were working fine. I even copied over my GizmoTest script and it worked fine in that older project. It worked even after I loaded the older project into the newest Unity version. So... I just created a new project in the latest Unity version (2018.2.16f1 at the time of writing) and now all my Gizmos work perfectly. I guess there was some kind of bug with creating new projects in one of the previous versions of Unity? Unfortunately, I'm not sure which version that was, other than it being earlier than 2018.2.15f1. It seems to be fixed now, in any case. Thank you all for your help, regardless.
Ok, I recently had the exact same problem and the solution for was folding out the script in the inspector with that little arrow next to component icon. It's the same case as with colliders, when they are folded, gizmos are not drawn
Common Mistakes Make sure the Component of the script is expanded in Inspector Enable Gizmos at the Scene View Window Check if Gizmo for particular Component is enabled (expand Gizmos-Button at Scene View Window) Scene-deactivated Layers (Top Right enum "Layers") will override everything so no gizmos are seen in Sceneview even when 1 - 3 are done. Tick the corresponding closed eye to be able to see the gamobjects and their containing Gizmos again.
Reset the transform component. As example when you say to draw a Sphere at position 0, 1 then it doesn't matter if you move your plane or object to another place it still draws the spheres at the world position 0,1
gizmos won't take in a color set in the inspector using public Color, you have to set the gizmos color before its draw with Gizmos.color = Color.red or whatever color, this was my issue
Mine too, but the real problem is, by default, alpha is zero in inspector-set colors. You have to make sure alpha is a full 100% or the gizmos are invisible!
My solution was to pass float value in method Gizmos.DrawWireSphere(transform.position, 5f); I was passing an int variable instead of float
I worked through all of those only to find out I had forgotten an "s" in the functions name: OnDrawGizmo should be OnDrawGizmos
Make sure you have the game object with the script for drawing the gizmos selected. That's what worked for me.
I was having exactly the same problem has him. The little checkbox for the script on the inspector window, didnt appear to me either. My problem was that the alpha of the color i was using was 0, so the gizmo was trasparent.
This was it for me too! One easy solution is to set the default Color in code: [SerializeField] private Color m_color = Color.blue; This automatically sets an Alpha of 1
After hours of debuging and searching with nothing happen while the function is correctly called, and the color properly set. That was it. The alpha value of the color ....
Neither of my functions (OnDrawGizmos, OnDrawGizmosSelected) were being called and I did everything. Turns out the layout of my Unity editor got "stale", and there's no real way to check other than go back to the Default (or your own Layout in the top-right of Unity), and make your windows nice as you want them again. After resetting my layout, it worked and started getting called. Go figure.
Hi, just giving my 2 cents here in case someone else have the same problem as me: make sure the object is also visible by disabling the eye icon in the hierarchy. If the object is invisble, the Gizmos methods won't be called either, even if the object itself is enabled!