Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unity 5 3 4 OnDrawGizmos does not work in play mode

Discussion in 'Scripting' started by correptus, Jun 27, 2016.

  1. correptus

    correptus

    Joined:
    Apr 14, 2015
    Posts:
    17
    Hi.

    Having a problem with OnDrawGizmos and OnDrawGizmosSelected. Both function work in editor mode, but when I enter play mode they non of them are executed.. It was not allways that way.

    Even simple script like this is not executed while editor in play mode:

    void OnDrawGizmos()
    {
    Debug.Log("OnDrawGizmos");
    }
     
  2. Nitugard

    Nitugard

    Joined:
    May 10, 2015
    Posts:
    341
    Did you try pressing this button:
    58608-gizmos.png
     
    taylor_unity867 likes this.
  3. correptus

    correptus

    Joined:
    Apr 14, 2015
    Posts:
    17
    Yes.
    Both funciton does not work while in play mode, no gizmos in game window no gizmos in scene window, not a single line executed in OnDrawGizmos.

    void OnDrawGizmos()
    {
    Debug.Log("OnDrawGizmos");
    }
    This line is executed while editor not in play mode. and not executed while editor in play mode.


    I see camera gizmo I see collider gizmos, problem is OnDrawGizmos is not executed



    Ok problem solved, it was because gameobject with script had hide in hierarchy flag
     
    Last edited: Jun 27, 2016