Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Resolved OnInspectorGUI doesn't directly apply changes to scene ?

Discussion in 'Scripting' started by DJ_Math, Mar 31, 2023.

  1. DJ_Math

    DJ_Math

    Joined:
    May 7, 2021
    Posts:
    7
    So OnInspectorGUI doesn't seem to directly apply changes to scene
    Unity-OnInspectorGUI.gif
    The thing that i can't understand is : when i move the mouse to the scene, changes are visible on scene.
    Should I use OnSceneGUI ?
    It's not a problem at all, but it can be a little bit confusing for users who doesn't know how changes are not directly applied to scene (they would say "at random time").

    MultiLanguageTextEditor screen.png

    Same situation happens on MultiLanguageManager :
    MultiLanguageManager.gif
    Capture d'écran 2023-03-31 124101.png
     
  2. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    4,130
    Well, you do realise that the Unity editor does not redraw itself all the time, only when it is told to. You are active in the inspector, so all user input is directed to and processed by the inspector window. The changes are applied immediately. However the SceneView hasn't redrawn yet. When you make changes in the inspector which should be reflected in the SceneView(s), you should call SceneView.RepaintAll in your EndChangeCheck.

    An EditorWindow is automatically redrawn when the tooltip event happens. That is when you move over the window and stop for a certain amount of time (about half a second I think). That's what you see in your case.
     
  3. DJ_Math

    DJ_Math

    Joined:
    May 7, 2021
    Posts:
    7
    Wow it worked, thanks !
    I didn't know at all the existence of SceneView.RepaintAll ;-;
    Can it be the same with OnSceneGUI ? Scene will redraw but Inspector will not ? (Just curious)
     
  4. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    4,130
    Yes, of course :) Inside of a custom Editor you can simply call "Repaint" of your Editor to make it update when necessary.
     
  5. DJ_Math

    DJ_Math

    Joined:
    May 7, 2021
    Posts:
    7
    Okay, thank you for the help and infos ! ;)