using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems; public class InitializeSelectable : MonoBehaviour { [SerializeField] Selectable initialSelected = null; void OnEnable() { StartCoroutine(WaitThenSelectRoutine()); } public IEnumerator WaitThenSelectRoutine() { yield return null; if (Player.Instance.GetInputHandler().UsingGamePad) { try { EventSystem.current.SetSelectedGameObject(null); EventSystem.current.SetSelectedGameObject(initialSelected.gameObject); //Debug.Log($"Currently Selected UI Object: {EventSystem.current.currentSelectedGameObject.name}"); } catch { Debug.LogError("I AM NOT ASSIGNED" + gameObject.name); } } else { EventSystem.current.SetSelectedGameObject(null); } } }