using System.Collections.Generic; using System; using UnityEngine; internal static class YieldInstructionCache { class FloatComparer : IEqualityComparer { bool IEqualityComparer.Equals(float x, float y) { return x == y; } int IEqualityComparer.GetHashCode(float obj) { return obj.GetHashCode(); } } public static readonly WaitForEndOfFrame WaitForEndOfFrame = new WaitForEndOfFrame(); public static readonly WaitForFixedUpdate WaitForFixedUpdate = new WaitForFixedUpdate(); private static readonly Dictionary _timeInterval = new Dictionary(new FloatComparer()); private static readonly Dictionary, WaitUntil> _waitUntil = new Dictionary, WaitUntil>(); // DG public static WaitForSeconds WaitForSeconds(float seconds) { WaitForSeconds wfs; if (!_timeInterval.TryGetValue(seconds, out wfs)) _timeInterval.Add(seconds, wfs = new WaitForSeconds(seconds)); return wfs; } // DG(20.05.08): parameter 없는 람다식 WaitUntil. public static WaitUntil WaitUntil(Func func) { WaitUntil wu; if (!_waitUntil.TryGetValue(func, out wu)) _waitUntil.Add(func, wu = new WaitUntil(func)); return wu; } }