Example #1
0
        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.");
            }
        }
Example #2
0
        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.");
            }
        }
Example #3
0
        private async void Start()
        {
            Sheet = new SheetContainer(new UnityLogger());
            await Sheet.Load(Path.Combine(Application.streamingAssetsPath, "Excel"));

            Debug.Log(Sheet.Constants.Count);
            Debug.Log(Sheet.Heroes["HERO001"].Count);
            Debug.Log(Sheet.Heroes["HERO001"].GetLevel(5).RequiredItem.Ref.Name);
            Debug.Log(Sheet.Items["ITEM_POTION001"].Name);
        }
Example #4
0
        private async void Start()
        {
            var jsonPath      = Path.Combine(Application.streamingAssetsPath, "Excel");
            var jsonConverter = new JsonSheetConverter(jsonPath);

            Sheet = new SheetContainer(new UnityLogger());
            await Sheet.Bake(jsonConverter);

            Debug.Log(Sheet.Constants.Count);
            Debug.Log(Sheet.Heroes["HERO001"].Count);
            Debug.Log(Sheet.Heroes["HERO001"].GetLevel(5).RequiredItem.Ref.Name);
            Debug.Log(Sheet.Items["ITEM_POTION001"].Name);
        }