Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Textfield in EditorWindow only updates when it loses focus

Discussion in 'Immediate Mode GUI (IMGUI)' started by Aeonvirtual, May 1, 2019.

  1. Aeonvirtual

    Aeonvirtual

    Joined:
    Oct 14, 2015
    Posts:
    33
    I have a textfield that I want to sanitize as the user is typing into it.
    I want to strip out non-letter characters and l want to limit the length.

    I would expect something like this to work but it doesn't:
    Code (CSharp):
    1. string tmp = EditorGUILayout.TextField("ACCESS TOKEN:", accessToken);
    2. tmp = alphaNumeric.Replace(tmp, "");
    3. if (tmp.Length > 6) tmp = tmp.Substring(0, 6);
    4. accessToken = tmp.ToUpper();
    I can still type whatever I want into the textfield and it only updates once the textfield loses focus. Is this a bug?