projectEli/Assets/NeoFPS/Samples/Shared/UserInterface/Spinners/UiSpinner.cs
2022-11-06 20:28:33 -05:00

45 lines
1.0 KiB
C#

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