public IExcelConfiguration HasSheetConfiguration(int sheetIndex, string sheetName, int startRowIndex, bool enableAutoColumnWidth, int?endRowIndex = null) { if (sheetIndex >= 0) { if (SheetSettings.TryGetValue(sheetIndex, out var sheetSetting)) { sheetSetting.SheetName = sheetName; sheetSetting.StartRowIndex = startRowIndex; sheetSetting.AutoColumnWidthEnabled = enableAutoColumnWidth; sheetSetting.EndRowIndex = endRowIndex; } else { SheetSettings[sheetIndex] = new SheetSetting() { SheetIndex = sheetIndex, SheetName = sheetName, StartRowIndex = startRowIndex, AutoColumnWidthEnabled = enableAutoColumnWidth, EndRowIndex = endRowIndex }; } } return(this); }
public void Init() { config = (GoogleSheetsToUnityConfig)Resources.Load(_gstuAPIsConfig); var finds = AssetDatabase.FindAssets($"t:{_sheetSettingAsset}", null); foreach (var item in finds) { var path = AssetDatabase.GUIDToAssetPath(item); _sheetSetting = AssetDatabase.LoadAssetAtPath <SheetSetting>(path); } if (_queue == null) { _queue = new QueueAction(); } }
/// <summary> /// 配置工作表设置 /// </summary> /// <param name="configAction">配置操作</param> /// <param name="sheetIndex">工作表索引</param> public IExcelConfiguration HasSheetSheeting(Action <SheetSetting> configAction, int sheetIndex = 0) { if (configAction == null) { throw new ArgumentNullException(nameof(configAction)); } if (sheetIndex >= 0) { if (!SheetSettings.TryGetValue(sheetIndex, out var sheetSetting)) { sheetSetting = new SheetSetting(); SheetSettings[sheetIndex] = sheetSetting; } configAction.Invoke(sheetSetting); } return(this); }
public IExcelConfiguration HasSheetSetting(Action <SheetSetting> configAction, int sheetIndex = 0) { if (sheetIndex >= 0 && configAction != null) { if (SheetSettings.TryGetValue(sheetIndex, out var sheetSetting)) { configAction.Invoke(sheetSetting); } else { SheetSettings[sheetIndex] = sheetSetting = new SheetSetting(); } configAction.Invoke(sheetSetting); } return(this); }
private void DrawLocalization() { if (_sheetSetting == null) { GUILayout.Label("Create GSTU Setting", EditorStyles.boldLabel); GUI.backgroundColor = Color.red; if (!GUILayout.Button("Create", GUILayout.Height(30))) { return; } if (AssetDatabase.IsValidFolder(_folderPath)) { _sheetSetting = CreateInstance <SheetSetting>(); AssetDatabase.CreateAsset(_sheetSetting, $"{_folderPath}/{_sheetSettingAsset}.asset"); config = CreateInstance <GoogleSheetsToUnityConfig>(); AssetDatabase.CreateAsset(config, $"{_resourcePath}/{_gstuAPIsConfig}.asset"); } else { //create export folder AssetDatabase.CreateFolder("Assets", exportFolder); //create export resource folder AssetDatabase.CreateFolder(_folderPath, "Resources"); //create export scripts folder AssetDatabase.CreateFolder(_folderPath, "Scripts"); _sheetSetting = CreateInstance <SheetSetting>(); _sheetSetting.GoogleSheets = new List <SheetConfig> { new SheetConfig() }; AssetDatabase.CreateAsset(_sheetSetting, $"{_folderPath}/{_sheetSettingAsset}.asset"); config = CreateInstance <GoogleSheetsToUnityConfig>(); AssetDatabase.CreateAsset(config, $"{_resourcePath}/{_gstuAPIsConfig}.asset"); } AssetDatabase.SaveAssets(); } else if (!showTextTemplate) { scrollPosition = GUILayout.BeginScrollView(scrollPosition); GUILayout.Label(""); GUILayout.Label("Google Sheet Config", EditorStyles.boldLabel); for (int i = 0; i < _sheetSetting.GoogleSheets.Count; i++) { DrawSheetConfig(i + 1, _sheetSetting.GoogleSheets[i]); GUI.backgroundColor = Color.white; } GUILayout.EndScrollView(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Add Google Sheet")) { _sheetSetting.GoogleSheets.Add(new SheetConfig()); } if (GUILayout.Button("Expand")) { expandAll = !expandAll; for (int i = 0; i < _sheetSetting.GoogleSheets.Count; i++) { _sheetSetting.GoogleSheets[i].isExpand = expandAll; } } GUI.backgroundColor = Color.yellow; if (GUILayout.Button("Save Asset")) { EditorUtility.SetDirty(config); EditorUtility.SetDirty(_sheetSetting); AssetDatabase.SaveAssets(); } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); GUILayout.Label(""); GUILayout.Label("Download & Build all data", EditorStyles.boldLabel); GUI.backgroundColor = Color.green; if (GUILayout.Button("Build all", GUILayout.Height(30))) { OnImportClicked(); } GUILayout.Label("", GUILayout.Height(60)); } else if (showTextTemplate) { scrollPosition = GUILayout.BeginScrollView(scrollPosition); GUILayout.Label(""); GUILayout.Label("Build Text Template", EditorStyles.boldLabel); _sheetSetting.textTemplate = GUILayout.TextArea(_sheetSetting.textTemplate); GUILayout.EndScrollView(); } }
/// <summary> /// 初始化一个<see cref="SheetConfiguration"/>类型的实例 /// </summary> /// <param name="sheetSetting">工作表设置</param> public SheetConfiguration(SheetSetting sheetSetting) { SheetSetting = sheetSetting ?? new SheetSetting(); }