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

OnSceneGUI inside an Editor Window not clear ?

Discussion in 'Scripting' started by fmarianacci, Feb 7, 2020.

  1. fmarianacci

    fmarianacci

    Joined:
    Oct 15, 2018
    Posts:
    20
    Hello guys,

    I got a strange behavior on Unity 2019.3.17f1.

    Inside an EditorWindow inherit class, I subscribe to SceneView.duringSceneGui inside the OnEnable method and unsubscribe inside the OnDestroy method.

    When I use the window, every things look good, but when I'm closing it, all the Handler I draw inside the Window are not clear, and they're still present in the scene, even when I'm closing the scene window and re open it, it's draw.
    And when I click on them the behavior is still present, but the window is gone.

    The OnDestroy method is call, but it look like the windows is still present, but just invisible.

    Anyone can help on that ?

    Thanks,
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,971
    Usually if you hook stuff up in
    OnEnable()
    you want to tear it down in
    OnDisable()
    , not
    OnDestroy()
    . Did you try that?

    The thinking behind this is something could get enabled/disabled many times before it is destroyed, so they are not a good pairing for sub/unsub.

    The problem you see might be related to that, or related to some other editor object lifetime detail.
     
  3. fmarianacci

    fmarianacci

    Joined:
    Oct 15, 2018
    Posts:
    20
    Thanks for your answer.

    I don't really understand when the OnDisable() is call on an EditorWindow.
    I try what you suggest, and OnDisable() or OnDestroy() it didn't change anything, I still have the bug...