public static void GenAssetsMD5() { XmlDocument xmldoc = new XmlDocument(); XmlDeclaration xmldecl = xmldoc.CreateXmlDeclaration("1.0", "UTF-8", "yes"); xmldoc.AppendChild(xmldecl); //加入一个根元素 XmlElement xmlRootElem = xmldoc.CreateElement("", "AssetsMD5", ""); xmldoc.AppendChild(xmlRootElem); List <string> fileList = PackUtils.GetFilesFormFolder("/StreamingAssets/", "*.*", true); for (int i = 0; i < fileList.Count; i++) { string filePath = fileList[i].Replace("Assets/StreamingAssets/", ""); string fileMD5 = ResUtils.GetFileMD5(Application.dataPath + "/StreamingAssets/" + filePath); XmlNode root = xmldoc.SelectSingleNode("AssetsMD5"); XmlElement xe1 = xmldoc.CreateElement("File"); xe1.SetAttribute("path", filePath); xe1.SetAttribute("md5", fileMD5); root.AppendChild(xe1); } //保存创建好的XML文档 string xmlFilePath = Application.dataPath + "/Resources/AssetsMD5.xml"; xmldoc.Save(xmlFilePath); }
public static void PackAllScenes() { List <string> fileList = PackUtils.GetFilesFormFolder("/Package/Scenes/", "*.unity", false); for (int i = 0; i < fileList.Count; i++) { string bundleName = PackUtils.GetFileNameFormPath(fileList[i]); //PackUtils.PackScene(fileList[i], "Scenes/" + bundleName); } }
public static void CompressTexture() { string[] compressFolderArray = { "/Resources/Textrue/", "/Package/UI/", }; for (int i = 0; i < compressFolderArray.Length; i++) { List <string> fileList = PackUtils.GetFilesFormFolder(compressFolderArray[i], "*.tga|*.psd|*.bmp|*.png|*.jpg", true); #if UNITY_ANDROID PackUtils.CompressTexture(fileList.ToArray(), TextureImporterFormat.DXT5); #elif UNITY_IPHONE PackUtils.CompressTexture(fileList.ToArray(), TextureImporterFormat.PVRTC_RGBA4); #endif } }
public void InitPackage() { string packagePath = Application.dataPath + "/Editor/WLPlugIns/package.xml"; XmlDocument packageDoc = new XmlDocument(); packageDoc.Load(packagePath); //add package data, #if UNITY_ANDROID XmlNodeList androidPacakages = packageDoc.SelectNodes("/PackageList/PackageAndroidList/package"); #elif UNITY_IPHONE XmlNodeList androidPacakages = packageDoc.SelectNodes("/PackageList/PackageIOSList/package"); #else XmlNodeList androidPacakages = packageDoc.SelectNodes("/PackageList/PackageAndroidList/package"); #endif foreach (XmlNode node in androidPacakages) { string tag = node.Attributes["tag"].Value; string strId = node.Attributes["id"].Value; string desc = node.Attributes["desc"].Value; string appname = node.Attributes["app"].Value; string identifier = node.Attributes["identifier"].Value; string pushkey = node.Attributes["pushkey"].Value; int id = int.Parse(strId); _allPackageTags.Add(tag); _allPackageDataIds.Add(id); _allPackageDataDesces.Add(desc); _allPackageDataAppNames.Add(appname); _allPackageDataIdentifiers.Add(identifier); _allPackageDataPushKeys.Add(pushkey); } //init all scenes data List <string> fileList = PackUtils.GetFilesFormFolder("/Package/Scenes/", "*.unity", false); _allPackageScenes = fileList; foreach (string scene in _allPackageScenes) { _allPackageSceneDesces.Add(scene.Substring(scene.LastIndexOf("/") + 1, scene.IndexOf(".unity") - scene.LastIndexOf("/") - 1)); } }