private static void GenerateUI(string configPath, string spriteFolderPath, Canvas canvas) { CsvTable table = null; pos_readdoc : if (File.Exists(configPath)) { try { table = CsvHelper.ReadCSV(configPath, System.Text.Encoding.GetEncoding("GB2312")); } catch (Exception e) { var reopen = EditorUtility.DisplayDialog("提示", e.Message, "重试", "取消"); if (reopen) { goto pos_readdoc; } } if (table != null) { var canLoad = table.IsUIInfoTable(false); if (canLoad) { var isTitleMatch = table.IsUIInfoTable(true); if (!isTitleMatch) { var forceLoad = Notice("文档标题不匹配:" + string.Join(",", UIInfo_TableExtend.uiInfoHead) + "\n继续请按确认!", true); if (!forceLoad) { return; } } var uiInfo = table.LoadUIInfo(); if (uiInfo != null) { if (emptyImporter != null) { Assembler.emptyImporter = emptyImporter; } Assembler.GenerateUI(spriteFolderPath, canvas, layerImportTypes, uiInfo); } } else { Notice("配制文档不可用,请核对后重试!"); } } } }
private static void GroupImportTexture() { var path = AssetDatabase.GetAssetPath(Selection.activeObject); if (!string.IsNullOrEmpty(path)) { var table = CsvHelper.ReadCSV(path, System.Text.Encoding.GetEncoding("gb2312")); TextureInfoTable infoTable = new TextureInfoTable(); infoTable.LoadFromCsvTable(table); if (infoTable != null) { var spriteFolder = EditorUtility.OpenFolderPanel("请选择需要批量导入信息的图片根目录!", System.IO.Path.GetDirectoryName(path), ""); if (!string.IsNullOrEmpty(spriteFolder)) { spriteFolder = spriteFolder.Replace("\\", "/"); if (spriteFolder.StartsWith(Application.dataPath)) { spriteFolder = spriteFolder.Replace(Application.dataPath, "Assets"); for (int i = 0; i < infoTable.textureInfos.Count; i++) { var textureInfo = infoTable.textureInfos[i]; var fullPath = spriteFolder + "/" + textureInfo.texturePath; var texture = AssetDatabase.LoadAssetAtPath <Texture>(fullPath); if (texture != null && textureInfo != null) { SetTextureResourceDic(fullPath, textureInfo); } } AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); } } } } }