Uta*_*aru 6 c# unity-game-engine
我为 Journal 类创建了自定义检查器以显示List<T>
为ReorderableList<T>
. 为了显示类结构我编写了以下代码:
private ReorderableList list;
private void OnEnable()
{
list.drawElementCallback =
(Rect rect, int index, bool isActive, bool isFocused) =>
{
rect = new Rect(rect.x, rect.y, rect.width, rect.height * 2);
var element = list.serializedProperty.GetArrayElementAtIndex(index);
rect.y += 2;
EditorGUI.PropertyField(
new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight),
element.FindPropertyRelative("Name"), GUIContent.none);
EditorGUI.PropertyField(
new Rect(rect.x + 100, rect.y, rect.width - 100, EditorGUIUtility.singleLineHeight),
element.FindPropertyRelative("Image"), GUIContent.none);
EditorGUI.PropertyField(
new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight + 2f, rect.width, EditorGUIUtility.singleLineHeight),
element.FindPropertyRelative("Description"), GUIContent.none);
};
Run Code Online (Sandbox Code Playgroud)
我期望它会像这样显示:
[1: Name] [1: Picture]
[1: Description]
[2: Name] [2: Picture]
[2: Description]
Run Code Online (Sandbox Code Playgroud)
但结果是,第一个元素的“描述”与第二个元素的“名称”和“图片”重叠,依此类推。
我找不到任何方法来增加 的ReorderableList
元素高度。设置rect.min
没有帮助
list.elementHeight = EditorGUIUtility.singleLineHeight * 2f;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5436 次 |
最近记录: |