private void Header() { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true)); { if (IsEdit) { Undo.IncrementCurrentGroup(); UndoHelper.ConverterUndo(data, UndoHelper.UNDO_CONVERTER_EDIT); ConverterName = EditorGUILayout.TextField(ConverterName, EditorStyles.toolbarTextField); } else { GUILayout.Label(ConverterName); } GUILayout.Label(string.Format("({0})", ScriptName)); GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("Open", GUIHelper.Textures.ScriptIcon), EditorStyles.toolbarButton, GUILayout.Width(80))) { FileUtility.OpenInEditor(ScriptName); } var edit = GUILayout.Toggle(IsEdit, "Edit", EditorStyles.toolbarButton, GUILayout.Width(50)); if (edit != IsEdit) { EditorGUIUtility.keyboardControl = 0; IsEdit = edit; } } EditorGUILayout.EndHorizontal(); }
private void OnSelectedSpreadSheetChange() { UndoHelper.WindowUndo(this, UndoHelper.UNDO_WIN_CHANGE); SpreadSheetConfigItem = new GoogleSpreadSheetConfigEditorGUI(SelectedSpreadSheet); selectedConverter = 0; EditorGUIUtility.keyboardControl = 0; }
private void LightSide() { EditorGUILayout.BeginVertical(GUIHelper.Styles.LeftArea); { var selected = GUILayout.Toolbar(selectedMenu, WindowHelper.MENU_WINDOW, EditorStyles.toolbarButton, GUILayout.ExpandWidth(true)); if (selected != selectedMenu) { UndoHelper.WindowUndo(this, UndoHelper.UNDO_WIN_CHANGE); EditorGUIUtility.keyboardControl = 0; selectedMenu = selected; } switch (selectedMenu) { case 0: SheetContents(); break; case 1: if (OAuthConfigItem != null) { OAuthConfigItem.OnGUI(); } break; } } EditorGUILayout.EndVertical(); }
private void OnSelectedConverterChange() { UndoHelper.WindowUndo(this, UndoHelper.UNDO_WIN_CHANGE); EditorGUIUtility.keyboardControl = 0; if (SelectedConverter != null) { ConverterItem = new GoogleSpreadSheetConverterEditorGUI(SelectedConverter); } }
private void DrawConverterList() { if (ConverterEditorUtility.ConverterTypeMenu == null || ConverterEditorUtility.ConverterTypeMenu.Count == 0) { EditorGUILayout.HelpBox("You have to create your own converter class.", MessageType.Error); return; } GUILayout.Space(3); EditorGUILayout.BeginHorizontal(GUIHelper.Styles.SheetConverterLabel); { GUILayout.Label(" Converters"); GUILayout.FlexibleSpace(); if (GUILayout.Button("", GUIHelper.Styles.PlusButton)) { popupWin = new SpreadSheetConvertToolConverterPopupWindow(); popupWin.Initialize(data); PopupWindow.Show(Rect.zero, popupWin); EditorGUIUtility.keyboardControl = 0; } } EditorGUILayout.EndHorizontal(); if (Converter == null || Converter.Count == 0) { EditorGUILayout.HelpBox("no converers.", MessageType.Warning); return; } GUILayout.Space(5); converterListView = EditorGUILayout.BeginScrollView(converterListView); { for (int i = 0; i < Converter.Count; i++) { GUI.backgroundColor = i == SelectedCoverter ? Color.yellow : Color.white; if (GUILayout.Button(Converter[i].ConverterName, GUIHelper.Styles.ConverterList, GUILayout.Height(30))) { UndoHelper.SpreadSheetUndo(data, UndoHelper.UNDO_SS_CHANGE); SelectedCoverter = i; EditorGUIUtility.keyboardControl = 0; } } } EditorGUILayout.EndScrollView(); GUI.backgroundColor = Color.white; }
private void DrawSaveDataConfig() { GUILayout.Space(3); GUILayout.Box("", new GUILayoutOption[] { GUILayout.Height(2f), GUILayout.ExpandWidth(true) }); GUILayout.Space(3); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Save Path".ToBold(), GUILayout.Width(100)); EditorGUILayout.TextField(SavePath); { var path = FileUtility.GetDraggedObjectPath(Event.current, GUILayoutUtility.GetLastRect()); if (!string.IsNullOrEmpty(path)) { UndoHelper.ConverterUndo(data, UndoHelper.UNDO_CONVERTER_EDIT); SavePath = path; } } if (GUILayout.Button(" Select ", GUILayout.Width(60))) { Undo.IncrementCurrentGroup(); UndoHelper.ConverterUndo(data, UndoHelper.UNDO_CONVERTER_EDIT); var path = EditorUtility.OpenFolderPanel("Select Folder", "", ""); if (!string.IsNullOrEmpty(path)) { UndoHelper.ConverterUndo(data, UndoHelper.UNDO_CONVERTER_EDIT); SavePath = path; } EditorGUIUtility.keyboardControl = 0; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Save FileName".ToBold(), GUILayout.Width(150)); SaveFileName = EditorGUILayout.TextField(SaveFileName); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Save File Extension".ToBold(), GUILayout.Width(150)); SaveFileExtension = EditorGUILayout.TextField(SaveFileExtension); } EditorGUILayout.EndHorizontal(); GUILayout.Space(5); }
protected override void Draw() { EditorGUILayout.BeginVertical(); { GUILayout.Space(5); GUILayout.Label("<b>Default OAuth Client</b>"); GUILayout.Space(5); var defaultWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 100; Undo.IncrementCurrentGroup(); UndoHelper.GoogleAPIOAuthUndo(data, UndoHelper.UNDO_GOOGLEAPI_EDIT); OAuthClientId = EditorGUILayout.TextField("ClientID", OAuthClientId, GUIHelper.Styles.TextFieldWordWrap); OAuthClientSecret = EditorGUILayout.TextField("ClientSecret", OAuthClientSecret, GUIHelper.Styles.TextFieldWordWrap); RefreshToken = EditorGUILayout.TextField("RefreshToken", RefreshToken, GUIHelper.Styles.TextFieldWordWrap); EditorGUIUtility.labelWidth = defaultWidth; EditorGUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Check Config", new GUILayoutOption[] { GUILayout.Width(120), GUILayout.Height(25) })) { EditorUtility.DisplayProgressBar("Spread Sheet Converter", "Checking Config...", 0f); try { var webRequest = new GoogleSpreadSheetWebRequest(OAuthClientId, OAuthClientSecret, RefreshToken); var requestCo = webRequest.CheckAccessToken(); while (requestCo.MoveNext()) { } EditorUtility.DisplayDialog("Spread Sheet Converter", "The setting is correct.", "ok"); AccessToken = webRequest.GetAccessToken(); } catch (Exception ex) { Debug.LogError(ex); } EditorUtility.ClearProgressBar(); } } EditorGUILayout.EndHorizontal(); GUILayout.Space(15); GUILayout.Label("<b>Your Current AccessToken</b>"); GUILayout.Label(AccessToken, GUIHelper.Styles.LabelWordWrap); } EditorGUILayout.EndHorizontal(); }
private void DrawCellRangeConfig() { GUILayout.Space(3); GUILayout.Box("", new GUILayoutOption[] { GUILayout.Height(2f), GUILayout.ExpandWidth(true) }); GUILayout.Space(3); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Cell Range".ToBold(), GUILayout.Width(100)); GUILayout.Label((StartCell + " : " + EndCell).ToMiddleBold()); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { Undo.IncrementCurrentGroup(); UndoHelper.ConverterUndo(data, UndoHelper.UNDO_CONVERTER_EDIT); GUILayout.Label(UseAutomaticEnd ? "Start Row" : "Row Range", GUILayout.Width(100)); if (UseAutomaticEnd) { data.RowRange.x = EditorGUILayout.IntSlider(( int )RowRange.x, 1, MaxRow); data.RowRange.y = RowRange.x + 1; } else { EditorGUILayout.MinMaxSlider(ref data.RowRange.x, ref data.RowRange.y, 1, MaxRow); } data.RowRange.x = ( int )RowRange.x; data.RowRange.y = ( int )RowRange.y; StartRow = ( int )RowRange.x; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { Undo.IncrementCurrentGroup(); UndoHelper.ConverterUndo(data, UndoHelper.UNDO_CONVERTER_EDIT); GUILayout.Label(UseAutomaticEnd ? "Start Col" : "Col Range", GUILayout.Width(100)); if (UseAutomaticEnd) { data.ColRange.x = EditorGUILayout.IntSlider(( int )ColRange.x, 1, MaxCol); data.ColRange.y = ColRange.x + 1; } else { EditorGUILayout.MinMaxSlider(ref data.ColRange.x, ref data.ColRange.y, 1, MaxCol); } data.ColRange.x = ( int )ColRange.x; data.ColRange.y = ( int )ColRange.y; StartCol = ( int )ColRange.x; } EditorGUILayout.EndHorizontal(); GUILayout.Space(5); EditorGUI.BeginDisabledGroup(!IsEdit); { EditorGUILayout.BeginHorizontal(); { Undo.IncrementCurrentGroup(); UndoHelper.ConverterUndo(data, UndoHelper.UNDO_CONVERTER_EDIT); GUILayout.Label("Use Automatic End", GUILayout.Width(150)); UseAutomaticEnd = EditorGUILayout.Toggle(UseAutomaticEnd); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { Undo.IncrementCurrentGroup(); UndoHelper.ConverterUndo(data, UndoHelper.UNDO_CONVERTER_EDIT); GUILayout.Label("Max Row Range", GUILayout.Width(100)); MaxRow = EditorGUILayout.IntField(MaxRow, GUILayout.Width(50)); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { Undo.IncrementCurrentGroup(); UndoHelper.ConverterUndo(data, UndoHelper.UNDO_CONVERTER_EDIT); GUILayout.Label("Max Col Range", GUILayout.Width(100)); MaxCol = EditorGUILayout.IntField(MaxCol, GUILayout.Width(50)); } EditorGUILayout.EndHorizontal(); } EditorGUI.EndDisabledGroup(); }
private void DrawSheetNameConfig() { GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); { Undo.IncrementCurrentGroup(); UndoHelper.ConverterUndo(data, UndoHelper.UNDO_CONVERTER_EDIT); GUILayout.Label("Sheet Name".ToBold(), GUILayout.Width(100)); SheetName = EditorGUILayout.TextField(SheetName); } EditorGUILayout.EndHorizontal(); EditorGUI.BeginDisabledGroup(!IsEdit); { EditorGUILayout.BeginHorizontal(); { Undo.IncrementCurrentGroup(); UndoHelper.ConverterUndo(data, UndoHelper.UNDO_CONVERTER_EDIT); GUILayout.Label("Multi Sheet Convert".ToBold(), GUILayout.Width(150)); MultiSheetConvertMode = EditorGUILayout.Toggle(MultiSheetConvertMode); } EditorGUILayout.EndHorizontal(); if (MultiSheetConvertMode) { EditorGUILayout.BeginHorizontal(); { Undo.IncrementCurrentGroup(); UndoHelper.ConverterUndo(data, UndoHelper.UNDO_CONVERTER_EDIT); GUILayout.Label("Min Sheet Index", GUILayout.Width(150)); MinSheetIndex = EditorGUILayout.IntField(MinSheetIndex, GUILayout.Width(50)); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { Undo.IncrementCurrentGroup(); UndoHelper.ConverterUndo(data, UndoHelper.UNDO_CONVERTER_EDIT); GUILayout.Label("Max Sheet Index", GUILayout.Width(150)); MaxSheetIndex = EditorGUILayout.IntField(MaxSheetIndex, GUILayout.Width(50)); } EditorGUILayout.EndHorizontal(); } } EditorGUI.EndDisabledGroup(); if (MultiSheetConvertMode) { Undo.IncrementCurrentGroup(); UndoHelper.ConverterUndo(data, UndoHelper.UNDO_CONVERTER_EDIT); GUILayout.Label(("Sheet Range : " + data.SheetIndexRange.x + " - " + data.SheetIndexRange.y).ToMiddleBold()); EditorGUILayout.BeginHorizontal(); { GUILayout.Space(100); EditorGUILayout.MinMaxSlider(ref data.SheetIndexRange.x, ref data.SheetIndexRange.y, MinSheetIndex, MaxSheetIndex); } EditorGUILayout.EndHorizontal(); data.SheetIndexRange.x = ( int )SheetIndexRange.x; data.SheetIndexRange.y = ( int )SheetIndexRange.y; EditorGUILayout.HelpBox("SheetName Example: mysheet_#NUM#", MessageType.Info); } }
private void Header() { EditorGUILayout.BeginHorizontal(); { Undo.IncrementCurrentGroup(); UndoHelper.SpreadSheetUndo(data, UndoHelper.UNDO_SS_EDIT); GUILayout.Label("Name", GUILayout.Width(100)); Name = EditorGUILayout.TextField(Name); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { Undo.IncrementCurrentGroup(); UndoHelper.SpreadSheetUndo(data, UndoHelper.UNDO_SS_EDIT); GUILayout.Label("SpreadSheet Id", GUILayout.Width(100)); Id = EditorGUILayout.TextField(Id); } EditorGUILayout.EndHorizontal(); GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); { var usetoken = GUILayout.Toggle(UseDefaultAccessToken, "Use Default OAuth Config"); if (usetoken != UseDefaultAccessToken) { Undo.IncrementCurrentGroup(); UndoHelper.SpreadSheetUndo(data, UndoHelper.UNDO_SS_EDIT); if (usetoken) { OAuthClientId = GoogleAPIOAuthEditorConfig.Instance.OAuthClientId; OAuthClientSecret = GoogleAPIOAuthEditorConfig.Instance.OAuthClientSecret; RefreshToken = GoogleAPIOAuthEditorConfig.Instance.RefreshToken; } UseDefaultAccessToken = usetoken; } } EditorGUILayout.EndHorizontal(); var defaultWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 100; if (!UseDefaultAccessToken) { OAuthClientId = EditorGUILayout.TextField("ClientID", OAuthClientId, GUIHelper.Styles.TextFieldWordWrap); OAuthClientSecret = EditorGUILayout.TextField("ClientSecret", OAuthClientSecret, GUIHelper.Styles.TextFieldWordWrap); RefreshToken = EditorGUILayout.TextField("RefreshToken", RefreshToken, GUIHelper.Styles.TextFieldWordWrap); EditorGUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Check Config", new GUILayoutOption[] { GUILayout.Width(120), GUILayout.Height(20) })) { try { EditorUtility.DisplayProgressBar("Spread Sheet Converter", "Checking Config...", 0f); var webRequest = data.GetWebRequest(); Sheets = EditorAPIUtility.GetSheetName(webRequest); EditorUtility.DisplayDialog("Spread Sheet Converter", "The setting is correct.", "ok"); AccessToken = webRequest.GetAccessToken(); } catch (Exception ex) { Debug.LogError("SpreadSheetConfig Error: " + ex); } EditorUtility.ClearProgressBar(); } } EditorGUILayout.EndHorizontal(); } EditorGUIUtility.labelWidth = defaultWidth; }