public void OpenXcodeSettingTxtPath() { if (FileHelper.JudgeFilePathExit(XcodeSettingTxtPath)) { EditorUtility.RevealInFinder(XcodeSettingTxtPath); } }
public static void UpdateABClass() { string ABConfigPath = AssetDatabasex.GetAssetPathStr("AF_ABConfig"); AF_ABConfig abConfig = null; if (!ABConfigPath.IsNotNullAndEmpty()) { abConfig = new AF_ABConfig(); ABConfigPath = "Assets/Scripts/AFData/AF-ConfigPath/AF_ABConfig.asset"; } else { abConfig = AssetDatabase.LoadAssetAtPath <AF_ABConfig>(ABConfigPath); } foreach (ARForProductType aBClass in System.Enum.GetValues(typeof(ARForProductType))) { if (abConfig != null && abConfig.JudgeClassExit(aBClass)) { continue; } AF_ABOneClass aF_ABOneClass = new AF_ABOneClass(); aF_ABOneClass.ABClassType = aBClass.ToString(); abConfig.m_AllClass.Add(aF_ABOneClass); } if (!FileHelper.JudgeFilePathExit(System.Environment.CurrentDirectory + "/" + ABConfigPath)) { AssetDatabase.CreateAsset(abConfig, ABConfigPath); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } }
public bool JudgeCanLoadAB(string abPath) { if ((ABConfig.ABResLoadfrom == ABResLoadFrom.StreamingAssetAB) || (ABConfig.ABResLoadfrom == ABResLoadFrom.PersistentDataPathAB && FileHelper.JudgeFilePathExit(abPath))) { return(true); } return(false); }
/// <summary> /// 获取xml文件中的识别对象,比如全部的识别图名称,或者模型名称 /// </summary> /// <param name="xmlPath"></param> /// <returns></returns> public static List <string> GetDataSetTarget(string xmlPath) { if (xmlPath == "") { AFLogger.d("未找到DataSet对应的xml文件,请检查设置!"); return(null); } if (!FileHelper.JudgeFilePathExit(xmlPath)) { AFLogger.d("DataSet对应的xml路径不存在:" + xmlPath); return(null); } string xmlContent = FileHelper.ReadTxtToStr(xmlPath); if (xmlContent.Contains("ImageTarget")) { FileInfo fileInfo = new FileInfo(xmlPath); using (FileStream fs = fileInfo.OpenRead()) { var knownTypes = new Type[] { typeof(VuforiaImage.ImageTargetList) }; XmlSerializer xmlserializer = new XmlSerializer(typeof(VuforiaImage.QCARConfig), knownTypes); VuforiaImage.QCARConfig data = xmlserializer.Deserialize(fs) as VuforiaImage.QCARConfig; List <string> imageTargets = new List <string>(); foreach (var OneImageTarget in data.Tracking.ImageTarget) { imageTargets.Add(OneImageTarget.name); } return(imageTargets); } } else if (xmlContent.Contains("ModelTarget") && xmlContent.Contains("Assembly")) { FileInfo fileInfo = new FileInfo(xmlPath); using (FileStream fs = fileInfo.OpenRead()) { var knownTypes = new Type[] { typeof(VuforiaModel.ModelTargetInfo), typeof(VuforiaModel.ModelTargetNameInfo), typeof(VuforiaModel.Assembly), typeof(VuforiaModel.Part) }; XmlSerializer xmlserializer = new XmlSerializer(typeof(VuforiaModel.QCARConfig), knownTypes); VuforiaModel.QCARConfig data = xmlserializer.Deserialize(fs) as VuforiaModel.QCARConfig; List <string> imageTargets = new List <string>(); imageTargets.Add(data.Assembly.Part.name); return(imageTargets); } } return(null); }
public static string[,] GetFirstSheetInfo(string filePath) { if (FileHelper.JudgeFilePathExit(filePath)) { FileInfo fileInfo = new FileInfo(filePath); ExcelPackage excelPackage = new ExcelPackage(fileInfo); ExcelWorksheets excelWorksheets = excelPackage.Workbook.Worksheets; if (excelWorksheets.Count > 0 && excelWorksheets[1] != null) { return(GetSheetInfo(excelWorksheets[1])); } else { AFLogger.e("excel文件内没有表格"); } } return(null); }
/// <summary> /// 获取表格内单个sheet信息 /// </summary> public string[,] GetSheetInfo(string filePath, string sheetName) { if (FileHelper.JudgeFilePathExit(filePath)) { FileInfo fileInfo = new FileInfo(filePath); ExcelPackage excelPackage = new ExcelPackage(fileInfo); ExcelWorksheets excelWorksheets = excelPackage.Workbook.Worksheets; if (excelWorksheets[sheetName] != null) { return(GetSheetInfo(excelWorksheets[sheetName])); } else { AFLogger.e("excel文件内没有" + sheetName + "表格"); } } return(null); }
public bool CheckABConfigExit(string ConfigPathPre) { switch (ABConfig.configWritingMode) { case ConfigWritingMode.Binary: Debug.Log("ABConfig路径:" + ConfigPathPre + ABConfigName); return(FileHelper.JudgeFilePathExit(ConfigPathPre + ABConfigName)); case ConfigWritingMode.TXT: Debug.Log("ABConfig路径:" + (ConfigPathPre + ABConfigName + ".txt")); return(FileHelper.JudgeFilePathExit(ConfigPathPre + ABConfigName + ".txt")); case ConfigWritingMode.XML: Debug.Log("ABConfig路径:" + (ConfigPathPre + ABConfigName + ".xml")); return(FileHelper.JudgeFilePathExit(ConfigPathPre + ABConfigName + ".xml")); } return(false); }
private void Update() { if (downloadOperation != null) { if (downloadOperation.Status == DownloadStatus.Failed) { Debug.Log("下载失败:" + downloadOperation.Error); } else if (downloadOperation.Status == DownloadStatus.Successful) { Debug.Log("下载完成:" + downloadOperation.DestinationPath); Debug.Log("下载完成文件是否存在:" + FileHelper.JudgeFilePathExit(PathTool.PersistentDataPath + "APPInfo.txt")); downloadOperation = null; } else { Debug.Log("下载失败:???"); } } }
/// <summary> /// 获取表格的全部信息 /// </summary> public static Dictionary <string, string[, ]> GetExcelInfo(string filePath) { Dictionary <string, string[, ]> sheetNameToCon = new Dictionary <string, string[, ]>(); if (FileHelper.JudgeFilePathExit(filePath)) { FileInfo fileInfo = new FileInfo(filePath); ExcelPackage excelPackage = new ExcelPackage(fileInfo); ExcelWorksheets excelWorksheets = excelPackage.Workbook.Worksheets; if (excelWorksheets.Count > 0) { for (int i = 0; i < excelWorksheets.Count; i++) { sheetNameToCon.Add(excelWorksheets[i].Name, GetSheetInfo(excelWorksheets[i])); } } else { AFLogger.e("excel文件内没有表格"); } } return(sheetNameToCon); }
public static void OnPostProcessBuild(BuildTarget target, string path) { if (BuildTarget.iOS != target) { return; } string[] s = AssetDatabasex.GetAssetPathStr("AppInfoConfig").Split('/'); string XcodeSettingPath = PathTool.ProjectPath; for (int i = 0; i < s.Length - 1; i++) { XcodeSettingPath += s[i] + "/"; } XcodeSettingPath += "Editor/XcodeSetting.txt"; if (XcodeSettingPath == "" || !FileHelper.JudgeFilePathExit(XcodeSettingPath)) { return; } XcodeSetting XcodeSetting = SerializeHelper.FromJson <XcodeSetting>(AssetDatabasex.LoadAssetOfType <TextAsset>("XcodeSetting").text); string projPath = PBXProject.GetPBXProjectPath(path); PBXProject pbx = new PBXProject(); pbx.ReadFromString(File.ReadAllText(projPath)); string guid = pbx.TargetGuidByName("Unity-iPhone"); iOSXcodeSet.SetTeamId(pbx, guid, XcodeSetting.TeamID); iOSXcodeSet.SetFrameworks(pbx, guid, XcodeSetting.frameworkToProjectList); iOSXcodeSet.SetLibs(pbx, guid, XcodeSetting.StaticlibraryDic); iOSXcodeSet.SetBuildProperty(pbx, guid, XcodeSetting.buildPropertyDic); //拷贝文件 iOSXcodeSet.CopyFiles(pbx, guid, XcodeSetting.CopyFileDic, path); iOSXcodeSet.CopyFolders(pbx, guid, XcodeSetting.CopyFolderDic, path); iOSXcodeSet.SetFilesCompileFlag(pbx, guid, XcodeSetting.FilesCompileFlagDIC); File.WriteAllText(projPath, pbx.WriteToString()); //修改Info.plist string plistPath = path + "/Info.plist"; iOSInfoPlist pListEditor = new iOSInfoPlist(plistPath); if (XcodeSetting.Version != "") { pListEditor.Update("CFBundleShortVersionString", XcodeSetting.Version); } if (XcodeSetting.build != "") { pListEditor.Update("CFBundleVersion", XcodeSetting.build); } if (XcodeSetting.BundleIdentifier != "" && XcodeSetting.BundleIdentifier.Split('.').Length >= 3) { pListEditor.Update("CFBundleIdentifier", XcodeSetting.BundleIdentifier); } foreach (var entry in XcodeSetting.pListDataDic) { pListEditor.Update(entry.Key, entry.Value, entry.infoType, entry.isAdd); } foreach (var urlScheme in XcodeSetting.urlSchemeDic) { pListEditor.UpdateUrlScheme(urlScheme.Key, urlScheme.Value, urlScheme.isAdd); } foreach (var whiteUrlScheme in XcodeSetting.appQueriesSchemeList) { pListEditor.UpdateLSApplicationQueriesScheme(whiteUrlScheme.Value, whiteUrlScheme.isAdd); } pListEditor.Save(); }
public override void DownloadFinish() { base.DownloadFinish(); ABClassDownInfo aBDownInfo = (ABClassDownInfo)httpInfo; OneABClassInfo NewABInfo = SerializeHelper.FromJson <OneABClassInfo>(FileHelper.ReadTxtToStr(m_saveFilePath)); List <string> downStr = new List <string>(); bool isLocalABComplete = true; bool isNeedHot = false; if (aBDownInfo.oldClassInfo != null) { List <string> keys = new List <string>(NewABInfo.FileMD5.Keys); for (int i = 0; i < keys.Count; i++) { if (aBDownInfo.oldClassInfo.FileMD5.ContainsKey(keys[i])) { if (NewABInfo.FileMD5[keys[i]].Equals(aBDownInfo.oldClassInfo.FileMD5[keys[i]])) // MD5相等 { if (!FileHelper.JudgeFilePathExit(PathTool.PersistentDataPath + keys[i])) //本地没有AB存在 { AFLogger.d("检测MD5:本地没有AB存在111"); isLocalABComplete = false; //本地AB包不完整 isNeedHot = true; downStr.Add(keys[i]); } } else { isNeedHot = true; downStr.Add(keys[i]); if (!FileHelper.JudgeFilePathExit(PathTool.PersistentDataPath + "/" + keys[i])) //本地没有AB存在 { AFLogger.d("检测MD5:本地没有AB存在222"); isLocalABComplete = false; //本地AB包不完整 } } } else { isLocalABComplete = false; //本地AB包不完整 isNeedHot = true; downStr.Add(keys[i]); } } } else { isLocalABComplete = false; isNeedHot = true; List <string> keys = new List <string>(NewABInfo.FileMD5.Keys); for (int i = 0; i < keys.Count; i++) { FileHelper.DeleteFile(PathTool.PersistentDataPath + "/" + keys[i]); downStr.Add(keys[i]); } } if (aBDownInfo.ABMD5Callback != null) { ABState aBState = ABState.Newest; if (isNeedHot) { if (isLocalABComplete) { aBState = ABState.UpdateAndLocalComplete; } else { aBState = ABState.UpdateAndLocalNotComplete; } } aBDownInfo.CheckMD5Call(NewABInfo, aBState, downStr); aBDownInfo.ABMD5CallbackLocal(aBDownInfo, downResult, downError); } }
/// <summary> /// 加载Androidmanifest /// </summary> /// <returns></returns> public bool LoadAssetManifest() { AssetBundleConfig config = null; switch (ABConfig.configWritingMode) { case ConfigWritingMode.Binary: if (FileHelper.JudgeFilePathExit(GetABConfigLocalPath())) { if (configAB != null) { configAB.Unload(false); } configAB = AssetBundle.LoadFromFile(GetABConfigLocalPath()); TextAsset textAsset = configAB.LoadAsset <TextAsset>(ABConfigName); if (textAsset == null) { Debug.LogError("AssetBundleConfig is no exist!"); return(false); } //反序列化,得到打包的信息 MemoryStream stream = new MemoryStream(textAsset.bytes); BinaryFormatter bf = new BinaryFormatter(); config = (AssetBundleConfig)bf.Deserialize(stream); stream.Close(); } else { AFLogger.e("AssetbundleConfig文件不存在"); return(false); } break; case ConfigWritingMode.TXT: string abJson = ""; if (ABConfig.ABResLoadfrom == ABResLoadFrom.PersistentDataPathAB) { abJson = FileHelper.ReadTxtToStr(GetABConfigLocalPath()); if (abJson.Equals("")) { AFLogger.e("AssetbundleConfig文件不存在或者内容为空"); return(false); } } else if (ABConfig.ABResLoadfrom == ABResLoadFrom.StreamingAssetAB) { string abConfigPath = "AF-ABForLocal/AF-InfoFile" + GetVersionStr() + "/" + GetStrByPlatform() + ABConfigName; TextAsset textAsset = ResManager.Instance.LoadSync(ResLoadInfo.Allocate(ResFromType.ResourcesRes, abConfigPath, false)) as TextAsset; abJson = textAsset.text; } config = SerializeHelper.FromJson <AssetBundleConfig>(abJson); break; case ConfigWritingMode.XML: XmlDocument xml = new XmlDocument(); MemoryStream ms = null; if (ABConfig.ABResLoadfrom == ABResLoadFrom.PersistentDataPathAB) { xml.Load(GetABConfigLocalPath()); } else { string abConfigPath = "AF-ABForLocal/AF-InfoFile" + GetVersionStr() + "/" + GetStrByPlatform() + ABConfigName; TextAsset textAsset = ResManager.Instance.LoadSync(ResLoadInfo.Allocate(ResFromType.ResourcesRes, abConfigPath, false)) as TextAsset; //由于编码问题,要设置编码方式 byte[] encodeString = System.Text.Encoding.UTF8.GetBytes(textAsset.text); //以流的形式来读取 ms = new MemoryStream(encodeString); xml.Load(ms); } if (xml == null) { AFLogger.e("AssetbundleConfig文件不存在或者内容为空"); return(false); } XmlSerializer xmldes = new XmlSerializer(typeof(AssetBundleConfig)); StringReader sr = new StringReader(xml.InnerXml); config = (AssetBundleConfig)xmldes.Deserialize(sr); if (ms != null) { ms.Close(); ms.Dispose(); } if (sr != null) { sr.Close(); sr.Dispose(); } break; } ResManager.Instance.CacheABConfig(config); return(true); }