本文整理汇总了C#中UnityEditorInternal.ReorderableList.onSelectCallback方法的典型用法代码示例。如果您正苦于以下问题:C# ReorderableList.onSelectCallback方法的具体用法?C# ReorderableList.onSelectCallback怎么用?C# ReorderableList.onSelectCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEditorInternal.ReorderableList
的用法示例。
在下文中一共展示了ReorderableList.onSelectCallback方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddProperty
public void AddProperty(SerializedProperty property)
{
// Check if this property actually belongs to the same direct child
if (GetGrandParentPath(property).Equals(Parent) == false)
return;
ReorderableList propList = new ReorderableList(
property.serializedObject, property,
draggable: true, displayHeader: false,
displayAddButton: true, displayRemoveButton: true)
{
headerHeight = 5
};
propList.drawElementCallback = delegate(Rect rect, int index, bool active, bool focused)
{
SerializedProperty targetElement = property.GetArrayElementAtIndex(index);
bool isExpanded = targetElement.isExpanded;
rect.height = EditorGUI.GetPropertyHeight(targetElement, GUIContent.none, isExpanded);
if (targetElement.hasVisibleChildren)
rect.xMin += 10;
// Get Unity to handle drawing each element
EditorGUI.PropertyField(rect, targetElement, isExpanded);
// Height might have changed when dealing with serialized class
// Call the select callback when height changes to reset the list elementHeight
float newHeight = EditorGUI.GetPropertyHeight(targetElement, GUIContent.none, targetElement.isExpanded);
if (rect.height != newHeight)
{
propList.onSelectCallback(propList);
#if UNITY_5_1 || UNITY_5_2
propList.elementHeight = Mathf.Max(propList.elementHeight, newHeight);
#endif
}
};
propList.onSelectCallback = delegate(ReorderableList list)
{
SerializedProperty targetElement = property.GetArrayElementAtIndex(list.index);
list.elementHeight = EditorGUI.GetPropertyHeight(targetElement, GUIContent.none, targetElement.isExpanded);
};
propList.onChangedCallback = delegate(ReorderableList list)
{
list.onSelectCallback(list);
};
// Unity 5.3 onwards allows reorderable lists to have variable element heights
#if UNITY_5_3_OR_NEWER
propList.elementHeightCallback = delegate(int index)
{
SerializedProperty arrayElement = property.GetArrayElementAtIndex(index);
return EditorGUI.GetPropertyHeight(arrayElement, GUIContent.none, arrayElement.isExpanded);
};
#endif
propList.onAddCallback = delegate(ReorderableList list)
{
list.serializedProperty.arraySize++;
propList.onSelectCallback(list);
};
propIndex.Add(property.propertyPath, propList);
}