Example #1
0
        public static void _BuildFileVersionList()
        {
#if UNITY_IOS
            string file_name = "FileVersionList_ios.json";
#else
            string file_name = "FileVersionList.json";
#endif

            try
            {
                File.Delete(file_name);
            }
            catch (Exception e)
            {
            }
            var             files = Directory.GetFiles("AssetBundles", "*", System.IO.SearchOption.AllDirectories);
            FileVersionList list  = new FileVersionList();
            foreach (var p in files)
            {
                FileVersion v = new FileVersion();
                v.file = p.Replace("\\", "/");
                v.md5  = MD5Code.GetMD5HashFromFile(p);
                FileInfo info = new FileInfo(v.file);
                v.size = (int)info.Length;
                list.files.Add(v);
            }
            var json = UnityEngine.JsonUtility.ToJson(list);
            File.WriteAllText(file_name, json);
        }
Example #2
0
        public static void _BuildFSFirm()
        {
            try
            {
                Directory.Delete("Assets/StreamingAssets");
            }
            catch (Exception e) { }
            try
            {
                Directory.CreateDirectory("Assets/StreamingAssets");
            }
            catch (Exception e) { }


            var files = Directory.GetFiles("AssetBundles", "*", System.IO.SearchOption.AllDirectories);

            FileVersionList fsfirm_list = new FileVersionList();

            foreach (var pp in files)
            {
                string p = pp.Replace("\\", "/");
                if (Patches.Patcher.ForceCheckMD5(p))
                {
                    FileVersion v = new FileVersion();
                    v.file = p;
                    v.size = (int)(new FileInfo(p)).Length;
                    v.md5  = MD5Code.GetMD5HashFromFile(p);

                    fsfirm_list.files.Add(v);

                    //engine 文件不需要打进去
                    if (p.Contains("/engine/"))
                    {
                        continue;
                    }

                    string target = "Assets/StreamingAssets/" + p;
                    int    found  = target.LastIndexOf("/");
                    if (found != target.Length)
                    {
                        if (!Directory.Exists(target.Substring(0, found)))
                        {
                            Directory.CreateDirectory(target.Substring(0, found));
                        }
                    }
                    File.Copy(p, target, true);
                }
            }
            try
            {
                File.Delete(DevConfig.FSFirmVersionListFileName);
            }
            catch (Exception e) { }

            File.WriteAllText("Assets/Resources/" + DevConfig.FSFirmVersionListFileName, JsonUtility.ToJson(fsfirm_list));

            AssetDatabase.Refresh();
        }