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

39 lines
816 B
C#
Raw Normal View History

2021-12-29 20:50:11 +03:00
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();
}
}