unity3d - 如何创建可折叠的汉堡菜单图标自定义检查器/编辑器 Unity
问题描述
我最近在一个视频中看到了这个自定义检查器图标,我认为它对于我目前正在创建的自定义编辑器可能非常有用。不过,我无法找到有关如何创建它的任何信息,所以我想知道是否有人知道如何创建它,或者它是否可能是视频创建者自己添加的。
红色框内的项目是我想要创建的。如果有人有任何关于它是如何创建的或如何从头开始创建它的信息,我将不胜感激。
解决方案
您可以使用 GUIStyle 创建此图像。
using UnityEditor;
[CustomPropertyDrawer(typeof(MyProperty))]
public class MyPropertyDrawer : PropertyDrawer
{
//which index of the popupOptions you want selected
private int selectedIndex = 0;
//the different options you want to display when the Popup is selected
private readonly string[] popupOptions =
{ "Option One", "Option Two" };
private GUIStyle popupStyle;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
//stuff above here
if (popupStyle == null)
{
popupStyle = new GUIStyle(GUI.skin.GetStyle("PaneOptions"));
popupStyle.imagePosition = ImagePosition.ImageOnly;
}
EditorGUI.Popup(position /*or whatever position you want*/, selectedIndex, popupOptions, popupStyle);
//stuff below here
}
}
在这里找到。
推荐阅读
- c# - 在 C# 中更改数据表中列的数据类型
- ios - UIScrollView contentInset 自动布局问题
- mysql - 网站中的 Sql 错误
- jmockit - @EJB 上的 JMockit 测试失败,持续查找
- multiprocessing - 在python中使用多处理删除文件
- sql - 仅当具有最新值的列“日期”具有另一列不为 NULL 时才检索行
- javascript - 输入自动完成不适用于标签和值
- blueprism - 控制室中的 Blueprism 进程看不到网页上的元素
- python - 为什么我在 python 中看到时区异常
- php - 了解参数化查询 php、sql、mysql