- Home /
Repaint EditorSettings inspector from custom menu item
I want to combine a few settings from Edit > ProjectSettings > Editor in a custom menu item. My code works so far, but if I have the inspector window open, it does not reflect my changes until I close and reopen it.
How do I trigger a repaint on the EditorSettings inspector when I edit its settings from a menu item?
[MenuItem ("Tools/Set Remote")]
static void SetRemote()
{
EditorSettings.unityRemoteDevice = "None";
// Repaint the Edit > ProjectSettings > Editor inspector if open
}
Comment
Answer by IgorAherne · Aug 05, 2020 at 02:21 PM
5 years later, here is how you might do it.
Works for ProjectSettings editor window (but didn't test on EditorSettings):
RepaintEditorWindow("ProjectSettingsWindow");//invoke like this.
static void RepaintEditorWindow(string name){
var buildSettingsType = System.Type.GetType("UnityEditor."+name+",UnityEditor");
var windows = Resources.FindObjectsOfTypeAll(buildSettingsType);
if (windows != null && windows.Length > 0)
{
var window = (EditorWindow)windows[0];
if (window)
window.Repaint();
}
}
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Does every object have to be static when adding tool bars to Unity? 0 Answers
IN-GAME Menu Items 0 Answers
Is MenuItem supported anymore? 2 Answers