using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; public class SelectIn : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler { public Sprite InUI; public Sprite OutUI; public bool selected = false; public Button[] other; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } public void OnPointerClick(PointerEventData eventData) { if (!selected) { this.GetComponent().sprite = InUI; selected = true; foreach (Button n in other) { n.GetComponent().selected = false; n.GetComponent().refresh(); } } } public void OnPointerEnter(PointerEventData eventData) { } public void OnPointerExit(PointerEventData eventData) { } private void OnDisable() { this.GetComponent().sprite = OutUI; selected = false; } public void refresh() { if (selected) { this.GetComponent().sprite = InUI; } else { this.GetComponent().sprite = OutUI; } } }