void AddLanguageModelGUI() { GeneralDataModificationWindow.OpenWindow(this, "新增模块", "", (value) => { value = EditorDrawGUIUtil.DrawBaseValue("模块名", value); string tempName = value.ToString(); EditorGUILayout.HelpBox("下划线分割文件夹,如:AA_BB_CC", MessageType.Info); if (string.IsNullOrEmpty(tempName)) EditorGUILayout.HelpBox("名字不能为空", MessageType.Error); if (s_languageFullKeyFileNameList.Contains(tempName.Replace('_','/'))) EditorGUILayout.HelpBox("名字重复", MessageType.Error); return value; }, (value) => { string tempName = value.ToString(); if (string.IsNullOrEmpty(tempName)) return false; if (s_languageFullKeyFileNameList.Contains(tempName.Replace('_', '/'))) return false; return true; }, (value) => { string fileName = value.ToString(); CreateNewFile(fileName, null); string tempContent = fileName.Replace('_', '/'); selectFullFileName = tempContent; //SaveData(); Init(); }); }
void AddLanguageModelGUI() { GeneralDataModificationWindow.OpenWindow(this, "新增模块", "", (value) => { value = EditorDrawGUIUtil.DrawBaseValue("模块名", value); if (string.IsNullOrEmpty(value.ToString())) { EditorGUILayout.HelpBox("名字不能为空", MessageType.Error); } if (s_languageKeyDict.ContainsKey(value.ToString())) { EditorGUILayout.HelpBox("名字重复", MessageType.Error); } return(value); }, (value) => { if (string.IsNullOrEmpty(value.ToString())) { return(false); } if (s_languageKeyDict.ContainsKey(value.ToString())) { return(false); } return(true); }, (value) => { CreateNewFile(value.ToString(), null); }); }
private object DrawTextureGUI(string text, object value) { if (editTextureValue != null) { value = editTextureValue; editTextureValue = null; } GUILayout.BeginHorizontal(); value = EditorDrawGUIUtil.DrawBaseValue(text, value); if (GUILayout.Button("o", GUILayout.Width(20))) { ObjectSelectorWindow.Show(GeneralDataModificationWindow.GetInstance(), value.ToString(), new string[] { "Assets/Resources" }, typeof(GameObject), (assetName, obj) => { editTextureValue = assetName; } ); } GUILayout.EndHorizontal(); string content = value.ToString(); bool isHave = false; try { ResourcesConfigManager.Initialize(); if (ResourcesConfigManager.GetIsExitRes(content)) { Texture2D obj = ResourceManager.Load <Texture2D>(content); if (obj) { if (obj != previewTex) { previewEditor1 = Editor.CreateEditor(obj); previewTex = obj; } previewEditor1.OnPreviewGUI(GUILayoutUtility.GetRect(300, 300), EditorStyles.helpBox); isHave = true; } } } catch { } if (!isHave) { EditorGUILayout.HelpBox("没有图片 [" + value + "] !!", MessageType.Error); } return(value); }
void ChooseFile() { GUILayout.BeginHorizontal(); chooseFileName = EditorDrawGUIUtil.DrawPopup("选择文件", chooseFileName, m_dataNameList, LoadData); if (GUILayout.Button("删除", GUILayout.Width(50))) { if (EditorUtility.DisplayDialog("警告", "是否删除文件[" + chooseFileName + "]", "确定", "取消")) { File.Delete(Application.dataPath + "/Resources/" + DataManager.c_directoryName + "/" + chooseFileName + ".txt"); AssetDatabase.Refresh(); m_currentData = null; return; } } if (GUILayout.Button("添加", GUILayout.Width(50))) { GeneralDataModificationWindow.otherParameter = ""; GeneralDataModificationWindow.OpenWindow(this, "添加新配置文件", "", (value) => { value = EditorDrawGUIUtil.DrawBaseValue("新建配置文件:", value); GeneralDataModificationWindow.otherParameter = EditorDrawGUIUtil.DrawBaseValue("主键名:", GeneralDataModificationWindow.otherParameter); if (string.IsNullOrEmpty(value.ToString()) || string.IsNullOrEmpty(GeneralDataModificationWindow.otherParameter.ToString())) { EditorGUILayout.HelpBox("文件名不能为空!!", MessageType.Error); } return(value); }, (value) => { if (string.IsNullOrEmpty(value.ToString()) || string.IsNullOrEmpty(GeneralDataModificationWindow.otherParameter.ToString())) { return(false); } else { return(true); } }, (value) => { DataTable data = new DataTable(); data.TableKeys.Add(GeneralDataModificationWindow.otherParameter.ToString()); SaveData(value.ToString(), data); AssetDatabase.Refresh(); LoadData(chooseFileName); AssetDatabase.Refresh(); }); } GUILayout.EndHorizontal(); }
/// <summary> /// 打开窗口 /// </summary> /// <param name="title">标题</param> /// <param name="value">希望修改的数据</param> /// <param name="customDrawGUI">自定义GUI绘制</param> /// <param name="checkCanOkButtonCallBack">检查是否能使用"OK"按钮</param> /// <param name="modificationCompleteCallBack">完成修改回调</param> public static void OpenWindow(EditorWindow otherWindow, string title, object value, CallBackR <object, object> customDrawGUI, CallBackR <bool, object> checkCanOkButtonCallBack, CallBack <object> modificationCompleteCallBack) { win = GetWindow <GeneralDataModificationWindow>(); win.wantsMouseMove = true; win.autoRepaintOnSceneChange = true; win.otherWindow = otherWindow; FocusWindowIfItsOpen <GeneralDataModificationWindow>(); win.m_Title = title; //win.value = value; win.modifi_Value = value;//.DeepCopySelf(); win.customDrawGUI = customDrawGUI; win.modificationCompleteCallBack = modificationCompleteCallBack; win.checkCanOkButtonCallBack = checkCanOkButtonCallBack; }
/// <summary> /// 添加一行数据 /// </summary> private void AddLineDataGUI() { GeneralDataModificationWindow.OpenWindow(this, "插入一行数据", "", (value) => { value = EditorDrawGUIUtil.DrawBaseValue("Key:", value); if (string.IsNullOrEmpty(value.ToString())) { EditorGUILayout.HelpBox("Key不能为空!!", MessageType.Error); } else if (m_currentData.TableKeys.Contains(value.ToString())) { EditorGUILayout.HelpBox("Key重复!!", MessageType.Error); } return(value); }, (value) => { if (string.IsNullOrEmpty(value.ToString()) || m_currentData.TableKeys.Contains(value.ToString())) { return(false); } return(true); }, (value) => { heightItemList.Add(30); SingleData data = new SingleData(); DataTable table = m_currentData; List <string> keys = table.TableKeys; for (int i = 0; i < keys.Count; i++) { string keyTmp = keys[i]; if (i == 0) { data.Add(keyTmp, value.ToString()); } else { data.Add(keyTmp, table.m_defaultValue[keyTmp]); } } m_currentData.AddData(data); }); }
void AddLanguageGUI() { if (GUILayout.Button("新增语言")) { GeneralDataModificationWindow.OpenWindow(this, "新增语言", SystemLanguage.Afrikaans, (value) => { SystemLanguage lan = (SystemLanguage)value; lan = (SystemLanguage)EditorDrawGUIUtil.DrawBaseValue("语言:", lan); if (config != null && config.gameExistLanguages.Contains(lan)) { EditorGUILayout.HelpBox("已存在", MessageType.Error); } if (lan == SystemLanguage.Chinese) { lan = SystemLanguage.ChineseSimplified; } if (lan == SystemLanguage.Unknown) { lan = SystemLanguage.ChineseSimplified; } return(lan); }, (value) => { SystemLanguage lan = (SystemLanguage)value; if (config != null && config.gameExistLanguages.Contains(lan)) { return(false); } return(true); }, (value) => { if (config == null) { config = new LanguageSettingConfig(); } SystemLanguage lan = (SystemLanguage)value; config.gameExistLanguages.Add(lan); CreateNewLangusge(lan); } ); } }
/// <summary> /// 添加一个字段 /// </summary> private void Add2FieldGUI() { GeneralDataModificationWindow.OpenWindow(this, "添加字段", new TableConfigFieldInfo(), (value) => { TableConfigFieldInfo info = (TableConfigFieldInfo)value; DrawTableConfigFieldInfo(info); if (string.IsNullOrEmpty(info.fieldName)) { EditorGUILayout.HelpBox("字段名不能为空!!", MessageType.Error); } else if (m_currentData.TableKeys.Contains(info.fieldName)) { EditorGUILayout.HelpBox("字段名重复!!", MessageType.Error); } string df = DataConfigUtils.ObjectValue2TableString(info.defultValue); if (string.IsNullOrEmpty(df)) { EditorGUILayout.HelpBox("默认值不能为空!!", MessageType.Error); } return(value); }, (value) => { TableConfigFieldInfo info = (TableConfigFieldInfo)value; if (string.IsNullOrEmpty(info.fieldName) || m_currentData.TableKeys.Contains(info.fieldName)) { return(false); } string df = DataConfigUtils.ObjectValue2TableString(info.defultValue); if (string.IsNullOrEmpty(df)) { return(false); } return(true); }, (value) => { TableConfigFieldInfo info = (TableConfigFieldInfo)value; AddField(m_currentData, info); withItemList.Add(wWith); }); }
void AddLanguageModelGUI() { GeneralDataModificationWindow.OpenWindow(this, "新增模块", "", (value) => { value = EditorDrawGUIUtil.DrawBaseValue("模块名", value); if (string.IsNullOrEmpty(value.ToString())) { EditorGUILayout.HelpBox("名字不能为空", MessageType.Error); } if (s_languageKeyDict.ContainsKey(value.ToString())) { EditorGUILayout.HelpBox("名字重复", MessageType.Error); } return(value); }, (value) => { if (string.IsNullOrEmpty(value.ToString())) { return(false); } if (s_languageKeyDict.ContainsKey(value.ToString())) { return(false); } return(true); }, (value) => { selectEditorModuleName = value.ToString(); s_languageKeyDict.Add(value.ToString(), new List <string>()); DataTable data = new DataTable(); data.TableKeys.Add(LanguageManager.c_mainKey); data.TableKeys.Add(LanguageManager.c_valueKey); data.SetDefault(LanguageManager.c_valueKey, "NoValue"); m_langeuageDataDict.Add(selectEditorModuleName, data); SaveData(); OnEnable(); }); }
/// <summary> /// 绘制每个数据格子 /// </summary> /// <param name="startPos"></param> private void DrawGridItem(Vector2 startPos) { helpBoxStyle.fontSize = nowButtonFontSize; float tempHeight = 0; for (int i = 0; i < heightItemList.Count; i++) { float h = heightItemList[i]; float tempWith = 0; for (int j = 0; j < withItemList.Count; j++) { float w = withItemList[j]; Vector2 size = new Vector2(w, h); Vector2 pos = startPos + new Vector2(tempWith, tempHeight); object value = null; string showStr = ""; string field = m_currentData.TableKeys[j]; FieldType fieldValueType = GetFieldType(j, field); string enumType = GetEnumType(fieldValueType, field); string defaultValue = GetDefaultValue(fieldValueType, enumType, field); if (i == 0) { GUI.color = Color.yellow; showStr = EditorDrawGUIUtil.GetFormatName(field, DataConfigUtils.ConfigFieldValueType2Type(fieldValueType, enumType), "red"); } else if (i == 1) { GUI.color = Color.cyan; showStr = GetDescription(field); } else if (i == 2) { GUI.color = Color.green; showStr = defaultValue; } else { SingleData data = m_currentData[m_currentData.TableIDs[i - 3]]; bool isDefault = false; if (data.ContainsKey(field) && data[field] != defaultValue) { DataFieldAssetType fieldAssetType = GetDataFieldAssetType(field); if (fieldAssetType == DataFieldAssetType.LocalizedLanguage) { string k = data[field]; if (LanguageManager.HaveKey(k)) { showStr = LanguageManager.GetContentByKey(k); } else { showStr = k; } } else { showStr = data[field]; } } else { showStr = defaultValue; isDefault = true; } if (!string.IsNullOrEmpty(searchValue)) { showStr = ShowContainsChar(showStr, searchValue); } if (isDefault) { showStr = "<color=green>" + showStr + "</color>"; } } if (i == 1 || i == 2) { GUI.Button(new Rect(pos, size), showStr, helpBoxStyle); } else { if (selectColumnIndexs.Contains(j)) { GUI.color = Color.magenta; } if (selectRowIndexs.Contains(i)) { GUI.color = Color.cyan; } if (GUI.Button(new Rect(pos, size), showStr, helpBoxStyle)) { modifiIndex = new Vector2Int(i - 2, j); if (i == 0) { TableConfigFieldInfo f = new TableConfigFieldInfo(); f.fieldName = field; f.description = m_currentData.m_noteValue.ContainsKey(field) ? m_currentData.m_noteValue[field] : ""; f.fieldValueType = fieldValueType; f.defultValue = DataConfigUtils.TableString2ObjectValue(defaultValue, fieldValueType, enumType); f.enumType = enumType; f.fieldAssetType = GetDataFieldAssetType(field); value = f; } else { SingleData data = m_currentData[m_currentData.TableIDs[i - 3]]; if (data.ContainsKey(field)) { defaultValue = data[field]; } value = DataConfigUtils.TableString2ObjectValue(defaultValue, fieldValueType, enumType); } GeneralDataModificationWindow.OpenWindow(this, "修改数据", value, DrawModifiValueGUI, CheckModifiValueCallBack, ModificationCompleteCallBack); } } GUI.color = Color.white; tempWith += w; } tempHeight += h; } helpBoxStyle.fontSize = oldButtonFontSize; }