Exemplo n.º 1
0
    void Update()
    {
        if (loadingList.Count > 0)
        {
            for (int i = 0; i < loadingList.Count; i++)
            {
                if (loadingList[i].IsDone)
                {
                    LoadAssets loadAssets = loadingList[i];
                    for (int j = 0; j < loadAssets.Listeners.Count; j++)
                    {
                        loadAssets.Listeners[j].OnLoaded(loadAssets.AssetPath, loadAssets.GetAsset);
                    }
                    //添加到已经加载的字典里
                    loadedAssets.Add(loadAssets.AssetPath, loadAssets.GetAsset);
                    //从正在加载列表里移除
                    loadingList.RemoveAt(i);
                }
            }
        }

        while (waitingQueue.Count > 0 && loadingList.Count < 5)
        {
            LoadAssets loadAssets = waitingQueue.Dequeue();
            loadingList.Add(loadAssets);
            loadAssets.LoadAsync();
        }
    }