private void CheckNull() { if (m_datatableNames == null) { m_datatableNames = new ReorderableList(DataTableEditorConfig.GetConfig().DataTableNamesList, typeof(DataTableName), true, false, true, true); m_datatableNames.elementHeight = 40; m_datatableNames.drawElementCallback = (rectt, index, isActive, isFocused) => { DataTableEditorConfig.GetConfig().DataTableNamesList[index].Name = EditorGUI.TextField(rectt, "Data Table Name", DataTableEditorConfig.GetConfig().DataTableNamesList[index].Name); rectt.position = new Vector2(20, rectt.y + 20); rectt.size = new Vector2(rectt.width, 20); if (DataTableEditorConfig.GetConfig().DataTableNamesList[index].IsOn) { DataTableEditorConfig.GetConfig().DataTableNamesList[index].IsOn = EditorGUI.ToggleLeft(rectt, "On", DataTableEditorConfig.GetConfig().DataTableNamesList[index].IsOn); } else { DataTableEditorConfig.GetConfig().DataTableNamesList[index].IsOn = EditorGUI.ToggleLeft(rectt, "Off", DataTableEditorConfig.GetConfig().DataTableNamesList[index].IsOn); } }; m_datatableNames.drawHeaderCallback = (rectt) => EditorGUI.LabelField(rectt, "Data Table"); m_datatableNames.onAddCallback = (list) => { DataTableName dataTable = new DataTableName(); dataTable.IsOn = false; dataTable.Name = ""; DataTableEditorConfig.GetConfig().DataTableNamesList.Add(dataTable); }; } }
void OnGUI() { //居中样式 fontStyle.alignment = TextAnchor.MiddleCenter; titleStyle.alignment = TextAnchor.MiddleCenter; fontStyle.fontSize = 10; titleStyle.fontSize = 20; GUILayout.Space(30); GUILayout.BeginHorizontal(); GUILayout.Label(DataTableEditorConfig.GetConfig().MainTitle, titleStyle); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(DataTableEditorConfig.GetConfig().SubTitle, fontStyle); GUILayout.EndHorizontal(); GUILayout.Space(30); //按钮 if (GUILayout.Button(DataTableEditorConfig.GetConfig().New, GUILayout.Height(50))) { CreateDataTable(); } if (GUILayout.Button(DataTableEditorConfig.GetConfig().Load, GUILayout.Height(50))) { OpenDataTable(); } if (GUILayout.Button(DataTableEditorConfig.GetConfig().Setting, GUILayout.Height(50))) { this.Close(); DataTableEditorSettingWindow.OpenWindow(this.position.position); } if (GUILayout.Button(DataTableEditorConfig.GetConfig().Generate, GUILayout.Height(50))) { this.Close(); DataTableGenerateWindow.OpenWindow(this.position.position); } GUILayout.Space(60); GUILayout.BeginHorizontal(); GUILayout.Label("Author:Jrimmmmmrz", fontStyle); GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginHorizontal(); GUILayout.Label(DataTableEditorConfig.GetConfig().Verision, fontStyle); GUILayout.EndHorizontal(); GUILayout.Space(5); }
public static DataTableEditorConfig GetConfig() { config = Resources.Load <DataTableEditorConfig>(LanguageFlags[DefaultLanguage]); if (config == null) { throw new System.Exception("Config is missing , create a new one."); } return(config); }
/// <summary> /// 设置数据 /// </summary> private static void SetProcessorData() { DataTableProcessor.NameRow = DataTableEditorConfig.SetData("IDNameRow", m_datatableIDNameRow); DataTableProcessor.TypeRow = DataTableEditorConfig.SetData("IDTypeRow", m_datatableIDTypeRow); DataTableProcessor.CommentRow = DataTableEditorConfig.SetData("CommentRow", m_datatableCommentRow); DataTableProcessor.ContentStartRow = DataTableEditorConfig.SetData("CommentStartRow", m_datatableCommentStartRow); DataTableProcessor.IdColumn = DataTableEditorConfig.SetData("Column", m_datatableIdColumn); DataTableGenerator.DataTablePath = DataTableEditorConfig.SetData("Path", m_datatablePath); DataTableGenerator.CSharpCodePath = DataTableEditorConfig.SetData("CSharpCodePath", m_CSharpCodePath); DataTableGenerator.CSharpCodeTemplateFileName = DataTableEditorConfig.SetData("CSharpCodeTemplateFileName", m_CSharpCodeTemplateFileName); DataTableGenerator.NameSpace = DataTableEditorConfig.SetData("Namespace", m_namespace); }
private void OnGUI() { GUILayout.Space(10); CheckNull(); m_datatableNames.DoLayoutList(); GUILayout.Space(10); if (GUILayout.Button(DataTableEditorConfig.GetConfig().Generate, GUILayout.Height(50))) { DataTableGeneratorMenu.GenerateDataTables(DataTableEditorConfig.GetConfig().DataTableNamesList); } if (GUILayout.Button(DataTableEditorConfig.GetConfig().Back, GUILayout.Height(50))) { this.Close(); DataTableEditorLaunchWindow.OpenWindow(this.position.position); } }
private void OnGUI() { GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label(DataTableEditorConfig.GetConfig().IDNameRow, GUILayout.Width(120)); m_datatableIDNameRow = EditorGUILayout.IntField(m_datatableIDNameRow, GUILayout.Width(60)); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label(DataTableEditorConfig.GetConfig().IDTypeRow, GUILayout.Width(120)); m_datatableIDTypeRow = EditorGUILayout.IntField(m_datatableIDTypeRow, GUILayout.Width(60)); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label(DataTableEditorConfig.GetConfig().CommentRow, GUILayout.Width(120)); m_datatableCommentRow = EditorGUILayout.IntField(m_datatableCommentRow, GUILayout.Width(60)); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label(DataTableEditorConfig.GetConfig().ContentStartRow, GUILayout.Width(120)); m_datatableCommentStartRow = EditorGUILayout.IntField(m_datatableCommentStartRow, GUILayout.Width(60)); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label(DataTableEditorConfig.GetConfig().IDColumn, GUILayout.Width(120)); m_datatableIdColumn = EditorGUILayout.IntField(m_datatableIdColumn, GUILayout.Width(60)); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label(DataTableEditorConfig.GetConfig().Language, GUILayout.Width(120)); DataTableEditorConfig.DefaultLanguage = EditorGUILayout.Popup(DataTableEditorConfig.DefaultLanguage, DataTableEditorConfig.LanguageFlags); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); m_namespace = EditorGUILayout.TextField(DataTableEditorConfig.GetConfig().NameSpace, m_namespace); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); m_datatablePath = EditorGUILayout.TextField(DataTableEditorConfig.GetConfig().DataTablePath, m_datatablePath); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); m_CSharpCodePath = EditorGUILayout.TextField(DataTableEditorConfig.GetConfig().CSharpCodePath, m_CSharpCodePath); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); m_CSharpCodeTemplateFileName = EditorGUILayout.TextField(DataTableEditorConfig.GetConfig().CSharpCodeTemplateFileName, m_CSharpCodeTemplateFileName); GUILayout.EndHorizontal(); GUILayout.Space(10); if (GUILayout.Button(DataTableEditorConfig.GetConfig().Apply, GUILayout.Height(50))) { DataTableEditorLaunchWindow.OpenWindow(this.position.position); SetProcessorData(); this.Close(); } if (GUILayout.Button(DataTableEditorConfig.GetConfig().Back, GUILayout.Height(50))) { DataTableEditorLaunchWindow.OpenWindow(this.position.position); this.Close(); } }
/// <summary> /// 打开设置窗口 /// </summary> /// <param name="position">窗口位置</param> public static void OpenWindow(Vector2 position) { GetProcessorData(); Rect rect = new Rect(DataTableEditorLaunchWindow.WindowRect); rect.position = position; var window = DataTableEditorSettingWindow.GetWindowWithRect <DataTableEditorSettingWindow>(rect, true, DataTableEditorConfig.GetConfig().Setting); window.minSize = windowSize; window.maxSize = windowSize; window.position = rect; window.ShowUtility(); }
/// <summary> /// 打开生成窗口 /// </summary> /// <param name="position">窗口位置</param> public static void OpenWindow(Vector2 position) { Rect rect = new Rect(DataTableEditorLaunchWindow.WindowRect); rect.position = position; var window = DataTableGenerateWindow.GetWindowWithRect <DataTableGenerateWindow>(DataTableEditorLaunchWindow.WindowRect, true, DataTableEditorConfig.GetConfig().WindowTitle); window.minSize = windowSize; window.maxSize = windowSize; window.position = rect; window.ShowUtility(); }
private void OnGUI() { for (int i = 0; i < rows.Count; i++) { GUILayout.BeginHorizontal(); for (int j = 0; j < rows[i].RowData.Count; j++) { rows[i].RowData[j] = GUILayout.TextField(rows[i].RowData[j], GUILayout.Width(TextFieldWidth), GUILayout.Height(TextFieldHeight)); } GUILayout.EndHorizontal(); } //添加列按钮 GUILayout.BeginHorizontal(); if (GUILayout.Button(DataTableEditorConfig.GetConfig().AddColumn, GUILayout.Height(50))) { for (int i = 0; i < rows.Count; i++) { rows[i].RowData.Add(""); } ReOpenWindow(); } if (GUILayout.Button(DataTableEditorConfig.GetConfig().RemoveColumn, GUILayout.Height(50))) { for (int i = 0; i < rows.Count; i++) { rows[i].RowData.RemoveAt(rows[i].RowData.Count - 1); } ReOpenWindow(); } GUILayout.EndHorizontal(); //添加行按钮 GUILayout.BeginHorizontal(); if (GUILayout.Button(DataTableEditorConfig.GetConfig().AddRow, GUILayout.Height(50))) { Row row = new Row(); for (int i = 0; i < rows[0].RowData.Count; i++) { row.RowData.Add(""); } rows.Add(row); ReOpenWindow(); } if (GUILayout.Button(DataTableEditorConfig.GetConfig().RemoveRow, GUILayout.Height(50))) { rows.RemoveAt(rows.Count - 1); ReOpenWindow(); } GUILayout.EndHorizontal(); if (GUILayout.Button(DataTableEditorConfig.GetConfig().Apply, GUILayout.Height(50))) { this.Close(); DataTableEditorLaunchWindow.OpenWindow(this.position.position); SaveDataTable(); } if (GUILayout.Button(DataTableEditorConfig.GetConfig().Back, GUILayout.Height(50))) { this.Close(); DataTableEditorLaunchWindow.OpenWindow(this.position.position); } }
public static void OpenWindow() { WindowRect = new Rect((Screen.currentResolution.width / 2) - (windowSize.x / 2), (Screen.currentResolution.height / 2) - (windowSize.y / 2), windowSize.x, windowSize.y); var window = DataTableEditorLaunchWindow.GetWindowWithRect <DataTableEditorLaunchWindow>(WindowRect, true, DataTableEditorConfig.GetConfig().WindowTitle); window.minSize = windowSize; window.maxSize = windowSize; window.ShowUtility(); }
/// <summary> /// 用于刷新窗口 /// </summary> /// <param name="position">位置</param> public static void OpenWindow(Vector2 position) { Rect rect = new Rect(DataTableEditorLaunchWindow.WindowRect); rect.position = position; var window = DataTableEditorWindow.GetWindowWithRect <DataTableEditorWindow>(rect, true, DataTableEditorConfig.GetConfig().WindowTitle); window.position = rect; window.minSize = new Vector2(rows[0].RowData.Count * (TextFieldWidth + 4) + 5, rows.Count * (TextFieldHeight + 2) + 215); window.maxSize = new Vector2(rows[0].RowData.Count * (TextFieldWidth + 4) + 5, rows.Count * (TextFieldHeight + 2) + 215); window.ShowUtility(); }
/// <summary> /// 打开编辑窗口 /// </summary> /// <param name="fileName">文件名</param> /// <param name="position">位置</param> public static void OpenWindow(string fileName, Vector2 position) { m_fileName = fileName; m_tableProcessor = DataTableGenerator.CreateDataTableProcessor(fileName); if (!DataTableGenerator.CheckRawData(m_tableProcessor, fileName)) { Debug.LogError(Utility.Text.Format("Check raw data failure. DataTableName='{0}'", fileName)); return; } LoadDataTable(); Rect rect = new Rect(DataTableEditorLaunchWindow.WindowRect); rect.position = position; var window = DataTableEditorWindow.GetWindowWithRect <DataTableEditorWindow>(rect, true, DataTableEditorConfig.GetConfig().WindowTitle); window.position = rect; window.minSize = new Vector2(m_tableProcessor.RawColumnCount * (TextFieldWidth + 4) + 5, m_tableProcessor.RawRowCount * (TextFieldHeight + 2) + 215); window.maxSize = new Vector2(m_tableProcessor.RawColumnCount * (TextFieldWidth + 4) + 5, m_tableProcessor.RawRowCount * (TextFieldHeight + 2) + 215); window.ShowUtility(); }