public static void CreateProductInfoDir (string productName, string companyName, string classifies, string description, string filePath) { InterfacePlatformTools.CreateJsonFiles(); string dirRootPath = LibraryManager.GetProductRootDirPath(); if (!Directory.Exists(dirRootPath)) { Directory.CreateDirectory(dirRootPath); } string productDirPath = dirRootPath + productName; string previewDirPath = productDirPath + "/Preview"; Directory.CreateDirectory(productDirPath); Directory.CreateDirectory(previewDirPath); var classifiesList = classifies.Split(',').ToList(); if (classifiesList == null) { Debug.Log("标签必须使用‘,’进行分段"); return; } ProductInfo productInfo = new ProductInfo { ProductName = productName, CompanyName = companyName, Classifies = classifiesList, Description = description, FilePath = filePath, }; string json = InterfacePlatformTools.Serialize(productInfo); string jsonPath = productDirPath + "/ProductInfo.json"; File.WriteAllText(jsonPath, json, System.Text.Encoding.UTF8); Debug.Log("创建完成"); string productDirListstr = InterfacePlatformTools.ReadText(JsonType.LibraryProductsList); LibraryManager.ProductsDirList productsDirList = new LibraryManager.ProductsDirList(); if (!string.IsNullOrEmpty(productDirListstr))//如果之前有内容 { productsDirList = InterfacePlatformTools.Deserialize <LibraryManager.ProductsDirList>(productDirListstr); } if (!productsDirList.Products.Contains(productName)) { productsDirList.Products.Add(productName); } string newProductDirListstr = InterfacePlatformTools.Serialize(productsDirList); File.WriteAllText(InterfacePlatformTools.GetJsonFilePath(JsonType.LibraryProductsList), newProductDirListstr, System.Text.Encoding.UTF8); }
/// <summary> /// 添加本地已有版本 /// </summary> private void AddAndSaveLocalVersion(EXEFileLocation location) { if (versionLocationsList.Exists((item) => { return(item.version == location.version); }))//传入的location和list中已有的只是值相同 还是要通过version比较一下 { UIManager.GetInstance().ShowMessagePanel(new MessageParam { content = string.Format("Unity{0} 已添加 !", location.version) }); Debug.LogError(location.version + "已添加"); return; } EngineInfoUI engineUI = Instantiate(engineUIPrefab, scrollContent) as EngineInfoUI; engineUI.Init(EngineType.UnityEngine, location); versionLocationsList.Add(location); string json = InterfacePlatformTools.Serialize(versionLocationsList); InterfacePlatformTools.WriteBytes(JsonType.UnityEditorLocalVersion, json); }