/// <summary>
    /// 检测自己及依赖是否全部加载完成
    /// </summary>
    /// <param name="bundleName"></param>
    /// <returns></returns>
    private static bool RecursiveCheckLoad(string bundleName)
    {
        if (!ReferenceBundle.IsAssetBundleCraete(bundleName))
        {
            return(false);
        }

        List <string> list = BundleDependencies.GetAssetBundleDependencies(bundleName);

        if (list != null)
        {
            foreach (string tBundleName in list)
            {
                if (!ReferenceBundle.IsAssetBundleCraete(tBundleName))
                {
                    return(false);
                }
                else
                {
                    // 当前已加载 再次向下查找
                    RecursiveCheckLoad(tBundleName);
                }
            }
        }

        return(true);
    }
    /// <summary>
    /// 异步加载bundle
    /// </summary>
    /// <param name="bundleName">bundle路径</param>
    /// <param name="onCreateAssetBundle">加载成功后的回调 取消加载后将回调将失效</param>
    /// <returns></returns>
    public static int CreateAssetBundleAsync(int requestId, string bundleName, OnCreateAssetBundle onCreateAssetBundle)
    {
        // 回调不存在不允加载
        if (onCreateAssetBundle == null)
        {
            return(0);
        }

        LoadBundleInfo loadBundleInfo = GetLoadBundleInfo(bundleName);

        if (loadBundleInfo == null)
        {
            loadBundleInfo = GetTempLoadBundleInfo();
            _loadBundleInfoList.Add(bundleName, loadBundleInfo);
            loadBundleInfo.bundleName = bundleName;
            EnterLoadWait(loadBundleInfo);
        }

        requestId = loadBundleInfo.CreateBundleRequest(requestId, onCreateAssetBundle);
        // 未请求
        if (loadBundleInfo.step == LoadBundleStep.LoadWait)
        {
            // 1 获取依赖列表
            List <string> dependencies = BundleDependencies.GetAssetBundleDependencies(bundleName);
            // 2 递归请求加载
            if (dependencies != null && dependencies.Count > 0)
            {
                foreach (string tempBundleName in dependencies)
                {
                    CreateAssetBundleAsync(requestId, tempBundleName, (string tBundleName, AssetBundle tAssetBundle, int tRequestId) => {
                        // 回调返回会增加引用 所以这里直接释放
                        ReferenceBundle.ReleaseBundle(tBundleName);
                    });
                }
            }
            // 3 正加载列表
            List <LoadBundleInfo> loadingBundleInfoList = GetLoadBundleStateList(LoadBundleStep.Loading);
            if (loadingBundleInfoList.Count < _frameLoadMaxCount)
            {
                LoadAssetBundle(loadBundleInfo);
            }
        }

        return(requestId);
    }
    public static void ReleaseBundle(string bundleName)
    {
        BundleReference br = null;

        if (_bundleReferenceList.TryGetValue(bundleName, out br))
        {
            // 释放依赖
            List <string> dependencies = BundleDependencies.GetAssetBundleDependencies(bundleName);
            if (dependencies != null)
            {
                foreach (string dependBundleName in dependencies)
                {
                    ReleaseBundle(dependBundleName);
                }
            }

            br.refCount--;
            LogRefCount(br, -1);
        }
    }
    /// <summary>
    /// 获取一个bundle 每次获取引用计数都会加1
    /// </summary>
    /// <param name="bundleName"></param>
    /// <returns></returns>
    public static AssetBundle GetAssetBundle(string bundleName)
    {
        BundleReference br = GetBundleReference(bundleName);;

        if (br != null)
        {
            br.refCount++;
            LogRefCount(br, 1);

            // 增加依赖
            List <string> denpendencies = BundleDependencies.GetAssetBundleDependencies(bundleName);
            if (denpendencies != null)
            {
                foreach (string denpendBundleName in denpendencies)
                {
                    GetAssetBundle(denpendBundleName);
                }
            }

            return(br.assetBundle);
        }
        return(null);
    }