public static void Copy(string srcPath, string destPath, string searchPattern, IProgress progress = null) { if (!Directory.Exists(srcPath)) { if (progress != null) { progress.SetPercent(1); } return; } string[] files = Directory.GetFiles(srcPath, searchPattern, SearchOption.AllDirectories); for (int i = 0; i < files.Length; i++) { string curFile = files[i]; string relativeFile = curFile.Substring(srcPath.Length); string destFile = destPath + relativeFile; FileOperateUtil.CreateFileDirectory(destFile); File.Copy(curFile, destFile, true); if (progress != null) { progress.SetPercent((float)i / (float)files.Length); } } }
private void BuildPlayer(string path, RuntimePlatform platform) { BuildTarget target = BuildTarget.Android; string buildPath = path; FileOperateUtil.CreateDirectory(path); if (platform == RuntimePlatform.Android) { target = BuildTarget.Android; buildPath = buildPath + "/Release.apk"; } else if (platform == RuntimePlatform.IPhonePlayer) { target = BuildTarget.iOS; buildPath = buildPath + "/Release"; FileOperateUtil.ClearDirectory(buildPath); } List <string> names = new List <string>(); foreach (EditorBuildSettingsScene e in EditorBuildSettings.scenes) { if (e == null) { continue; } if (e.enabled) { names.Add(e.path); } } BuildPipeline.BuildPlayer(names.ToArray(), buildPath, target, BuildOptions.None); }
public static void Compare(string srcPath, string destPath, string toPath, string searchPattern, bool replaceDest, IProgress progress = null) { string[] files = Directory.GetFiles(srcPath, searchPattern, SearchOption.AllDirectories); for (int i = 0; i < files.Length; i++) { string curFile = files[i]; string relativeFile = curFile.Substring(srcPath.Length); string targetFile = destPath + relativeFile; if (!FileOperateUtil.IsFileEqual(curFile, targetFile)) { if (replaceDest) { FileOperateUtil.CreateFileDirectory(targetFile); File.Copy(curFile, targetFile, true); } string toFile = toPath + relativeFile; FileOperateUtil.CreateFileDirectory(toFile); File.Copy(curFile, toFile, true); } if (progress != null) { progress.SetPercent((float)i / (float)files.Length); } } }
private void LoadIslandInfos() { string info = FileOperateUtil.ReadFileInfo("Assets/Configs", "islandInfo.json"); Island[] datas = JsonConvert.DeserializeObject <Island[]>(info); for (int i = 0; i < datas.Length; i++) { Island data = datas[i]; islandInfos.Add(data); } }
public static string GetPlatformPath(string path, RuntimePlatform platform) { if (platform == RuntimePlatform.Android) { return(FileOperateUtil.GetRegPath(path + "/Android")); } else if (platform == RuntimePlatform.IPhonePlayer) { return(FileOperateUtil.GetRegPath(path + "/IOS")); } Debug.LogError("不支持的platform"); return(String.Empty); }
public static void Init() { string text = File.ReadAllText(FileOperateUtil.GetPath("Assets/Project/Art/Editor/EditorConfig.xml")); XmlDocument doc = new XmlDocument(); doc.LoadXml(text); XmlElement root = doc.ChildNodes[0] as XmlElement; InitAssetBundleItem(root.SelectSingleNode("AssetBundle") as XmlElement); InitModelImportItem(root.SelectSingleNode("ModelImport") as XmlElement); InitTextureImportItem(root.SelectSingleNode("TextureImport") as XmlElement); Debug.Log("Reload Completed!!"); }
public override void Execute(object content) { base.Execute(content); publishContent = _content as PublishContent; string resPath = PublishContent.GetResPath(publishContent.GetRootPath()); string resABPath = PublishContent.GetABPath(resPath); string resCachePath = resPath + "Cache"; string resCacheABPath = PublishContent.GetABPath(resCachePath); FileOperateUtil.CreateDirectory(resCachePath); if (!publishContent.bigVersion) { ProgressBarUtil.Title = "AssetBundle文件拷贝和对比"; ProgressBarUtil.Content = "AssetBundle文件拷贝和对比"; ProgressBarUtil.Percent = 0.0f; ProgressBarUtil.Show(); string updatePath = PublishContent.GetResPath(this.publishContent.GetUpdateFilePath()); PublishUtil.Compare(resPath, resCachePath, updatePath, "*.ab", false, new ABProgress()); ProgressBarUtil.Close(); } else { ProgressBarUtil.Title = "AssetBundle文件拷贝"; ProgressBarUtil.Content = "拷贝AssetBundle到缓存目录"; ProgressBarUtil.Percent = 0.0f; ProgressBarUtil.Show(); string projectABPath = PublishContent.GetABPath(Application.streamingAssetsPath); FileOperateUtil.ClearDirectory(projectABPath); FileOperateUtil.ClearDirectory(resCacheABPath); PublishUtil.Copy(resABPath, resCacheABPath, "*.ab", new ABProgress()); ProgressBarUtil.Content = "拷贝AssetBundle到项目目录"; PublishUtil.Copy(resCacheABPath, projectABPath, "*.ab", new ABProgress()); ProgressBarUtil.Close(); } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); Success(publishContent); }
public override void Execute(object content) { base.Execute(content); PublishContent publishContent = _content as PublishContent; string versionFile = publishContent.GetVersionPath() + "/version.xml"; string cacheVersionFile = publishContent.GetRootPath() + "/version.xml"; FileOperateUtil.CreateFileDirectory(versionFile); if (publishContent.bigVersion) { VersionContent versionContent = new VersionContent(); versionContent.version = publishContent.version; versionContent.resUrl = publishContent.resUrl; versionContent.Save(versionFile); string projectVersionFile = FileOperateUtil.GetRegPath(Application.dataPath + "/Resources/version.bytes"); File.Copy(versionFile, projectVersionFile, true); } else { VersionContent versionContent = new VersionContent(); if (File.Exists(cacheVersionFile)) { versionContent.Parse(File.ReadAllText(cacheVersionFile)); } versionContent.version = publishContent.version; versionContent.resUrl = publishContent.resUrl; ResVersion resVersion; resVersion.version = publishContent.resVersion; resVersion.url = publishContent.updateFile; resVersion.md5 = publishContent.updateFileMD5; resVersion.size = publishContent.updateFileSize; versionContent.resVersions.Add(resVersion); versionContent.Save(versionFile); } File.Copy(versionFile, cacheVersionFile, true); Success(publishContent); }
public override void Execute(object content) { base.Execute(content); publishContent = _content as PublishContent; string resPath = PublishContent.GetResPath(publishContent.GetRootPath()); string resABPath = PublishContent.GetABPath(resPath); // bool clearResPath = this.publishContent.env == PublishEnvironment.ONLINE; bool clearResPath = publishContent.bigVersion; //不清理res资源 FileOperateUtil.CreateDirectory(resPath, clearResPath); BuildTarget target = publishContent.GetBuildTarget(); AssetBundleTool.Build(resABPath, target); Success(publishContent); }
public static TextureImportItem GetTextureImportItem(string path) { if (textureImportItems == null) { Init(); } path = FileOperateUtil.GetRegPath(path); for (int i = 0; i < textureImportItems.Length; i++) { TextureImportItem item = textureImportItems[i]; Match match = item.MatchPath(path); if (match.Success) { return(item); } } return(null); }
public static bool TryGetAssetBundleName(string path, out string abName) { if (assetBundleItems == null) { Init(); } path = FileOperateUtil.GetRegPath(path); abName = null; for (int i = 0; i < assetBundleItems.Length; i++) { AssetBundleItem curItem = assetBundleItems[i]; if (curItem.TryGetABName(path, out abName)) { abName = abName.ToLower(); return(true); } } return(false); }
public override void Execute(object content) { base.Execute(content); PublishContent publishContent = this._content as PublishContent; if (!publishContent.bigVersion) { string updateFilePath = publishContent.GetUpdateFilePath(); string updateFile = "/res_" + publishContent.resVersion + ".bin"; string updateFullFile = publishContent.GetVersionPath() + updateFile; FileOperateUtil.CreateFileDirectory(updateFullFile); FolderEncoder folderEncoder = new FolderEncoder(updateFilePath, updateFullFile, "*.*"); long size = folderEncoder.Encode(null); publishContent.updateFile = updateFile; publishContent.updateFileSize = size; } this.Success(publishContent); }
static public void UpdateIslandInfo() { LoadMapInfo(); GameObject[] arr = Resources.LoadAll <GameObject>("Prefabs/IslandItems"); string islandInfo = "["; foreach (GameObject go in arr) { Vector3 length = go.GetComponent <BoxCollider>().size; Vector3 scale = go.transform.lossyScale; Island island = new Island(); island.name = go.name; island.scaleX = scale.x; island.scaleZ = scale.z; island.xlength = length.x * scale.x; island.zlength = length.z * scale.z; island.mapItemRealRow = (int)Mathf.Ceil(island.xlength / mapInfo.cellSize); island.mapItemRealColumn = (int)Mathf.Ceil(island.zlength / mapInfo.cellSize); islandInfo += JsonConvert.SerializeObject(island) + ","; } islandInfo = islandInfo.Substring(0, islandInfo.Length - 1); islandInfo += "]"; FileOperateUtil.CreateFile("Assets/Configs", "islandInfo.json", islandInfo); }
static void LoadMapInfo() { string info = FileOperateUtil.ReadFileInfo("Assets/Configs", "mapInfo.json"); mapInfo = JsonConvert.DeserializeObject <MapInfo>(info); }
public static string GetABPath(string path) { return(FileOperateUtil.GetRegPath(path + "/AssetBundles")); }
public static string GetResPath(string path) { return(FileOperateUtil.GetRegPath(path + "/Res")); }