'Unity UI Text Selected while the scene loads

I need a way to have a UI Text already selected at the beginning of the scene, so that I can type into it through the keyboard as soon as the game starts. There is a way to do that?



Solution 1:[1]

Use this at start event..

EventSystem.current.SetSelectedGameObject(inputField.gameObject);

Solution 2:[2]

You can use the base class Selectable to refer to your ui element to make this a bit more generic. This works for all UI Components that inherit Selectable, which includes InputField, Button, and others.

public UnityEngine.UI.Selectable uiElement;

void Start()
{
    uiElement.Select();
}

You can also refer to the specific ui element, same method applies.

public UnityEngine.UI.InputField inputField;

void Start()
{
    inputField.Select();
}    

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 KiynL
Solution 2