Manual repainting not working in a custom editor

Hi!,

After reading some answers about forcing repainting in a unity3d editor and realizing they do not work for me I have written a little example:

[CustomEditor(typeof(LocalizationData))]
class LocalizationDataEditor : Editor 
{
    LocalizationData data = null;

    void Awake()
    {
        data = target as LocalizationData;
    }


    public override void OnInspectorGUI ()
    {
        if (Event.current.type == EventType.Repaint)
            Debug.Log("Repaint.....");

        if (GUILayout.Button("-", new GUILayoutOption[] { GUILayout.Width(30) }))
        {
            //GUI.changed = true;
            //EditorUtility.SetDirty(target);
            Repaint();
        }
    }
}

This should be firing a repaint event everytime I press the button but it is not firing. If I click out of the editor and then move mose over the editor I see how it is firing, so, I suppose the code should work.

I have spent part of the day trying to figure out why this is happening without any success. If anyone could help here I would really apreciate it.

Thanks in advance.

Is 'collapse' active in your console? The Button probably already sends a repaint request both when it releases and when it is pressed; the Button's request and your request may be merged into a single repaint request (but I'm not sure how it all works under the hood). Can't be much more help than that; I've used Repaint myself in MouseDown and MouseDrag events and haven't had any issue with it not triggering. :(

Excuse for the dumb question, but what you mean by "is collapse active in your console?". On the other hand I have been logging all events arriving to the OnInspectorGUI and when a click on the button is performed it won't do an authomatic repaint either :/. Thanks in advance.

Hi everyone, I'm bumping this issue up, I'm encountering the same issue : I have a custom inspector on a Scriptable Object, and calling either SetDirty / Repaint doesn't update my inspector. Anyone has a clue ?

1 Answer

1

Anyone ever try

EditorGUI.BeginChangeCheck();
//Your miserable UI code here
if(EditorGUI.BeginChangeCheck())
{
    Repaint();
}

it doesn’t catch every case (like when i change the size of a resizeable array) but, it does catch quite a lot of changes to serialized properties.

I think your second BeginChangeCheck() should be EndChangeCheck()