Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug OnDrawGizmosSelected doesn't work in scene mode, but works in prefab mode

Discussion in 'Editor & General Support' started by Da6i, May 2, 2023.

  1. Da6i

    Da6i

    Joined:
    Apr 21, 2020
    Posts:
    1
    Unity 2022.2.10. I use both OnDrawGizmos and OnDrawGizmosSelected at the same MonoBehaviour object. And earlier (Unity 2019) it worked correctly.

    I wrote an editor script with a toggle button to draw a gizmo from multiple objects of the same type to call OnDrawGizmosSelected when generic parent is selected and call OnDrawGizmos when the toggle is off to see all the gizmos.

    So now I have that situation: In Scene mode (first 4 pics) I Can only see gizmos when I select the main MonoBehaviour object. That is not correct by the documentation. I should also see object gizmos also when I select one of the parents.
    Screenshot_6.png Screenshot_7.png Screenshot_8.png Screenshot_9.png

    But in Prefab Mode I can see Gizmos correctly: OnDrawGizmosSelected is called there, because I toggle my setting on.
    Screenshot_11.png

    In the Game mode situation is the same.
    But if I remove OnDrawGizmos method, everything goes fine again, so it conflicts with OnDrawGizmosSelected?
    Is It 2022 Unity version bug?
     
    jsmglorenzo likes this.