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> /// 根据产品名获取产品信息,会有一个Add操作,慎用 /// </summary> /// <param name="productName"></param> /// <returns></returns> public ProductInfo GetProductInfoByProductName(string productName) { string jsonPath = GetProductInfoJsonPath(productName); string json = InterfacePlatformTools.ReadText(jsonPath); ProductInfo info = InterfacePlatformTools.Deserialize <ProductInfo>(json); productInfosList.Add(info); return(info); }
/// <summary> /// 产品名字列表 /// </summary> /// <returns></returns> public List <string> GetProductsInfoList() { string productLists = InterfacePlatformTools.ReadText(JsonType.LibraryProductsList); if (string.IsNullOrEmpty(productLists)) { Debug.Log("库中无软件"); return(null); } var productInfosList = InterfacePlatformTools.Deserialize <ProductsDirList>(productLists); foreach (var item in productInfosList.Products) { Debug.Log(item); } return(productInfosList.Products); }
/// <summary> /// 初始化所有本地有的版本UnityEditor /// StreamingAsset下面存一个模板 /// </summary> private void InitAllUnityLocalVersion() { versionLocationsList = new List <EXEFileLocation>(); string localEditorInfo = InterfacePlatformTools.ReadText(JsonType.UnityEditorLocalVersion); if (string.IsNullOrEmpty(localEditorInfo)) { return; } List <EXEFileLocation> exeLocations = InterfacePlatformTools.Deserialize <List <EXEFileLocation> >(localEditorInfo); foreach (var item in exeLocations) { var location = new EXEFileLocation(item.version, item.localpath); versionLocationsList.Add(location);//存入字典 方便添加时覆盖 EngineInfoUI engineUI = Instantiate(engineUIPrefab, scrollContent) as EngineInfoUI; engineUI.Init(EngineType.UnityEngine, location); } }