/// <summary> /// 异步加载 /// </summary> /// <param name="assetName"></param> /// <param name="assetType"></param> /// <param name="listener"></param> private void LoadAsync(string assetName, Type assetType, IResourceListener listener) { //正在被加载 还没加载完成 foreach (LoadAsset item in loadingList) { if (item.AssetName == assetName) { item.AddListener(listener); return; } } //等待的队列里面有 foreach (LoadAsset item in waitingQue) { if (item.AssetName == assetName) { item.AddListener(listener); return; } } //都没有 先创建 LoadAsset asset = new LoadAsset(); asset.AssetName = assetName; asset.AssetType = assetType; asset.AddListener(listener); //添加到等待队列 waitingQue.Enqueue(asset); }
/// <summary> /// 异步加载 /// </summary> /// <param name="assetName">资源名</param> /// <param name="type">资源类型</param> /// <param name="listener">回掉</param> private void LoadAsync(string assetName, Type type, IResourceListener listener) { // 如果正在加载中 添加回掉 foreach (LoadAsset item in m_LoadingList) { if (item.AssetName == assetName) { item.AddListener(listener); return; } } // 如果在等待的队列中 添加回掉 foreach (LoadAsset item in m_WaitingQueue) { if (item.AssetName == assetName) { item.AddListener(listener); return; } } // 都没有 则创建资源 LoadAsset asset = new LoadAsset(); asset.AssetName = assetName; asset.Type = type; asset.AddListener(listener); // 添加到等待队列 m_WaitingQueue.Enqueue(asset); }