- Home /
How can I 'disable' editing with a TextArea?
Hello! This is a Photon Unity Networking question.
I have a thing where I use Photon.player.name to let users type in a username. This is just done with a TextArea and stuff.
I then save the string inside the TextArea using player prefs.
My question is this. How can I make it so that when a user types in there username, they will NOT be able to edit it ever again. They would have to redowoad the game.
Thanks in advance!
Possible duplicate: how to make textArea or a textfield uneditable?
Answer by Eluate · Jan 01, 2015 at 10:52 PM
Change the textarea to a label when the username is saved in the playerprefs and then assign the style to be the style of the textarea. Also, assign the saved playerprefs username to the text of the label.
GUI.Label(Rect(x,y,width,height),VariableName,"TextField");
Ok thanks! Could you show me the basics of the code please? I understand the concept but I can't think of the code.
First you need to disable the textfield after you've saved the data to playerprefs. Then you need to make the label:
x, y, width, height = 100;
username = PlayerPrefs.GetString("Username");
GUI.Label(Rect(x,y,width,height),username,"TextField");
@The_Unity_Game_Developer accept the question please by clicking the green tick.
Your answer
Follow this Question
Related Questions
Show Photon username based on Distance 0 Answers
Backend database and user management 1 Answer
How to make disappear a GUI text after an amount of time? 5 Answers
Text Prompt Problem 1 Answer