Custom Editor and OnSceneGUI

My setup

  • Custom Editor derived from UnityEditor::EditorWindow, and has a few buttons.
  • Custom Inspector derived from UnityEditor::Editor, which implements OnSceneGUI() and gives a visual representation of the data being edited.

My requirement

I want to update the sceneView when I click a button in the customEditor; in other words, trigger a call to OnSceneGUI when the button is clicked.

What I have done till now, is received a call in my custom Inspector following the button click. Currently I’ve tried dirtying the object in the scene so that the scene is redrawn. But it doesn’t. I have to hover my mouse over the scene view to trigger the redraw.

The problem (what I think)

The focus is with the customEditor (following button click); hence the OnSceneGUI() is not called on the custom inspector.

Is my analysis of the problem correct? If yes, then bringing focus to the inspector should solve the problem. How do I do it?

I’ve found the problem.

In my code, I was dirtying temporary objects in the scene that had the hideFlags = hideAndDontSave.
On dirtying a object without this flag, the scene started refreshing on the press of the button.