Unity中实现List类型的自定义GUI(ReorderableList)
2016-05-04 12:57
866 查看
感谢韩同学提供的资源
Unity本身提供了float,int,vector3..等类型字段的gui接口,而对于集合类型一般要自己硬写。
官方提供了一个List的自定义GUI,但使用起来非常复杂
UnityEditorInternal.ReorderableList使用:
http://www.cnblogs.com/hont/p/5458021.html
另外有一个开源的ReorderableList实现,Rotorz.ReorderableList
这个用起来非常简单
MonoBehaviour:
Editor:
最终效果:
只需把序列化字段名称传给Rotorz.ReorderableList就可以在GUI显示了。
下载地址:
https://bitbucket.org/rotorz/reorderable-list-editor-field-for-unity
Unity本身提供了float,int,vector3..等类型字段的gui接口,而对于集合类型一般要自己硬写。
官方提供了一个List的自定义GUI,但使用起来非常复杂
UnityEditorInternal.ReorderableList使用:
http://www.cnblogs.com/hont/p/5458021.html
另外有一个开源的ReorderableList实现,Rotorz.ReorderableList
这个用起来非常简单
MonoBehaviour:
public class ReorderableTest : MonoBehaviour { public List<string> names = new List<string>(); }
Editor:
[CustomEditor(typeof(ReorderableTest))] public class ReorderableTestInspector : Editor { SerializedProperty mNamesProp; private void OnEnable() { mNamesProp = serializedObject.FindProperty("names"); } public override void OnInspectorGUI() { serializedObject.Update(); ReorderableListGUI.Title("names"); ReorderableListGUI.ListField(mNamesProp); serializedObject.ApplyModifiedProperties(); } }
最终效果:
只需把序列化字段名称传给Rotorz.ReorderableList就可以在GUI显示了。
下载地址:
https://bitbucket.org/rotorz/reorderable-list-editor-field-for-unity
相关文章推荐
- [转]Unity: make your lists functional with ReorderableList
- untiy 3d ShaderLab_第6章_VertexLit渲染路径_4_顶点照明和Unity存放光源的第三种方式
- Unity ScriptableObject的使用
- unity5.3+Easytouch4.3——EasyTouch及摇杆控件介绍
- Unity3D UNET 模仿局域网游戏(三)
- Unity3D Pattern not found 破解失败解决方法
- Unity优化个人体验
- Unity3D UNET 模仿局域网游戏(二)
- Unity3D入门(rolling ball)——学习笔记
- Unity3d+moba+小地图
- Unity3D UNET 模仿局域网游戏(一)
- WWW加载文件
- Unity3D游戏开发之虚拟现实项目开发流程
- Unity+Vuforia 防抖动解决方案
- 关于Unity任何版本点击Play运行就黑屏,除了摄像机窗口其他全部黑掉的问题解决~
- [UnityUI]NGUI性能优化之ScrollView
- 【笔记】Core GameObjects, components, and concepts relating to Unity UI development include
- untiy 3d ShaderLab_第6章_VertexLit渲染路径_3_顶点照明和Unity存放光源的第二种方式
- untiy 3d ShaderLab_第6章_VertexLit渲染路径_2_顶点照明和Unity存放光源的第一种方式
- Unity3D NGUI动态生成模糊背景图