Set default text of an Input Field
Is there a way to add some default text to an input field in Unity? Not as a placeholder but as text in the textbox , without creating a script. There is a Text object as part of the input field however when I enter text into it, it disappears.
Any help would be appreciated, thanks.
Answer by highwoodsdrive · Sep 23, 2017 at 05:21 PM
Hello, Setting the text value in the nested Text object won't work, but you can set the value of the Text field in the Input Field script Text field that's exposed in the editor.
Answer by darklight-15 · Dec 11, 2018 at 06:49 PM
@marty64 that previous answet doesnt work, the value stills erase the value after the app starts, there is no other way to achieve this? i have the same problem
Answer by Mohamed_Farag · Sep 13, 2019 at 09:15 PM
AFAIK, the only way to do this is through script:
create a script and attach it to InputField object and the script will be like this
using UnityEngine;
using UnityEngine.UI;
public class InputFieldScript : MonoBehaviour
{
public InputField inputField;
// Start is called before the first frame update
void Start()
{
inputField = GetComponent<InputField>();
inputField.text = "Default Value";
}
}
another way: could use GameFlow, its a powerful and easy visual scripting tool and free now on the AssetStore https://assetstore.unity.com/packages/tools/visual-scripting/gameflow-14808
add GameFlow component to InputField object click the + button choose On Start -> Set Input Field Property
Your answer

Follow this Question
Related Questions
How to set up a password to be used in the password input field? 1 Answer
Making an image appear 0 Answers
Can`t convert text to upper case from Text of InputField 0 Answers
How can I stop InputField focus/selection from activating device's native keyboard? 1 Answer
Setting string to 'entire' contents of input field? 0 Answers