Пример #1
0
        private static void Pack()
        {
            List <PackRes_Def.BundleData> bundleDataList;

            if (packSetting.policy == PackRes_Def.packPolicy_configFile)
            {
                bundleDataList = InitCfgDataList();
            }
            else if (packSetting.policy == PackRes_Def.packPolicy_standalone)
            {
                bundleDataList = InitStandaloneDataList();
            }
            else
            {
                Debug.LogError("PackTexture not support policy: " + packSetting.policy);
                return;
            }

            foreach (PackRes_Def.BundleData data in bundleDataList)
            {
                PackRes_Common.PrintObjectInfo(data);
            }

            Dictionary <string, string> idxMap = new Dictionary <string, string>();

            PackRes_Common.PackBundle(bundleDataList, packSetting.GetPlatformBundleFullPath(platform), platform, idxMap);

            PackRes_Common.ExpIdxFile(packSetting.GetPlatformIdxFileFullPath(platform), idxMap, packSetting.index_file);
        }
Пример #2
0
        private static void Pack()
        {
            string exppath = packSetting.GetPlatformBundleRelativePath(platform);

            PackRes_Common.PrintObjectInfo(packSetting);

            List <string> files = PackRes_Common.GetFileListRecursively(packSetting.res_path, packSetting.fileTypeList);

            foreach (string scene in files)
            {
                Debug.Log(scene);
            }
            Dictionary <string, string> idxMap = new Dictionary <string, string>();

            PackRes_Common.PackScenes(files, exppath, platform, idxMap);

            PackRes_Common.ExpIdxFile(packSetting.GetPlatformIdxFileFullPath(platform), idxMap, packSetting.index_file);
        }
Пример #3
0
        private static void GenerateIndexFile()
        {
            PackRes_Def.PackSetting textureSetting = PackRes_Textures.packSetting;
            PackRes_Def.PackSetting guiSetting     = PackRes_Gui.packSetting;
            PackRes_Def.PackSetting sceneSetting   = PackRes_Scene.packSetting;



            List <PackRes_Def.PackSetting> packSettingList = new List <PackRes_Def.PackSetting>();

            packSettingList.Add(textureSetting);
            packSettingList.Add(guiSetting);
            packSettingList.Add(sceneSetting);

            string platformDir = Path.Combine(Path.GetFullPath(binPath), platform);

            if (Directory.Exists(platformDir))
            {
                Directory.Delete(Path.Combine(Path.GetFullPath(binPath), platform), true);
            }
            Directory.CreateDirectory(Path.Combine(Path.GetFullPath(binPath), platform));

            Dictionary <string, BundleCheckSumData> bundleChecksumDict = new Dictionary <string, BundleCheckSumData>();
            Dictionary <string, string>             idxMap             = new Dictionary <string, string>();

            foreach (PackRes_Def.PackSetting packSetting in packSettingList)
            {
                string idxfile = packSetting.GetPlatformIdxFileFullPath(platform);
                idxfile = Path.Combine(idxfile, packSetting.index_file);

                string srcBundlePath  = packSetting.GetPlatformBundleFullPath(platform);
                string destBundlePath = Path.Combine(Path.GetFullPath(binPath), platform);

                Debug.Log("idxfile: " + idxfile);

                Dictionary <string, string> tempIdx = LoadIdxMapFile(idxfile);
                foreach (KeyValuePair <string, string> pair in tempIdx)
                {
                    if (idxMap.ContainsKey(pair.Key))
                    {
                        Debug.LogError("Dupilate asset : " + pair.Key + "  bundle: " + pair.Value);
                        throw new PackRes_Def.PckException("Dupilate asset : " + pair.Key + "  bundle: " + pair.Value);
                    }
                    else
                    {
                        idxMap.Add(pair.Key, pair.Value);

                        //copy the bundle file to bin path
                        string srcfile  = Path.Combine(srcBundlePath, pair.Value);
                        string destfile = Path.Combine(destBundlePath, pair.Value);
                        if (!File.Exists(srcfile))
                        {
                            Debug.LogError("srcfile not exist: " + srcfile);
                            throw new PackRes_Def.PckException("srcfile not exist: " + srcfile);
                        }
                        if (!File.Exists(destfile))
                        {
                            File.Copy(srcfile, destfile);
                        }

                        //create the bundleMD5Dict
                        if (!bundleChecksumDict.ContainsKey(pair.Value))
                        {
                            BundleCheckSumData checksum = new BundleCheckSumData();
                            checksum.md5  = PackRes_Common.ComputeFileMD5Value(destfile);
                            checksum.size = PackRes_Common.GetFileSize(destfile);
                            bundleChecksumDict.Add(pair.Value, checksum);
                        }
                    }
                }
            }
            string temppath = Path.Combine(binPath, platform);

            PackRes_Common.ExpIdxFile(temppath, idxMap, idxFileName);
            AddIdxFileToChecksum(ref bundleChecksumDict, temppath, idxFileName);
            PackRes_Common.ExpBundleCheckSumFile(temppath, bundleChecksumDict, bundleMd5FileName);
        }