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;
}
