Auto Focus

Hey guys. In going and spamming new game a bunch to get more save files for this I noticed that it is very irritating that the text entry field for the new game name does not automatically have focus. I am not sure of a way to do that with just the UI on its own so I made a quick script to throw on the New Game Menu parent object and dragged the InputField into my Serialized field. This worked like a charm:

using TMPro;
using UnityEngine;

namespace RPG.UI
{
    public class TextFocus : MonoBehaviour
    {
        [SerializeField] TMP_InputField inputField;

        private void OnEnable()
        {
            inputField.ActivateInputField();
        }
    }
}
2 Likes

Privacy & Terms