static async void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { // automatically run postprocessor if any excel file is imported string excelAsset = importedAssets.FirstOrDefault(x => x.EndsWith(".xlsx")); if (excelAsset != null) { var excelPath = Path.GetDirectoryName(excelAsset); var jsonPath = Path.Combine(Application.streamingAssetsPath, "Excel"); var logger = new UnityLogger(); var sheetContainer = new SheetContainer(logger); // create excel converter from path var excelConverter = new ExcelSheetConverter(excelPath, TimeZoneInfo.Utc); // bake sheets from excel converter await sheetContainer.Bake(excelConverter); // create json converter to path var jsonConverter = new JsonSheetConverter(jsonPath); // save datasheet to streaming assets await sheetContainer.Store(jsonConverter); AssetDatabase.Refresh(); Debug.Log("Excel sheet converted."); } }
static async void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { // automatically run postprocessor if any excel file is imported string csvAsset = importedAssets.FirstOrDefault(x => x.EndsWith(".csv")); if (csvAsset != null) { var csvPath = Path.GetDirectoryName(csvAsset); var resultPath = Path.Combine(Application.streamingAssetsPath, "CSV"); var logger = new UnityLogger(); var sheetContainer = new SheetContainer(logger); // create csv converter from path var csvImporter = new CsvSheetConverter(csvPath, TimeZoneInfo.Utc); // bake sheets from csv converter await sheetContainer.Bake(csvImporter); // create csv converter to path var csvExporter = new CsvSheetConverter(resultPath, TimeZoneInfo.Utc); // save datasheet to streaming assets await sheetContainer.Store(csvExporter); AssetDatabase.Refresh(); Debug.Log("CSV sheet converted."); } }