using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; using UnityEngine.EventSystems;
publicclassUiNavigationTweak : MonoBehaviour { ///<summary> /// Start is called on the frame when a script is enabled just before /// any of the Update methods is called the first time. ///</summary> IEnumerator Start() { while(true) { Refresh(); yieldreturnnewWaitForSeconds(1); } }
///<summary> /// Start is called on the frame when a script is enabled just before /// any of the Update methods is called the first time. ///</summary> publicvoidRefresh() { var selectables = Transform.FindObjectsOfType<Selectable>(); var eventSystem = GameObject.FindObjectOfType<EventSystem>(); Color32 mikuColor = new Color32(0x39, 0xc5, 0xbb, 0xff); int i = 0; // mod all selected color foreach(var selectable in selectables) { var c = selectable.colors; c.selectedColor = mikuColor; selectable.colors = c; i++; } // evs if(i > 0 && eventSystem) { Debug.Log($"[UiNavigationTweak] Modded {i} objects."); if(!eventSystem?.currentSelectedGameObject?.activeInHierarchy ?? true) eventSystem.SetSelectedGameObject(selectables[0].gameObject); } } }