本文整理汇总了C#中UnityEditorInternal.ReorderableList.elementHeightCallback方法的典型用法代码示例。如果您正苦于以下问题:C# ReorderableList.elementHeightCallback方法的具体用法?C# ReorderableList.elementHeightCallback怎么用?C# ReorderableList.elementHeightCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEditorInternal.ReorderableList
的用法示例。
在下文中一共展示了ReorderableList.elementHeightCallback方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnEnable
void OnEnable()
{
script = target as NPCController;
list = new ReorderableList(serializedObject, serializedObject.FindProperty("dialogs"), true, true, true, true);
list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => {
if (!list.serializedProperty.isExpanded) return;
var element = list.serializedProperty.GetArrayElementAtIndex(index);
rect.x += 15;
rect.width -= 15;
rect.height = EditorGUI.GetPropertyHeight(element) + 2;
EditorGUI.PropertyField(rect, element);
};
list.elementHeightCallback = (int index) => {
if (!list.serializedProperty.isExpanded) return 0;
var element = list.serializedProperty.GetArrayElementAtIndex(index);
float h = EditorGUI.GetPropertyHeight(element) + 6;
// If it's not the last one, but it's the last playOnce...
if (element.FindPropertyRelative("messages").isExpanded && ShowLastPlayOnceStuff(index))
h += 20;
return h;
};
list.drawHeaderCallback = (Rect rect) => {
//EditorGUI.LabelField(rect, list.serializedProperty.displayName);
//EditorGUI.LabelField(rect, "Conversations");
EditorGUI.indentLevel++;
list.serializedProperty.isExpanded = EditorGUI.Foldout(rect, list.serializedProperty.isExpanded, "Conversations");
EditorGUI.indentLevel--;
list.draggable =
list.displayAdd =
list.displayRemove = list.serializedProperty.isExpanded;
};
list.drawElementBackgroundCallback = (Rect rect, int index, bool isActive, bool isFocused) => {
if (!list.serializedProperty.isExpanded) return;
if (index < 0) return;
bool playOnce = list.serializedProperty.GetArrayElementAtIndex(index).FindPropertyRelative("playOnce").boolValue;
rect.y -= 2;
rect.x += 1;
rect.width -= 2;
rect.height = list.elementHeightCallback(index);
EditorGUI.DrawRect(rect, isFocused
? (playOnce ? new Color(0.2f, 0.5f, 0.2f, 0.2f) : new Color(0.2f, 0.2f, 0.2f, 0.2f))
: (playOnce ? new Color(0, 1, 0, 0.1f) : Color.clear));
if (ShowLastPlayOnceStuff(index)) {
var bot = new Rect(rect.x, rect.yMax-1, rect.width, 1);
EditorGUI.DrawRect(bot, new Color(0, 0.5f, 0, 0.5f));
}
};
list.onAddCallback = (ReorderableList l) => {
int index = l.count;
l.serializedProperty.InsertArrayElementAtIndex(index);
var sub = l.serializedProperty.GetArrayElementAtIndex(index);
sub.FindPropertyRelative("playOnce").boolValue = false;
sub.FindPropertyRelative("messages").ClearArray();
sub.isExpanded = true;
};
}