I’m displaying a small window to let the user enter a name for his new character. The window looks great until the user interacts with the TextField. With every input event (mouse and keyboard), the window momentarily shrinks and then re-expands to its original size.
Here’s how it normally looks:
And this is how it looks when you click or type in the TextField:
It immediately snaps back to the original size, hince the “flicker”. Here’s my code:
windowRect.width = 350;
windowRect.height = 200;
windowRect.x = h - (windowRect.width / 2);
windowRect.y = v - (windowRect.height / 2);
windowRect = GUILayout.Window (0, windowRect, DrawPromptNameDialog, "");
...
void DrawPromptNameDialog (int windowID)
{
GUILayout.Space (50);
GUILayout.Label ("Enter character name:");
characterName = GUILayout.TextField (characterName);
GUILayout.BeginHorizontal ();
{
if (GUILayout.Button ("Continue", "SmallButton", GUILayout.ExpandWidth (true)))
{
// TODO: Validate name
state = State.PromptSkipTutorial;
}
if (GUILayout.Button ("Cancel", "SmallButton", GUILayout.ExpandWidth (true))) {
state = State.Menu;
}
}
GUILayout.EndHorizontal ();
}