| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using UnityEngine; |
| | 5 | |
|
| | 6 | | public class WaitForSecondsCache |
| | 7 | | { |
| 1 | 8 | | private static Dictionary<string, WaitForSeconds> waitCache = new Dictionary<string, WaitForSeconds>(); |
| | 9 | |
|
| | 10 | | public static WaitForSeconds Get(float seconds) |
| | 11 | | { |
| 104 | 12 | | string key = seconds.ToString("0.0"); |
| | 13 | |
|
| 104 | 14 | | if (!waitCache.ContainsKey(key)) |
| | 15 | | { |
| 9 | 16 | | float rounded = (float)Math.Round(seconds, 1); |
| 9 | 17 | | waitCache.Add(key, new WaitForSeconds(rounded)); |
| | 18 | | } |
| | 19 | |
|
| 104 | 20 | | return waitCache[key]; |
| | 21 | | } |
| | 22 | | } |