- Home /
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 $$anonymous$$ouseDown and $$anonymous$$ouseDrag 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 ?
Answer by Bezzy · Mar 07, 2018 at 09:29 PM
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()
Your answer

Follow this Question
Related Questions
Weird bug when dragging object onto EditorGUILayout.ObjectField 0 Answers
Text in custom editor is displayed/rendered with boxes around characters... 2 Answers
custom fogColor editorWindow undo problem 0 Answers
Correct behavior of the mouse wheel when zooming in a 2D area (Unity Editor) 0 Answers
How do I get a reference to the default editor windows (Hierarchy, Console, and Inspector)? 1 Answer