1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- using TMPro;
- using UnityEngine.EventSystems;
- using UnityEngine;
- using UnityEngine.UI;
- public class GuideButtonChangeUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
- {
- public Image guideButtonBG;
- public Image guideIcon;
- public Image xIcon;
- public TextMeshProUGUI txt;
- public Sprite targetBG;
- public Sprite targetIcon;
- public Sprite targetXIcon;
- private Sprite curBG;
- private Sprite curIcon;
- private Sprite curXIcon;
- private void Awake()
- {
- curBG = guideButtonBG.sprite;
- curIcon = guideIcon.sprite;
- curXIcon=xIcon.sprite;
- #if UNITY_STANDALONE_WIN
- #elif UNITY_ANDROID
- xIcon.gameObject.SetActive(false);
- #elif UNITY_WEBGL
- #endif
- }
- public void OnPointerEnter(PointerEventData eventData)
- {
- ChangeUI();
- }
- public void OnPointerExit(PointerEventData eventData)
- {
- ResetUI();
- }
- public void ChangeUI()
- {
- guideButtonBG.sprite = targetBG;
- guideIcon.sprite = targetIcon;
- xIcon.sprite = targetXIcon;
- txt.color = Color.black;
- }
- public void ResetUI()
- {
- guideButtonBG.sprite = curBG;
- guideIcon.sprite = curIcon;
- xIcon.sprite = curXIcon;
- txt.color = Color.white;
- }
- }
|