/// <summary> /// 计算当前需要下载的资源 /// </summary> /// <param name="state"></param> private void ResetLoadingState() { //停止正在下载的资源 itemLoadCtrl.CansaleLoadAllLoadingObjs(); needDownLand.Clear(); var loadedKeys = new string[loadedDic.Count]; loadedDic.Keys.CopyTo(loadedKeys, 0); ///删除新状态下不再需要的对象 foreach (var item in loadedKeys) { var info = CurrentItems.Find(x => x.ID == item); if (info == null) { if (loadedDic[item] != null) { if (catchStates.Contains(lastState)) { delyHideObjects.Add(loadedDic[item]); if (log) Debug.Log("隐藏1:" + item); } else { delyDestroyObjects.Add(loadedDic[item]); loadedDic.Remove(item); if (log) Debug.Log("销毁1:" + item); } } } else { loadedDic[item].gameObject.SetActive(true); if (log) Debug.Log("保留:" + item); } } ///记录需要加载的资源 for (int i = 0; i < CurrentItems.Count; i++) { var info = CurrentItems[i]; if (!loadedDic.ContainsKey(info.ID)) { needDownLand.Enqueue(info); } } }