Editor scripting - a little problem

Hi,

I have a custom Editor (for the inspector), and in this I have a Toggle (checkbox) that switches between two sets of textfields. However, when the cursor is in one of these textfields when I press the checkbox, the cursor will be in one of the new textfields, which is ok, but it also takes over the value of the original textfield, which is not ideal.

Any ideas on how I could solve this?

Thanks!

Could you post the code that you are working with, its a bit hard to visualize without it. :wink:

Well, I can’t paste the entire code, but here’s the part that is causing the problem. Note that it’s using a vector2 field and not a textfield like I said, sorry about that.

layer.useUvSpace = EditorGUILayout.Toggle("Use UV space", layer.useUvSpace);

if(layer.useUvSpace) {
	tileUvSizeTemp = EditorGUILayout.Vector2Field ("Tile Size (UV)", tileUvSizeTemp);
} else {
	tileSizeTemp = EditorGUILayout.Vector2Field ("Tile Size", tileSizeTemp);
}

So what happens is when you press the toggle with one of the fields selected, the other field will show up, and it will contain the value of the original. When you press tab, it reverts to the value it should have.

Finally figured this one out - I can remove the focus from the field by doing GUI.FocusControl(“SomeOtherField”).