unity set inputfield text code example

Example 1: unity set text value

//Because the Text variable is public, 
//you will have to drag the Text box object onto the script in unity.
//So unity knows what text box to apply the script to.

public Text myText;
myText.text = "Enter the text value here!";

By: Barry Cox

Example 2: change the text of inputfield unity

using UnityEngine.UI;

public InputField example; //creates an inputfield with the name "example"
public string textToPutToInputField = "If I helped you don't forget to upvote!"; //creates a string to give its value to the inputfield

public void SetTheText() //creates a void that we can call in one of our main void
{
example.text = textToPutToInputField; //gives the value of our string to the text of the inputfield
}

//Now, it's written "If I helped you don't forget to upvote!" on the inputfield