Ejemplo n.º 1
0
    /// <summary>
    /// 异步加载
    /// </summary>
    /// <param name="assetPath">资源路径</param>
    /// <param name="assetType">资源类型</param>
    /// <param name="listener">回调</param>
    private void LoadAsync(string assetPath, Type assetType, IResourceListener listener)
    {
        //正在被加载,还没加载完成
        foreach (LoadAssets item in loadingList)
        {
            if (item.AssetPath == assetPath)
            {
                item.AddListener(listener);
                return;
            }
        }
        //等待的队列里面有
        foreach (LoadAssets item in waitingQueue)
        {
            if (item.AssetPath == assetPath)
            {
                item.AddListener(listener);
                return;
            }
        }
        //都没有 先创建
        LoadAssets loadAssets = new LoadAssets();

        loadAssets.AssetPath = assetPath;
        loadAssets.AssetType = assetType;
        loadAssets.AddListener(listener);
        //添加到等待队列
        waitingQueue.Enqueue(loadAssets);
    }