EditorGUI refresh

I have this text field on the OnGUI function of an EditorWindow:

trace.print("This should be " + m_mapName);
m_mapName = EditorGUILayout.TextField("Map Name", m_mapName);

But when I change the value of m_mapName externally (by pressing another button, for example), the value doesn’t refresh. For example, if I write something on the textfield, then call a function to set the value to:

m_mapName = "map";

I get

This should be map

But the control displays something. I tried to call Repaint after setting the value, but it doesn’t seem to work.

GUILayout.TextField works as expected. So I’ll try to report this as a bug, and see what feedback I get.

Seems like it’s a bug. It only happens when I have the focus on a textfield, and change the string value of the textfield. It doesn’t refresh unless I set the focus to another textfield. So a quick workaround is:

GUIUtility.keyboardControl = 0;


m_field = EditorGUILayout.TextField("Field Value", m_field);
if (GUILayout.Button("Change Field")) {
	GUIUtility.keyboardControl = 0;
	m_field = "bar";

have you tried EditorUtility.SetDirty ?