123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.EventSystems;
- using UnityEngine.UI;
- using Blue;
- public class ShowHide_Toggle : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IController
- {
- public List<Sprite> SpriteList;
- public Image mImage;
- private Toggle toggle;
- private IQueueSystem mQueueSystem;
- void Awake()
- {
- toggle = GetComponent<Toggle>();
- toggle.onValueChanged.AddListener(ShowHideLevel3);
- mQueueSystem = this.GetService<IQueueSystem>();
- mQueueSystem.Level3QueueCount.Register(mQueueSystemCountNotNull).UnRegisterWhenGameObjectDestroyed(gameObject);
- }
- private void OnEnable()
- {
- Debug.Log($"打开的数量:{mQueueSystem.Level3QueueCount.Value}");
- isShow = toggle.isOn;
- }
- public void OnPointerEnter(PointerEventData eventData)
- {
- if(isShow)
- mImage.sprite = SpriteList[2];
- else
- mImage.sprite = SpriteList[3];
- }
- public void OnPointerExit(PointerEventData eventData)
- {
- if(isShow)
- mImage.sprite = SpriteList[0];
- else
- mImage.sprite = SpriteList[1];
- }
- private void mQueueSystemCountNotNull(int newCount)
- {
- Debug.Log($"打开的数量:{mQueueSystem.Level3QueueCount.Value}");
- }
- private bool isShow;
- private void ShowHideLevel3(bool on)
- {
- Debug.LogError("Level3Queue:" + mQueueSystem.Level3List.Count);
- if (on)
- mImage.sprite = SpriteList[2];
- else
- mImage.sprite = SpriteList[3];
- isShow =on;
- foreach (var go in mQueueSystem.Level3List)
- {
- go.SetActive(on);
- }
- }
- }
|