Esempio n. 1
0
        /// <summary>
        /// 加载assetbundle
        /// </summary>
        /// <param name="string">assetBundleName</param>
        /// <param name="bool">async = true 异步加载</param>
        /// <returns></returns>
        static void LoadDependencies(string assetBundleName, string[] deps, bool async)
        {
            string item = null;

            if (deps.Length > 0)
            {
                // Debug.LogFormat("LoadDependencies assetBundleName={0},deps={0},len={1}", assetBundleName, string.Concat(deps), deps.Length);
                CacheManager.AddDependencies(assetBundleName, deps); //记录引用关系
                //开始加载依赖
                for (int i = 0; i < deps.Length; i++)
                {
                    item = deps[i];
                    if (!item.Equals(assetBundleName))
                    {
                        CacheData cacheData = null;
                        CacheManager.CreateOrGetCache(item, out cacheData);
                        cacheData.count++;                 //引用计数加1
                        ABDelayUnloadManager.Remove(item); //从列表移除
                        if (!cacheData.canUse)
                        {
                            LoadAssetBundleInternal(item, async);
                        }
                    }
                }
            }
        }