1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- 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 Image bIcon;
- public TextMeshProUGUI txt;
- public Sprite targetBG;
- public Sprite targetIcon;
- public Sprite targetBIcon;
- private Sprite curBG;
- private Sprite curIcon;
- private Sprite curBIcon;
- private void Awake()
- {
- curBG = bagButtonBG.sprite;
- curIcon = bagIcon.sprite;
- curBIcon = bIcon.sprite;
- #if UNITY_STANDALONE_WIN
- #elif UNITY_ANDROID
- bIcon.gameObject.SetActive(false);
- #elif UNITY_WEBGL
- #endif
- }
- public void OnPointerEnter(PointerEventData eventData)
- {
- ChangeUI();
- }
- public void OnPointerExit(PointerEventData eventData)
- {
- ResetUI();
- }
- public void ChangeUI()
- {
- bagButtonBG.sprite = targetBG;
- bagIcon.sprite = targetIcon;
- bIcon.sprite = targetBIcon;
- txt.color = Color.black;
- }
- public void ResetUI()
- {
- bagButtonBG.sprite = curBG;
- bagIcon.sprite = curIcon;
- bIcon.sprite = curBIcon;
- txt.color = Color.white;
- }
- }
|