AssetBundle LoadSyncCoroutine(string path)
        {
            Debug.Log("path - " + path);

            AssetBundle ab = AssetbundleHelp.LoadFromFile(path);

            if (ab == null)
            {
                Debug.LogError("assetbundle loadFromFile error:");
            }
            path = path.Replace("/", "\\");
            string localpath = AssetBundleInfo.assetPath_local;

            localpath = localpath.Replace("/", "\\");
            string assetbundlename = path.Replace(localpath + "\\", "");

            Debug.Log("assetbundlename:" + assetbundlename + " localpath:" + localpath);
            string[] dependencies = AssetBundleInfo.Manifest.GetAllDependencies(assetbundlename);
            for (int i = 0; i < dependencies.Length; i++)
            {
                Debug.Log("dependencies:" + dependencies[i]);
                //if(!rememberList.Contains(localpath + "\\" + dependencies[i]))
                AssetBundle child = AssetbundleHelp.LoadFromFile(localpath + "\\" + dependencies[i]);
                if (child != null)
                {
                    child.LoadAllAssets();
                }
            }
            return(ab);
        }
        void LoadFromFileDependices(string fullname)
        {
            string      dir      = fullname.Substring(0, fullname.LastIndexOf('/')) + "/";
            string      filename = fullname.Substring(fullname.LastIndexOf('/') + 1);
            AssetBundle ab       = AssetbundleHelp.LoadFromFile(fullname);

            string[] dependencies = AssetBundleInfo.Manifest.GetAllDependencies(filename);
            for (int i = 0; i < dependencies.Length; i++)
            {
                AssetBundle child = AssetbundleHelp.LoadFromFile(dir + dependencies[i]);
                child.LoadAllAssets();
            }
            ab.LoadAllAssets();
        }
Exemple #3
0
 void init(System.Action <bool> whenOver)
 {
     if (checkUpdate())                                           //检查资源是否需要更新
     {
         Debug.Log("更新资源配置信息");
         pullAssetinfoFromSer((AssetVersion newAsset) =>
         {
             Debug.Log("更新资源");
             updateAssets(newAsset, (bool result) =>
             {
                 if (result)
                 {
                     Debug.Log("资源下载完毕");
                     AssetbundleHelp.UnLoadBundles();
                     FileStream file = File.Create(AssetBundleInfo.assetPath_local + "/" + "assetVersionInfo.txt");
                     StreamWriter sw = new StreamWriter(file);
                     sw.Write(newAsset.ToStr());
                     sw.Close();
                     file.Close();
                     if (whenOver != null)
                     {
                         whenOver(true);
                     }
                 }
                 else if (whenOver != null)
                 {
                     whenOver(false);
                 }
             });
         });
     }
     else
     {
         AssetbundleHelp.UnLoadBundles();
         UnityEngine.Debug.Log("没有要更新的资源");
         //      AppFacade.Ins.Log(BugType.log, "没有要更新的资源");
         if (whenOver != null)
         {
             whenOver(true);
         }
     }
 }