35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
|
using System;
|
|||
|
using System.Collections;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace BlueWater.Utility
|
|||
|
{
|
|||
|
public static class Utils
|
|||
|
{
|
|||
|
public static IEnumerator CoolDownCoroutine(float waitTime, Action onCooldownComplete = null)
|
|||
|
{
|
|||
|
yield return new WaitForSeconds(waitTime);
|
|||
|
onCooldownComplete?.Invoke();
|
|||
|
}
|
|||
|
|
|||
|
public static void StartUniqueCoroutine(MonoBehaviour owner, ref Coroutine coroutineField, IEnumerator coroutineMethod)
|
|||
|
{
|
|||
|
if (coroutineField != null)
|
|||
|
{
|
|||
|
owner.StopCoroutine(coroutineField);
|
|||
|
coroutineField = null;
|
|||
|
}
|
|||
|
|
|||
|
coroutineField = owner.StartCoroutine(coroutineMethod);
|
|||
|
}
|
|||
|
|
|||
|
public static void EndUniqueCoroutine(MonoBehaviour owner, ref Coroutine coroutineField)
|
|||
|
{
|
|||
|
if (coroutineField != null)
|
|||
|
{
|
|||
|
owner.StopCoroutine(coroutineField);
|
|||
|
coroutineField = null;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|