123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- using System;
- using UnityEngine;
- using UnityEngine.EventSystems;
- using UnityEngine.UI;
- public class uGUIButtonSE : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler, IEventSystemHandler
- {
- private void Start()
- {
- if (base.transform.parent)
- {
- CanvasGroup component = base.transform.parent.GetComponent<CanvasGroup>();
- if (component)
- {
- this.m_ParentSelectable = component;
- }
- }
- }
- public void ClickSEPlay()
- {
- if (string.IsNullOrEmpty(this.m_PointerClickSE))
- {
- GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Click);
- }
- else
- {
- GameMain.Instance.SoundMgr.PlaySe(this.m_PointerClickSE, false);
- }
- }
- public void OnPointerEnter(PointerEventData eventData)
- {
- if (!this.m_SelectableComp)
- {
- return;
- }
- if (!this.m_SelectableComp.enabled || !this.m_SelectableComp.interactable)
- {
- return;
- }
- if (this.m_ParentSelectable && !this.m_ParentSelectable.interactable)
- {
- return;
- }
- if (string.IsNullOrEmpty(this.m_PointerEnterSE))
- {
- GameMain.Instance.SoundMgr.PlaySystem(SoundMgr.SeType.Hover);
- }
- else
- {
- GameMain.Instance.SoundMgr.PlaySe(this.m_PointerEnterSE, false);
- }
- }
- public void OnPointerClick(PointerEventData eventData)
- {
- if (this.m_MyButton)
- {
- return;
- }
- if (!this.m_SelectableComp)
- {
- return;
- }
- if (!this.m_SelectableComp.enabled || !this.m_SelectableComp.interactable)
- {
- return;
- }
- this.ClickSEPlay();
- }
- [SerializeField]
- [HideInInspector]
- private Selectable m_SelectableComp;
- [SerializeField]
- [HideInInspector]
- private Button m_MyButton;
- [SerializeField]
- [Header("カーソルが乗ったときに再生するSEファイル名(拡張子含む)")]
- private string m_PointerEnterSE = string.Empty;
- [SerializeField]
- [Header("このUIをクリックしたときに再生するSEファイル名(拡張子含む)")]
- private string m_PointerClickSE = string.Empty;
- private CanvasGroup m_ParentSelectable;
- }
|