protected override void RenderExtensionButton(CodeGen item) { string errorInfo = string.Empty; if (string.IsNullOrEmpty(item.EditorName)) { errorInfo = "Editor Name Is Empty"; } else if (string.IsNullOrEmpty(item.SubType)) { errorInfo = "SubType Is Empty"; } if (string.IsNullOrEmpty(errorInfo)) { //设置导出路径 string export_folder = string.Format(@"{0}/Editor/Export/", Application.dataPath); if (!Directory.Exists(export_folder)) { Directory.CreateDirectory(export_folder); } //检测代码是否已存在 string path = string.Format("{0}{1}.cs", export_folder, item.EditorName); string disPlay = Language.Build; if (File.Exists(path)) { GUI.color = Color.green; disPlay = Language.ReBuild; } if (GUILayout.Button(disPlay, new GUILayoutOption[] { GUILayout.Width(currentEditorSetting.ExtensionHeadTagWith) })) { WriteFile(item, path); } GUI.color = Color.white; } else { if (GUILayout.Button(EditorGUIStyle.LoadEditorResource <Texture2D>("warning.png"), new GUILayoutOption[] { GUILayout.Width(currentEditorSetting.ExtensionHeadTagWith), GUILayout.Height(18) })) { ShowNotification(new GUIContent(errorInfo)); } } }
/// <summary> /// 处理表头 /// </summary> protected virtual void RenderHead() { GUILayout.BeginScrollView(new Vector2(posv.x, 0), false, false, GUIStyle.none, GUIStyle.none, new GUILayoutOption[] { GUILayout.Height(Data.currentEditorSetting.TableHeadHeight) }); GUILayout.BeginHorizontal(EditorGUIStyle.GetGroupBoxStyle(), new GUILayoutOption[] { GUILayout.Width(position.width) }); //TODO Set Order foreach (var item in Data.CurrentClassFieldsCache) { if (GUILayout.Button( string.IsNullOrEmpty(item.config_editor_setting.Display) ? item.field_info.Name : item.config_editor_setting.Display, EditorGUIStyle.GetTagButtonStyle(), new GUILayoutOption[] { GUILayout.Width(GetResizeWidth(item.config_editor_setting.Width, item.config_editor_setting.MaxWidth)) })) { HeadButton_Click(item.field_info.Name); } GUILayout.Space(Data.currentEditorSetting.ColumnSpan); } RenderExtensionHead(); if (current_windowType == WindowType.CALLBACK) { GUILayout.Label(Language.Select, EditorGUIStyle.GetTagButtonStyle(), GUILayout.Width(Data.currentEditorSetting.ExtensionHeadTagWith)); } else if (current_windowType == WindowType.INPUT) { GUILayout.Label(Language.Operation, EditorGUIStyle.GetTagButtonStyle(), GUILayout.Width(Data.currentEditorSetting.ExtensionHeadTagWith)); } else { GUILayout.Label(Language.Operation, EditorGUIStyle.GetTagButtonStyle(), GUILayout.Width(Data.currentEditorSetting.ExtensionHeadTagWith)); } GUILayout.EndHorizontal(); GUILayout.EndScrollView(); }
protected override void RenderExtensionButton(CodeGen item) { string error = VerfiyLineData(item, false); if (string.IsNullOrEmpty(error)) { string export_path = PathMapping.GetInstance().DecodePath(item.CodeExportPath); if (!Directory.Exists(export_path)) { Directory.CreateDirectory(export_path); } //检测代码是否已存在 string path = Path.Combine(export_path, string.Format("{0}Export.cs", item.ClassType)); string disPlay = Language.Build; if (File.Exists(path)) { GUI.color = Color.green; disPlay = Language.ReBuild; } if (GUILayout.Button(disPlay, new GUILayoutOption[] { GUILayout.Width(currentEditorSetting.ExtensionHeadTagWith) })) { WriteFile(item, path); } GUI.color = Color.white; } else { if (GUILayout.Button(EditorGUIStyle.LoadEditorResource <Texture2D>("warning.png"), new GUILayoutOption[] { GUILayout.Width(currentEditorSetting.ExtensionHeadTagWith), GUILayout.Height(18) })) { ShowNotification(new GUIContent(error)); } } }
protected override void RenderExtensionHead() { GUILayout.Label("GenCode", EditorGUIStyle.GetTagButtonStyle(), new GUILayoutOption[] { GUILayout.Width(currentEditorSetting.ExtensionHeadTagWith) }); }
/// <summary> /// 设置基础的控件 /// </summary> /// <param name="width"></param> /// <param name="enable"></param> /// <param name="value"></param> /// <param name="setValue"></param> public virtual void RenderBaseControl(int width, bool enable, object value, Action <object> setValue) { if (value is Enum) { if (enable) { value = EditorGUILayout.EnumPopup(value as Enum, new GUILayoutOption[] { GUILayout.Width(width) }); setValue(value); } else { EditorGUILayout.LabelField((value as Enum).ToString(), new GUILayoutOption[] { GUILayout.Width(width) }); } } else if (value is Bounds) { if (enable) { value = EditorGUILayout.BoundsField((Bounds)value, new GUILayoutOption[] { GUILayout.Width(width) }); setValue(value); } else { EditorGUILayout.BoundsField((Bounds)value, new GUILayoutOption[] { GUILayout.Width(width) }); } } else if (value is Color) { if (enable) { value = EditorGUILayout.ColorField((Color)value, new GUILayoutOption[] { GUILayout.Width(width) }); setValue(value); } else { EditorGUILayout.ColorField((Color)value, new GUILayoutOption[] { GUILayout.Width(width) }); } } else if (value is AnimationCurve) { if (enable) { value = EditorGUILayout.CurveField((AnimationCurve)value, new GUILayoutOption[] { GUILayout.Width(width) }); setValue(value); } else { EditorGUILayout.CurveField((AnimationCurve)value, new GUILayoutOption[] { GUILayout.Width(width) }); } } else if (value is string) { if (enable) { value = EditorGUILayout.TextField(value as string, new GUILayoutOption[] { GUILayout.Width(width) }); setValue(value); } else { EditorGUILayout.LabelField(value as string, new GUILayoutOption[] { GUILayout.Width(width) }); } } else if (value is float) { if (enable) { value = EditorGUILayout.FloatField((float)value, new GUILayoutOption[] { GUILayout.Width(width) }); setValue(value); } else { EditorGUILayout.LabelField(value as string, new GUILayoutOption[] { GUILayout.Width(width) }); } } else if (value is int) { if (enable) { value = EditorGUILayout.IntField((int)value, new GUILayoutOption[] { GUILayout.Width(width) }); setValue(value); } else { EditorGUILayout.LabelField(value as string, new GUILayoutOption[] { GUILayout.Width(width) }); } } else if (value is bool) { if (enable) { value = EditorGUILayout.Toggle((bool)value, EditorGUIStyle.GetTogleStyle(), new GUILayoutOption[] { GUILayout.Width(width) }); setValue(value); } else { EditorGUILayout.LabelField(((bool)value).ToString(), new GUILayoutOption[] { GUILayout.Width(width) }); } } else if (value is Vector2) { if (enable) { value = EditorGUILayout.Vector2Field("", (Vector2)value, new GUILayoutOption[] { GUILayout.Width(width) }); setValue(value); } else { EditorGUILayout.Vector2Field("", (Vector2)value, new GUILayoutOption[] { GUILayout.Width(width) }); } } else if (value is Vector3) { if (enable) { value = EditorGUILayout.Vector3Field("", (Vector3)value, new GUILayoutOption[] { GUILayout.Width(width) }); setValue(value); } else { EditorGUILayout.Vector3Field("", (Vector3)value, new GUILayoutOption[] { GUILayout.Width(width) }); } } else if (value is Vector4) { if (enable) { value = EditorGUILayout.Vector4Field("", (Vector4)value, new GUILayoutOption[] { GUILayout.Width(width) }); setValue(value); } else { EditorGUILayout.Vector4Field("", (Vector4)value, new GUILayoutOption[] { GUILayout.Width(width) }); } } }
/// <summary> /// 处理表主体 /// </summary> protected virtual void RenderTable() { posv = GUILayout.BeginScrollView(posv, false, false, EditorGUIStyle.GetHorizontalScrollbarStyle(), GUIStyle.none, EditorGUIStyle.GetTableGroupBoxStyle()); if (!string.IsNullOrEmpty(Data.currentEditorSetting.SearchResourceName)) { Data.currentEditorSetting.ItemMaxCount = Data.LinesCache.Count(x => x.SearchKey.ToLower().Contains(Data.currentEditorSetting.SearchResourceName.ToLower().Trim())); Finallylist = Data.LinesCache .Where(x => x.SearchKey.ToLower().Contains(Data.currentEditorSetting.SearchResourceName.ToLower().Trim())) .Skip(Data.currentEditorSetting.PageIndex * Data.currentEditorSetting.PageAmount) .Take(Data.currentEditorSetting.PageAmount).ToList(); } else { Data.currentEditorSetting.ItemMaxCount = Data.LinesCache.Count; Finallylist = Data.LinesCache .Skip(Data.currentEditorSetting.PageIndex * Data.currentEditorSetting.PageAmount) .Take(Data.currentEditorSetting.PageAmount).ToList(); } //遍历搜索结果 for (int i = 0; i < Finallylist.Count; i++) { var lineData = Finallylist[i]; if (deleteList.Contains(lineData.HashCode)) { continue; } //Select effect diaplay if (current_windowType == WindowType.CALLBACK && SelectDisplayEffectList.Contains(lineData.HashCode)) { GUI.backgroundColor = Color.green; } else { GUI.backgroundColor = Color.white; } GUILayout.BeginHorizontal(EditorGUIStyle.GetGroupBoxStyle()); foreach (var column in lineData.ColumnInfo) { if (ErrorLine.Contains(lineData.HashCode)) { GUI.color = Color.red; } RenderRawColumn(column, lineData); GUI.color = Color.white; GUILayout.Space(Data.currentEditorSetting.ColumnSpan); } RenderExtensionButton(lineData.RawData); GUILayout.Space(Data.currentEditorSetting.ColumnSpan); RenderFunctionButton(lineData.RawData); GUILayout.Space(Data.currentEditorSetting.ColumnSpan); GUILayout.EndHorizontal(); GUILayout.Space(5); } GUILayout.Space(15); GUILayout.EndScrollView(); }
/// <summary> /// 分页算法 /// </summary> protected virtual void Page() { GUILayout.BeginHorizontal(EditorGUIStyle.GetGroupBoxStyle(), new GUILayoutOption[] { GUILayout.Width(position.width) }); int maxIndex = Mathf.FloorToInt((Data.currentEditorSetting.ItemMaxCount - 1) / (float)Data.currentEditorSetting.PageAmount); if (maxIndex < Data.currentEditorSetting.PageIndex) { Data.currentEditorSetting.PageIndex = 0; } GUILayout.Label(string.Format(Language.PageInfoFormate, Data.currentEditorSetting.PageIndex + 1, maxIndex + 1), GUILayout.Width(100)); GUILayout.Label(Language.OnePageMaxNumber, EditorGUIStyle.GetPageLabelGuiStyle(), GUILayout.Width(80)); int.TryParse(GUILayout.TextField(Data.currentEditorSetting.PageAmount.ToString(), GUILayout.Width(40)), out Data.currentEditorSetting.PageAmount); if (GUILayout.Button(Language.Jump, EditorGUIStyle.GetJumpButtonGuiStyle(), GUILayout.Width(40))) { if (jumpTo - 1 < 0) { jumpTo = 0; } if (jumpTo - 1 > maxIndex) { jumpTo = maxIndex; } Data.currentEditorSetting.PageIndex = jumpTo - 1; } jumpTo = EditorGUILayout.IntField(jumpTo, GUILayout.Width(40)); if (GUILayout.Button(Language.Previous, GUI.skin.GetStyle("ButtonLeft"), GUILayout.Height(16))) { if (Data.currentEditorSetting.PageIndex - 1 < 0) { Data.currentEditorSetting.PageIndex = 0; } else { Data.currentEditorSetting.PageIndex -= 1; } } if (GUILayout.Button(Language.Next, GUI.skin.GetStyle("ButtonRight"), GUILayout.Height(16))) { if (Data.currentEditorSetting.PageIndex + 1 > maxIndex) { Data.currentEditorSetting.PageIndex = maxIndex; } else { Data.currentEditorSetting.PageIndex++; } } //处理缩放 if (!Data.currentEditorSetting.HideResizeSlider) { Data.currentEditorSetting.Resize = (int)GUILayout.HorizontalSlider(Data.currentEditorSetting.Resize, 1, 5, GUILayout.Width(70)); } GUILayout.EndHorizontal(); }