示例#1
0
        IEnumerator TryGetVersion()
        {
            var ManifestPath = string.Format("{0}{1}", AssetBundlePath, VersionFileName);

            using (UnityWebRequest uwr = UnityWebRequest.Get(ManifestPath))
            {
                yield return(uwr.SendWebRequest());

                if (uwr.isNetworkError || uwr.error != null)
                {
                    FrameDebug.LogError(String.Format("File -{0}- Download failed{1}", ManifestPath, uwr.error));
                    yield break;
                }
                m_dataMap.Clear();
                var data  = Encoding.UTF8.GetString(uwr.downloadHandler.data);
                var infos = data.Split('\n');
                foreach (var item in infos)
                {
                    var texts    = item.Split('\t');
                    var itemdata = new ResItemData();

                    itemdata.resName            = texts[0];
                    itemdata.resHash            = texts[1];
                    itemdata.resSize            = int.Parse(texts[2]);
                    m_dataMap[itemdata.resName] = itemdata;
                }
                FrameDebug.Log(string.Format("Finish Download Version"));
                verReadFinished = true;
            }
        }
示例#2
0
 void IClientModule.InitData()
 {
     FrameDebug.Log("Start Init ModuleLua");
     luaScriptsFullPath = Application.dataPath + luaScriptsFolder;
     DoHotFix();
     luaEnv.AddLoader(CustomLoader);
     LoadScript(HotFix);
     LuaFileWatcher.CreateLuaFileWatcher(luaEnv);
 }
 private void LoadAync(int index)
 {
     if (index < jobs.Count)
     {
         ResManager.Instance.AddDownload(jobs[index]);
     }
     else
     {
         FrameDebug.Log("Index out range");
     }
 }
示例#4
0
        static void WriteVersion(BuildTarget target)
        {
            FrameDebug.Log("Start Write Verison");
            var oripath      = GetFullOutPutDir(target);
            var path         = GetAssetBuildPath(target);
            var manifestPath = GetManifestPath(target);
            var temps        = new List <string>(Directory.GetFiles(oripath));

            temps.Remove(path);
            var versionpath = oripath + versionName;

            if (Directory.Exists(versionpath))
            {
                Directory.Delete(versionpath);
            }
            var viersionfile = File.CreateText(versionpath);
            var allfiles     = new List <string>(Directory.GetFiles(oripath));

            allfiles.Remove(versionpath);
            allfiles.Remove(manifestPath);
            allfiles.Remove(manifestPath + ".manifest");
            var allmanifest = AssetBundle.LoadFromFile(manifestPath).LoadAsset <AssetBundleManifest>("AssetBundleManifest").GetAllAssetBundles();

            for (int i = 0; i < allmanifest.Length; i++)
            {
                if (!allmanifest[i].EndsWith(".manifest"))
                {
                    var fullitemPath = oripath + allmanifest[i];
                    var manifest     = AssetBundle.LoadFromFile(fullitemPath);
                    if (manifest != null)
                    {
                        var code = manifest.GetHashCode();
                        allfiles.Remove(fullitemPath);
                        if (i == allmanifest.Length - 1)
                        {
                            viersionfile.Write(string.Format("{0}\t{1}\t{2}", allmanifest[i], AssetBundleUtils.GetMD5(fullitemPath), AssetBundleUtils.GetSize(fullitemPath)));
                        }
                        else
                        {
                            viersionfile.WriteLine(string.Format("{0}\t{1}\t{2}", allmanifest[i], AssetBundleUtils.GetMD5(fullitemPath), AssetBundleUtils.GetSize(fullitemPath)));
                        }
                    }
                }
            }
            viersionfile.Close();
            //删除不属于的ab
            foreach (var item in allfiles)
            {
                File.Delete(item);
            }
            FrameDebug.Log("Finish");
        }
示例#5
0
        private IEnumerator DownLordAssetBundle(ResItem item)
        {
            UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle(item.fullpath);

            www.SendWebRequest();
            item.StartDownLoading();
            while (!www.isDone)
            {
                yield return(1);
            }
            if (www.isNetworkError || www.isHttpError)
            {
                FrameDebug.Log("DownLoad Err: " + www.error);
            }
            else
            {
                var ab = DownloadHandlerAssetBundle.GetContent(www);
            }
        }