1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System.Collections;
- using System.Collections.Generic;
- using TMPro;
- using UnityEngine;
- using UnityEngine.EventSystems;
- using UnityEngine.UI;
- public class BagButtonChangeUI : MonoBehaviour,IPointerEnterHandler,IPointerExitHandler
- {
- public Image bagButtonBG;
- public Image bagIcon;
- public TextMeshProUGUI txt;
- public Sprite targetBG;
- public Sprite targetIcon;
- private Sprite curBG;
- private Sprite curIcon;
- private void Awake()
- {
- curBG = bagButtonBG.sprite;
- curIcon = bagIcon.sprite;
- }
- public void OnPointerEnter(PointerEventData eventData)
- {
- ChangeUI();
- }
- public void OnPointerExit(PointerEventData eventData)
- {
- ResetUI();
- }
- public void ChangeUI()
- {
- bagButtonBG.sprite = targetBG;
- bagIcon.sprite = targetIcon;
- txt.color = Color.black;
- }
- public void ResetUI()
- {
- bagButtonBG.sprite = curBG;
- bagIcon.sprite = curIcon;
- txt.color = Color.white;
- }
- }
|