继上一篇,制作序列化类的编辑器
发布日期:2021-06-30 19:38:52
浏览次数:3
分类:技术文章
本文共 1263 字,大约阅读时间需要 4 分钟。
上一篇奖到类的序列化,为了编辑方便和一些特殊需求,比如编辑某序列化属性的时候会另外去写一个文件之类的,所以为类写编辑器就派上用场了
如下,为MyClass编写一个编辑器类
using UnityEngine;using UnityEditor;[CustomEditor(typeof(MyClass))]public class MyClassEditor : Editor{ private MyClass instance; public override void OnInspectorGUI() { instance = (MyClass)target; CommonInfoGUI(); } private void CommonInfoGUI() { EditorGUILayout.HelpBox("hello,welcom", MessageType.None); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("IntTest","整数测试")); instance.SetIntTest(EditorGUILayout.IntField(instance.IntTest)); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("BoolTest", "布尔值测试")); instance.SetBoolenTest(EditorGUILayout.Toggle(instance.BoolenTest)); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("StrTest", "字符串测试")); instance.SetStrIndex(EditorGUILayout.Popup(instance.StrIndex, instance.strList)); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); }}这时候,我们的类序列化文件的显示就变成我们做的样子啦~
大功告成~~
转载地址:https://linxinfa.blog.csdn.net/article/details/51973500 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
关注你微信了!
[***.104.42.241]2024年04月13日 11时22分11秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
JAVA学习笔记6 - 数组
2019-04-30
JAVA学习笔记8 - Stream 和 File I/O
2019-04-30
JAVA学习笔记9 - 异常
2019-04-30
JAVA学习笔记10 - 继承
2019-04-30
JAVA学习笔记11 - 接口interface
2019-04-30
JAVA学习笔记12 - 包package
2019-04-30
Android 开发学习笔记 00 - Getting Started
2019-04-30
【学习笔记】Android Activity
2019-04-30
【学习笔记】Android Fragments
2019-04-30
Android使用Retrofit_00_Getting Started
2019-04-30
Android使用Retrofit_01_OAuth2 + GitHub
2019-04-30
Django + REST学习笔记
2019-04-30
【转载】将Ubuntu16.04 中gedit在仅显示一个文件时显示文件名tab
2019-04-30
fstream 对象多次使用时注意clear
2019-04-30
调试 LenaCV 3D Camera (Linux)
2019-04-30
OpenCV杂记 - Mat in C++
2019-04-30