Reputation: 1886
When I create a new InputField on a screen and give it some default text, the text field returns nothing until I edit it. Looking at the debugger, the text field is actually "".
Once I edit the field at play time, it now equals what I input. But when I come back around to activate that screen again and I want to reset it, setting each of these fields to "" again does not show the original default text, it blanks them out. How do I reset the original text? Where does it live?
Upvotes: 1
Views: 2893
Reputation: 21
Input fields have 2 children attached: Placeholder with a Text component attached which says: Enter text... and a Text with a Text component which says nothing.
If you change the Text in the Text child you will have a default value, but this will show in place of the placeholder text.
It can be done in code if you want the placeholder to be shown when there.
Example:
public InputField inputField; //this is the input field that you are typing into.
public void ButtonPress()
{
//when this button is pressed it will set the value or a default
if(inputField.Text == "")
{
//insert default information
}
else
{
//enter the rest of the function here
}
}
I hope this helps.
Upvotes: 1