34 lines
		
	
	
		
			801 B
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			34 lines
		
	
	
		
			801 B
		
	
	
	
		
			C#
		
	
	
	
|  | using System; | ||
|  | using System.Collections; | ||
|  | using System.Collections.Generic; | ||
|  | using UnityEngine; | ||
|  | 
 | ||
|  | namespace Script.Utils | ||
|  | {  | ||
|  |     public static class TimerUtils  | ||
|  |     { | ||
|  |         private static MonoBehaviour _coroutineRunner; | ||
|  |      | ||
|  |         public static void Initialize(MonoBehaviour runner) | ||
|  |         { | ||
|  |             _coroutineRunner = runner; | ||
|  |         } | ||
|  |          | ||
|  |         public static void DelayExecute(float delay, Action action) | ||
|  |         { | ||
|  |             if (_coroutineRunner != null) | ||
|  |             { | ||
|  |                 _coroutineRunner.StartCoroutine(DelayExecuteCoroutine(delay, action)); | ||
|  |             } | ||
|  |         } | ||
|  |          | ||
|  |         private static IEnumerator DelayExecuteCoroutine(float delay, Action action) | ||
|  |         { | ||
|  |             yield return new WaitForSeconds(delay); | ||
|  |             action?.Invoke(); | ||
|  |         } | ||
|  |     } | ||
|  | 
 | ||
|  | } | ||
|  | 
 |