c# - 使用 EditorGUILayout.PropertyField 时可以删除这个大空间吗?
问题描述
我开始在 Unity 中编写编辑器脚本,并且很快就被整个 SerializedProperty 事物所吸引。我要做的就是让这个区分大小写的复选框粘在检查器的右侧,文本和框本身之间没有所有空间,为 TextField 留出足够的空间。
这就是我目前正在做的事情:
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.Label("Search for:", GUILayout.Width(64));
searchText = GUILayout.TextField(searchText);
EditorGUILayout.PropertyField(propCaseSensitive, GUILayout.MinWidth(0), GUILayout.ExpandWidth(false));
}
我试过 GUILayout.Width 和 GUILayout.MaxWidth 和 GUILayout.ExpandWidth(false) 结合 GUILayout.MinWidth (也只是他们自己)
这些都没有奏效,我一直试图让这个简单的脚本工作太久,以至于我无法承认,这让我发疯了。请帮帮我,谢谢:)
解决方案
我认为您可以像其他标签一样进行操作。
PropertyField
有超载GUIContent label
。通过传入,GUIContent.none
您可以省略标签,而是添加您自己的标签:
// Not sure if even needed but adjust to the width you need
EditorGUILayout.LabelField(propCaseSensitive.displayName, GUILayout.Width(64), GUILayout.ExpandWidth(false));
// Don't draw the name via the default property field layout
EditorGUILayout.PropertyField(propCaseSensitive, GUIContent.none, GUILayout.ExpandWidth(false));
推荐阅读
- kotlin - Kotlin 反射获取参数作为字符串
- .net - InitializeComponent() 不存在 - 多目标项目 (4.6.1 & 5)
- teradata - 通过 .NET 连接器查询的错误结果,但直接在 Teradata Studio 中更正了结果
- sql - 每个点返回的行数 PostGIS
- javascript - Nodemailer连接错误仅在服务器上
- r - ggplot2如何仅对数据的某些行着色
- java - 将jOOQ表达式分配给局部变量时如何防止Eclipse添加@NotNull注释
- python - 在 python 套接字服务器上从客户端接收文件
- tarantool - 如何在 tarantool 中将乙烯基转换为 memtx?
- string - 这个模板字符串/公式字段的格式是什么?