Update: so I changed the default of what is in the Gui.Textfield and now I can sort of type in there, but it doesnt override the default text that I put in there “Enter Name Here”. and it saves my character name as "Enter Name here " ![]()
Hello Unity,
For some reason, I cant type into a GUI.Textfield - I have never had a problem like this before. Would someone mind taking a look and seeing if they can see something I did that would not allow me to type? I have tried running as a standalone build and in the editor, neither let you type into the field.
This is a window that opens and allows you to put in character information for creating a character, then it is supposed to save that into binary(which I havent gotten working either).
//Save Character Window Function
void SaveCharDataWindow(int windowID)
{
PlayerDataClass myChar = new PlayerDataClass();
GUI.Label(new Rect(10,10,150, 25), "Enter Character Name");
myChar.playerName = GUI.TextField(new Rect(5,30, 150, 25), "Enter Name Here");
//Set Default values for the new character
myChar.playerXP = 0;
myChar.playerLevel = 1;
if(GUI.Button(new Rect(offset, 150, 450, 50), "Save"))
{
MyCharacters.Add(myChar);
openCreateCharacterScreen = false;
numberOfCharacters++;
//Save this data to playerprefs file:
var b = new BinaryFormatter();
var m = new MemoryStream();
//save info
b.Serialize(m, MyCharacters);
PlayerPrefs.SetString("MyCharacters",Convert.ToBase64String(m.GetBuffer()));
}
}
Of course you can assign it in the same line, but the important thing is that you have to pass the current name into the TextField function. So this should work as well: myChar.playerName = GUI.TextField(new Rect(5,30, 150, 25), myChar.playerName);
– Bunny83Hmm. Strange that is actually what I was using before - but it wasnt allowing me to type anything into the textbox which was the original issue causing me to post (before I updated it). It might be an issue with my myChar.playerName though? Not sure.
– madmike6537