unity编辑器显示中文枚举
来源:互联网 发布:mac地址 ip 编辑:程序博客网 时间:2024/06/10 03:31
先上效果图
该类来自雨松http://www.xuanyusong.com/archives/4213
放在非 Editor 文件夹下
using UnityEngine;using System;[AttributeUsage(AttributeTargets.Enum | AttributeTargets.Field)]public class EnumLabelAttribute : PropertyAttribute{ public string label; public new int[] order = new int[0]; public EnumLabelAttribute(string label) { this.label = label; } public EnumLabelAttribute(string label, params int[] order) { this.label = label; this.order = order; }}
下面这个才是我写哒
在这里显示枚举的中文Popup
using UnityEditor;using System;using System.Reflection;public class EditorGUIEnumPopup : EditorWindow { public static object EnumPopup(string title, Enum selected) { int index = 0; var array = Enum.GetValues(selected.GetType()); int length = array.Length; string[] enumString = new string[length]; for (int i = 0; i < length; i++) { FieldInfo[] fields = selected.GetType().GetFields(); foreach (FieldInfo field in fields) { if (field.Name.Equals(array.GetValue(i).ToString())) { object[] objs = field.GetCustomAttributes(typeof(EnumLabelAttribute), true); if (objs != null && objs.Length > 0) { enumString[i] = ((EnumLabelAttribute)objs[0]).label; } } } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(title); index = EditorGUILayout.Popup(selected.GetHashCode(), enumString); EditorGUILayout.EndHorizontal(); return Enum.ToObject(selected.GetType(), index); }}
阅读全文
0 0
- unity编辑器显示中文枚举
- unity 自定义编辑器 枚举 隐藏与显示
- Unity 编辑器 Inspector面板枚举
- Unity中的中文显示
- Unity IOS 中文显示
- Unity 中文显示
- Unity GUI 中文显示
- Unity如何显示中文
- 将枚举值中文显示
- unity中文字符的显示
- unity monodevelop中文显示解决方法
- 让Processing编辑器显示中文
- 让枚举成员显示出中文信息
- PropertyGrid中的枚举显示为中文
- PropertyGrid中的枚举显示为中文
- Unity--关于中文显示的解决方法
- Unity生成WebGL是InputField显示中文
- 中文显示问题(终端显示,vi编辑器显示)
- 仿IOS Switch 开关
- 图像检索
- 来到CSDN,希望能够开始记录自己
- JSON with HTTP
- linux安装mysql
- unity编辑器显示中文枚举
- Mac系统崩溃,如何备份、恢复数据
- 近观Python: Texts as list of words
- su
- APP热更新方案
- VBA基本用法
- java 集合框架 Map-AbstractMap
- QT备忘笔记
- 阿里妈妈字体图标(iconfont)使用介绍