projectEli/Assets/NeoFPS/Samples/Shared/UserInterface/Spinners/UiSpinner.cs

45 lines
1.0 KiB
C#
Raw Normal View History

2022-11-07 01:28:33 +00:00
using System.Collections;
using UnityEngine;
namespace NeoFPS.Samples
{
public abstract class UiSpinner : MonoBehaviour
{
[SerializeField]
private bool m_StartVisible = true;
public abstract void Tick();
protected abstract IEnumerator ShowCoroutine();
protected abstract IEnumerator HideCoroutine();
protected virtual void Awake()
{
if (!m_StartVisible)
gameObject.SetActive(false);
}
public void Show()
{
StopAllCoroutines();
gameObject.SetActive(true);
StartCoroutine(ShowCoroutine());
}
public void Hide()
{
StopAllCoroutines();
StartCoroutine(HideCoroutineInternal());
}
private void Update()
{
Tick();
}
private IEnumerator HideCoroutineInternal()
{
yield return StartCoroutine(HideCoroutine());
gameObject.SetActive(false);
}
}
}