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

OnSceneGUI() stops working after compilation, resumes after play then stop

Discussion in 'Linux' started by MostHated, Aug 25, 2019.

  1. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    I just setup a small OnSceneGUI() to draw some items out in the scene view but I have noticed that if I make a change and recompile it no longer works. If I hit play and then stop it begins to work again until the next compilation.

    Observed on 2019.2.1f1. I have not tried it on any other version as of yet.
     
  2. senkal_

    senkal_

    Joined:
    May 22, 2018
    Posts:
    86
    Hi @MostHated
    Do you get any errors?
    From what you're saying looks like the code is not even executed, didn't hit this one in 2019.2.1.

    What is your settings for Preferences -> General -> Script Changes While Playing?
    I use Recompile after finished playing, maybe it does something here.
     
  3. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    -- EDIT : I tried to do it using OnDrawGizmos() and OnDrawGizmosSelected(), and both of those do the same thing as OnSceneGui as mentioned below.

    No, there are no errors or anything.

    The setting you asked about is set to "Recompile and Continue Playing". I don't think I have ever changed that setting in any project I have ever made, so I believe that is the default.

    I wanted to test it out with the change, (made it the "Recompile after finishing playing" as you mentioned), closed the editor and reopened. If I select a gameobject that is using the script I am using to draw the debug upon first opening the editor it works fine. It draws a sphere on my waypoint and draws a line to each waypoint it is connected to. I opened Rider and made a script change and then recompiled back in the editor, with the same gameobject still selected, once the recompile finished, drawing of the sphere and the lines disappeared.

    I then went and hit play, then once the game started I stopped it from playing, and then once again the waypoint was drawing the sphere and the lines. This seems to happen every time. If I make any sort of script change and recompile, OnSceneGui() simply stops working, but then as soon as I play/stop, it starts working again (or close and reopen the editor).

    So all that being said, the change you mentioned didn't help, it still does the same thing unfortunately.
     
    Last edited: Aug 28, 2019
  4. senkal_

    senkal_

    Joined:
    May 22, 2018
    Posts:
    86
    Hi @MostHated
    Thank you for your detailed explanation.
    Looks like you invested some time to describe everything.

    Probably the best option would be to create a bug.
    Base on my experience in few days you should get an answer.
    If you use one of the supported OS, like Ubuntu, definitely it should be validated if can be replicated by Unity team.