SamsonGame/Assets/Scripts/Game/UI/SkipButton.cs

39 lines
816 B
C#

using System;
using UnityEngine;
using UnityEngine.UI;
public class SkipButton : MonoBehaviour
{
private Button _button;
private Text _text;
private Action _callback;
private void Awake()
{
_button = transform.Find("Button").GetComponent<Button>();
_button.onClick.AddListener(OnButtonClick);
_text = transform.Find("Button/Text").GetComponent<Text>();
}
private void OnButtonClick() => _callback.Invoke();
public void SetHandler(Action handler)
{
_callback = handler;
}
public void ShowView()
{
_button.gameObject.Show();
_text.gameObject.Show();
}
public void HideView()
{
_button.gameObject.Hide();
_text.gameObject.Hide();
}
}