//预加载一系列资源 public static async ETTask LoadDependency(this GameObjectPoolComponent self, List <string> res) { if (res.Count <= 0) { return; } using (ListComponent <ETTask> TaskScheduler = ListComponent <ETTask> .Create()) { for (int i = 0; i < res.Count; i++) { TaskScheduler.Add(self.PreLoadGameObjectAsync(res[i], 1)); } await ETTaskHelper.WaitAll(TaskScheduler); } }
//异步获取:必要时加载 public static async ETTask <GameObject> GetGameObjectAsync(this GameObjectPoolComponent self, string path, Action <GameObject> callback = null) { if (self.TryGetFromCache(path, out var inst)) { self.InitInst(inst); callback?.Invoke(inst); return(inst); } await self.PreLoadGameObjectAsync(path, 1); if (self.TryGetFromCache(path, out inst)) { self.InitInst(inst); callback?.Invoke(inst); return(inst); } callback?.Invoke(null); return(null); }