private void Btn_ChooseColor(MyEnumColor colorEnum, bool isNull = false) { if (isShowLeftTip) { isShowLeftTip = false; go_MouseLeftClick.SetActive(false); switch (go_CurrentSelect.name) { case FLODER_NAME: // 文件夹 GameObject biaoJi = go_CurrentSelect.transform.Find("BiaoJi").gameObject; biaoJi.SetActive(!isNull); if (!isNull) { biaoJi.GetComponent <Image>().color = MyColor.GetColor(colorEnum); Ctrl_DaoRuInfo.Instance.AddBiaoJi(m_CurrentSelectFile.FullName, colorEnum); } else { Ctrl_DaoRuInfo.Instance.RemoveBiaoJi(m_CurrentSelectFile.FullName); } break; } } }
/*-------------------------------Button---------------------------------------------------*/ #region 私有 箭头 private static void JianTuoText(string text, int width, ref bool isShow, MyEnumColor color, Action showAction, Action action, bool isNeedSpace = true) { bool tmp = isShow; MyCreate.Heng(() => { string jianTuo = tmp ? "▼ ".AddSize(10).ToString(): "▶ ".AddSize(10).ToString(); jianTuo += text; string des = jianTuo.AddColor(color, false); MyCreate.Heng(() => { MyCreate.ButtonLabel(des, width, () => { tmp = !tmp; }); if (null != action) { action(); if (isNeedSpace) { MyCreate.AddSpace(); } } }); }); if (tmp && null != showAction) { showAction(); } isShow = tmp; }
/// <summary> /// 单 Class 的按组添加 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="tree"></param> /// <param name="bigStr"></param> /// <param name="subString"></param> /// <param name="color"></param> protected void AddNew <R>(OdinMenuTree tree, string bigStr, string subString, MyEnumColor color = MyEnumColor.Blue) where R : new() { OdinMenuItem item1 = new OdinMenuItem(tree, subString, MyType.NewTypeClass <R>()); item1.TextColor = color; tree.AddMenuItemAtPath(bigStr, item1); }
public TitleAttribute(string title, MyEnumColor color) { Title = title ?? "null"; Subtitle = null; TextColor = color; TitleAlignment = TitleAlignments.Left; HorizontalLine = true; Bold = true; }
public void AddBiaoJi(string path, MyEnumColor color) // 添加标记 { if (pathK_ColorV.ContainsKey(path)) { pathK_ColorV[path] = (ushort)color; } else { pathK_ColorV.Add(path, (ushort)color); } }
} // 底下音频名称 //—————————————————— 标记 —————————————————— public bool GetIsBiaoJi(string path, ref MyEnumColor color) // 获得标记 { foreach (string key in pathK_ColorV.Keys) { if (key == path) { color = (MyEnumColor)pathK_ColorV[key]; return(true); } } return(false); }
public static void FenGeXian(string text, //能点击展示下边的Action ref bool isShow, MyEnumColor color = MyEnumColor.Green) { bool tmp = isShow; string des = isShow ? "▼ ".AddSize(10) + text : "▶ ".AddSize(10) + text; if (GUILayout.Button(des.AddColor(color, false), "BottomLine")) { tmp = !tmp; } ; isShow = tmp; }
public override void OnGUI(Rect position) { string descriptionText = ((MyHeadAttribute)attribute).Description; MyEnumColor color = ((MyHeadAttribute)attribute).TextColor; int offsetX = ((MyHeadAttribute)attribute).OffsetX; position.y += 4f; position.x += offsetX; Color firstColor = GUI.color; GUI.color = MyColor.GetColor(color); MyGUI.Text(position, descriptionText); GUI.color = firstColor; }
public static string AddColor(this string str, MyEnumColor color, bool isAddSpaceLine) { StringBuilder sb = new StringBuilder(); sb.Append("<color="); sb.Append(MyColor.GetColorString(color)); sb.Append(">"); sb.Append(str); sb.Append("</color>"); if (isAddSpaceLine) { sb.AppendLine(); } return(sb.ToString()); }
public static string GetColorString(MyEnumColor enumColor) { string colorStr = ""; switch (enumColor) { case MyEnumColor.White: colorStr = "#ffffffff"; break; case MyEnumColor.Hui: colorStr = "#c0c0c0ff"; break; case MyEnumColor.LightBlue: colorStr = "#add8e6ff"; break; case MyEnumColor.Blue: colorStr = "#00ffffff"; break; case MyEnumColor.Yellow: colorStr = "#ffff00ff"; break; case MyEnumColor.Orange: colorStr = "#ffa500E5"; break; case MyEnumColor.Green: colorStr = "#00ff00E5"; break; case MyEnumColor.LightGreen: colorStr = "#008000E5"; break; case MyEnumColor.Red: colorStr = "#ff0000ff"; break; default: colorStr = "#808000ff"; break; } return(colorStr); }
private static void DoLog(object obj, MyEnumColor color, Object choose = null) { string tmp = (null == obj) ? "null" : obj.ToString(); if (m_IsLog) { if (null != choose) { Debug.Log(tmp.AddColor(color, true), choose); } else { Debug.Log(tmp.AddColor(color, true)); } } }
public static string AddColorAndSize(this string text, MyEnumColor color, int size, bool isAddSpaceLine) { StringBuilder sb = new StringBuilder(); sb.Append("<color="); sb.Append(MyColor.GetColorString(color)); sb.Append(">"); sb.Append("<size="); sb.Append(size); sb.Append(">"); sb.Append(text); sb.Append("</size>"); sb.Append("</color>"); if (isAddSpaceLine) { sb.AppendLine(); } return(sb.ToString()); }
public static bool GetEnumColor(string str, ref MyEnumColor color) { bool res = true; switch (str) { case "red": color = MyEnumColor.Red; break; case "blue": color = MyEnumColor.Blue; break; case "green": color = MyEnumColor.Green; break; case "white": color = MyEnumColor.White; break; case "yellow": color = MyEnumColor.Yellow; break; case "orange": color = MyEnumColor.Orange; break; default: res = false; break; } return(res); }
public static void TextButton(string str1, string buttonText, int jianGe, Action onClick, ref bool isShow, Action showAction, MyEnumColor color) { JianTuoText(str1, jianGe, ref isShow, color, showAction, () => { MyCreate.Button(buttonText, onClick); }); }
public static bool TextBool(string trueStirng, string falseString, bool value, int jianGe, ref bool isShow, Action showAction, MyEnumColor color) { bool tmp = value; JianTuoText(tmp ? trueStirng : falseString, jianGe, ref isShow, color, showAction, () => { tmp = MyCreate.InputBool(tmp); }); return(tmp); }
private Transform AddMiddleButton(FileSystemInfo fileInfo, MiddleButtonType type) // 按分类添加中间按钮 { Transform t; switch (type) { case MiddleButtonType.File: // 文件 t = InstantiateMoBan(moBan_File, t_MiddleGrid, FILE_NAME, true); t.Find("Text").GetComponent <Text>().text = GetShortName(Path.GetFileNameWithoutExtension(fileInfo.FullName)); t.Find("GeiShi/Text").GetComponent <Text>().text = fileInfo.Extension.Substring(1); break; case MiddleButtonType.Folder: // 文件夹 t = InstantiateMoBan(moBan_Folder, t_MiddleGrid, FLODER_NAME, true); t.Find("Text").GetComponent <Text>().text = GetShortName(fileInfo.Name); MyEnumColor biaoJiColor = MyEnumColor.Hui; bool isBiaoJi = Ctrl_DaoRuInfo.Instance.GetIsBiaoJi(fileInfo.FullName, ref biaoJiColor); if (isBiaoJi) { GameObject biaoJi = t.Find("BiaoJi").gameObject; biaoJi.SetActive(true); biaoJi.GetComponent <Image>().color = MyColor.GetColor(biaoJiColor); } break; case MiddleButtonType.Drive: // 磁盘 t = InstantiateMoBan(moBan_YinPan, t_MiddleGrid, YINPAN_NAME, true); string reStr = fileInfo.Name; reStr = reStr.Replace(":\\", " 盘"); t.Find("Text").GetComponent <Text>().text = reStr; break; case MiddleButtonType.Computer: // 我的电脑 t = InstantiateMoBan(moBan_Computer, t_MiddleGrid, COMPUTER_NAME, true); t.Find("Text").GetComponent <Text>().text = "我的电脑"; break; case MiddleButtonType.ZhuoMain: // 桌面 t = InstantiateMoBan(moBan_ZhuoMain, t_MiddleGrid, ZHUOMAIN_NAME, true); t.Find("Text").GetComponent <Text>().text = "桌面"; break; case MiddleButtonType.Music: // 音频文件 t = InstantiateMoBan(moBan_Music, t_MiddleGrid, MUSIC_NAME, true); t.Find("Text").GetComponent <Text>().text = GetShortName(Path.GetFileNameWithoutExtension(fileInfo.FullName)); t.Find("GeiShi/Text").GetComponent <Text>().text = fileInfo.Extension.Substring(1); break; default: throw new Exception("未定义"); } GameObject go = t.gameObject; if (type != MiddleButtonType.File) // 文件加载完图才添加按钮事件 { t.GetComponent <Button>().onClick.AddListener(() => { if (go.Equals(go_CurrentSelect) && isSelect) // 双击 { isSelect = false; switch (go_CurrentSelect.name) { case FLODER_NAME: //双击文件夹 case YINPAN_NAME: //双击硬盘 mFileBrowser.GoInSubDirectory(fileInfo.Name); RefreshMiddleContent(); // 刷新 break; case COMPUTER_NAME: // 双击我的电脑 mFileBrowser.GoToRoot(true); RefreshMiddleContent(); // 刷新 break; case ZHUOMAIN_NAME: // 双击桌面 string Desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); mFileBrowser.RetrieveFiles(new DirectoryInfo(Desktop), true); RefreshMiddleContent(); // 刷新 break; case MUSIC_NAME: //音乐文件 // MyEventCenter.SendEvent(E_GameEvent.ShowMusicInfo, t.Find("Text").GetComponent<Text>(),(FileInfo)fileInfo,true); break; default: throw new Exception("没有定义 —— " + go_CurrentSelect.name); } } else { if (isShowLeftTip) { isShowLeftTip = false; go_MouseLeftClick.SetActive(false); } go_CurrentSelect = go; m_CurrentSelectFile = fileInfo; Ctrl_Coroutine.Instance.StartCoroutine(CheckoubleClick()); } }); } l_MiddleItems.Add(go); return(t); }
private static void JianTuoText2(string text, int width, ref bool isShow, Action showAction, Action action, bool isNeedSpace = true, MyEnumColor color = MyEnumColor.LightBlue) { bool tmp = isShow; string des = isShow ? "▼".AddColorAndSize(color, 10, false) : "▶".AddColorAndSize(color, 10, false); MyCreate.Heng(() => { MyCreate.ButtonLabel(text, width, () => { tmp = !tmp; }); MyCreate.AddSpace(); MyCreate.Heng(() => { MyCreate.ButtonLabel(des, 0, () => { tmp = !tmp; }); MyCreate.Shu(() => { MyCreate.AddSpace(5); if (null != action) { action(); if (isNeedSpace) { MyCreate.AddSpace(); } } }); }); }); if (tmp && null != showAction) { showAction(); } isShow = tmp; }
public static void Text(string str1, ref bool isShow, Action showAction, MyEnumColor color) { JianTuoText(str1, 0, ref isShow, color, showAction, null); }
public static void Text3(string str1, string str2, string str3, int jianGe, ref bool isShow, Action showAction, MyEnumColor color) { bool tmp = isShow; MyCreate.Heng(() => { string des = (tmp ? "▼ ".AddSize(10) + str1 : "▶ ".AddSize(10) + str1).AddColor(color, false); MyCreate.ButtonLabel(des, jianGe, () => { tmp = !tmp; }); MyCreate.Text(str2); MyCreate.AddSpace(); MyCreate.Text(str3); }); if (tmp && null != showAction) { showAction(); } isShow = tmp; }
public MyHeadAttribute(string description) { Description = description; TextColor = MyEnumColor.Green; }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(IPropertyValueEntry <T> entry, EnumToggleButtonsAttribute attribute, GUIContent label) { bool isBiaoTi = attribute.IsBiaoTi; int buttonSize = attribute.ButtonSize; MyEnumColor textColor = attribute.TextColor; var t = entry.WeakValues[0].GetType(); int i = 1; for (; i < entry.WeakValues.Count; i++) { if (t != entry.WeakValues[i].GetType()) { AllEditorGUI.ErrorMessageBox("ToggleEnum does not support multiple different enum types."); return; } } var enumType = entry.TypeOfValue; var context = entry.Property.Context.Get(this, "context", (Context)null); if (context.Value == null) { var enumNames = Enum.GetNames(enumType); context.Value = new Context(); context.Value.Names = enumNames.Select(x => new GUIContent(isBiaoTi ? x.TitleCase_ChinaFormat().AddColor(textColor, false) : x)).ToArray(); context.Value.Values = new ulong[context.Value.Names.Length]; context.Value.IsFlagsEnum = entry.TypeOfValue.IsDefined <FlagsAttribute>(); if (isBiaoTi) { context.Value.NameSizes = new float[context.Value.Names.Length]; for (int j = 0; j < context.Value.NameSizes.Length; j++) { context.Value.NameSizes[j] = buttonSize; } } else { context.Value.NameSizes = context.Value.Names.Select(x => SirenixGUIStyles.ButtonMid.CalcSize(x).x).ToArray(); } context.Value.ColumnCounts = new List <int>() { context.Value.NameSizes.Length }; GUIHelper.RequestRepaint(); i = 0; for (; i < context.Value.Values.Length; i++) { context.Value.Values[i] = TypeExtensions.GetEnumBitmask(Enum.Parse(enumType, enumNames[i]), enumType); } } ulong value = TypeExtensions.GetEnumBitmask(entry.SmartValue, enumType); Rect controlRect = new Rect(); i = 0; for (int j = 0; j < context.Value.ColumnCounts.Count; j++) { var rect = EditorGUILayout.GetControlRect(); if (label != null) { rect = EditorGUI.PrefixLabel(rect, j == 0 ? label : new GUIContent(" ")); } if (j == 0) { controlRect = rect; } var xMax = rect.xMax; rect.width /= context.Value.ColumnCounts[j]; rect.width = (int)rect.width; int from = i; int to = i + context.Value.ColumnCounts[j]; for (; i < to; i++) { bool selected; if (context.Value.IsFlagsEnum) { var mask = TypeExtensions.GetEnumBitmask(context.Value.Values[i], enumType); selected = (mask & value) == mask; } else { selected = context.Value.Values[i] == value; } GUIStyle style; Rect btnRect = rect; if (i == from && i == to - 1) { style = selected ? SirenixGUIStyles.ButtonSelected : SirenixGUIStyles.Button; btnRect.x -= 1; btnRect.xMax = xMax + 1; } else if (i == from) { style = selected ? SirenixGUIStyles.ButtonLeftSelected : SirenixGUIStyles.ButtonLeft; } else if (i == to - 1) { style = selected ? SirenixGUIStyles.ButtonRightSelected : SirenixGUIStyles.ButtonRight; btnRect.xMax = xMax; } else { style = selected ? SirenixGUIStyles.ButtonMidSelected : SirenixGUIStyles.ButtonMid; } //厘亟議!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! if (isBiaoTi) { style.fontStyle = FontStyle.Bold; style.richText = true; style.fontSize = 13; btnRect.height += 5f; if (btnRect.y > 14) { btnRect.y += 5f; } } if (GUI.Button(btnRect, context.Value.Names[i], style)) { GUIHelper.RemoveFocusControl(); if (!context.Value.IsFlagsEnum || Event.current.button == 1 || Event.current.modifiers == EventModifiers.Control) { entry.WeakSmartValue = Enum.ToObject(enumType, context.Value.Values[i]); } else { if (selected) { value &= ~context.Value.Values[i]; } else { value |= context.Value.Values[i]; } entry.WeakSmartValue = Enum.ToObject(enumType, value); } GUIHelper.RequestRepaint(); } rect.x += rect.width; } } if (Event.current.type == EventType.Repaint && context.Value.PreviousControlRectWidth != controlRect.width) { context.Value.PreviousControlRectWidth = controlRect.width; float maxBtnWidth = 0; int row = 0; context.Value.ColumnCounts.Clear(); context.Value.ColumnCounts.Add(0); i = 0; for (; i < context.Value.NameSizes.Length; i++) { float btnWidth = context.Value.NameSizes[i] + 3; int columnCount = ++context.Value.ColumnCounts[row]; float columnWidth = controlRect.width / columnCount; maxBtnWidth = Mathf.Max(btnWidth, maxBtnWidth); if (maxBtnWidth > columnWidth && columnCount > 1) { context.Value.ColumnCounts[row]--; context.Value.ColumnCounts.Add(1); row++; maxBtnWidth = btnWidth; } } } }
/// <summary> /// Adds the specified object at the specified menu item path and returns all menu items created in order to add in order to end up at the specified menu path. /// </summary> /// <param name="tree">The tree.</param> /// <param name="menuPath">The menu path.</param> /// <param name="instance">The object instance.</param> /// <param name="forceShowOdinSerializedMembers">Set this to true if you want ODIN serialzied members such as dictionaries and generics to be shown as well.</param> /// <returns>Returns all menu items created in order to add the menu item at the specified menu item path.</returns> public static IEnumerable <OdinMenuItem> AddObjectAtPath(this OdinMenuTree tree, string menuPath, object instance, bool forceShowOdinSerializedMembers = false, MyEnumColor textColor = MyEnumColor.Blue) { string name; SplitMenuPath(menuPath, out menuPath, out name); if (forceShowOdinSerializedMembers && !(instance as UnityEngine.Object)) { OdinMenuItem item = new OdinMenuItem(tree, name, new SerializedValueWrapper(instance)); item.TextColor = textColor; return(tree.AddMenuItemAtPath(menuPath, item)); } else { OdinMenuItem item = new OdinMenuItem(tree, name, instance); item.TextColor = textColor; return(tree.AddMenuItemAtPath(menuPath, item)); } }
public readonly int OffsetX = 10; //X轴偏移 public MyHeadAttribute(string description, MyEnumColor colorEnum) { Description = description; TextColor = colorEnum; }
/// <summary> /// 单 Class 单个添加 /// </summary> /// <typeparam name="T">那个类</typeparam> /// <param name="tree">树</param> /// <param name="subString">菜单项名</param> /// <param name="color">字体颜色</param> protected void AddNew <R>(OdinMenuTree tree, string subString, MyEnumColor color = MyEnumColor.Blue) where R : new() { tree.AddObjectAtPath(subString, MyType.NewTypeClass <R>(), false, color); }
public static Color GetColor(MyEnumColor enumColor) { return(GetColor(GetColorString(enumColor))); }
public static void TextText2(string str1, string str2, int jianGe, ref bool isShow, Action showAction, MyEnumColor color = MyEnumColor.LightBlue) { JianTuoText2(str1, jianGe, ref isShow, showAction, () => { MyCreate.Text(str2); }, false, color); }
public static int TextEnum(string str1, int value, string[] displayedOptions, int jianGe, ref bool isShow, Action showAction, MyEnumColor color) { int tmp = value; JianTuoText(str1, jianGe, ref isShow, color, showAction, () => { tmp = MyCreate.Enum(tmp, displayedOptions); }, false); return(tmp); }
public MyHeadAttribute(string description, MyEnumColor textColor, int offsetX) { Description = description; TextColor = textColor; OffsetX = offsetX; }
public EnumToggleButtonsAttribute(MyEnumColor textColor, int size = 120) { IsBiaoTi = true; TextColor = textColor; ButtonSize = size; }
private void OneLine(string str, string des, MyEnumColor color, params string[] strs) { StringBuilder sb = new StringBuilder(); sb.Append(" ── ").Append(str.AddColor(color, false)).Append(" (").Append(des.AddGreen()).Append(")"); MyCreate.Text(sb.ToString()); MyCreate.Heng(() => { MyCreate.AddSpace(18); MyCreate.Box(() => { sb.Length = 0; sb.Append(" "); if (strs.Length <= 5) { for (int i = 0; i < strs.Length; i++) { if (i % 2 == 0) { sb.Append(strs[i].AddBlue()); } else { sb.Append(strs[i].AddLightBlue()); } if (i != strs.Length - 1) { sb.Append(Point); } } MyCreate.Text(sb.ToString()); } else { for (int i = 0; i < 5; i++) { if (i % 2 == 0) { sb.Append(strs[i].AddBlue()); } else { sb.Append(strs[i].AddLightBlue()); } if (i != strs.Length - 1) { sb.Append(Point); } } MyCreate.Text(sb.ToString()); sb.Length = 0; sb.Append(" "); for (int i = 5; i < strs.Length; i++) { if (i % 2 == 0) { sb.Append(strs[i].AddBlue()); } else { sb.Append(strs[i].AddLightBlue()); } if (i != strs.Length - 1) { sb.Append(Point); } } MyCreate.Text(sb.ToString()); } }); }); }