本文整理汇总了C#中IReorderableListAdaptor.DrawItemBackground方法的典型用法代码示例。如果您正苦于以下问题:C# IReorderableListAdaptor.DrawItemBackground方法的具体用法?C# IReorderableListAdaptor.DrawItemBackground怎么用?C# IReorderableListAdaptor.DrawItemBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReorderableListAdaptor
的用法示例。
在下文中一共展示了IReorderableListAdaptor.DrawItemBackground方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawListItem
private void DrawListItem(EventType eventType, Rect position, IReorderableListAdaptor adaptor, int itemIndex) {
bool visible = (position.y < _visibleRect.yMax && position.yMax > _visibleRect.y);
bool draggable = _allowReordering && adaptor.CanDrag(itemIndex);
Rect itemContentPosition = position;
itemContentPosition.x = position.x + 2;
itemContentPosition.y += 1;
itemContentPosition.width = position.width - 4;
itemContentPosition.height = position.height - 4;
// Make space for grab handle?
if (draggable) {
itemContentPosition.x += 20;
itemContentPosition.width -= 20;
}
// Make space for element index.
if (_indexLabelWidth != 0) {
itemContentPosition.width -= _indexLabelWidth;
if (eventType == EventType.Repaint && visible)
s_RightAlignedLabelStyle.Draw(new Rect(itemContentPosition.x, position.y, _indexLabelWidth, position.height - 4), itemIndex + ":", false, false, false, false);
itemContentPosition.x += _indexLabelWidth;
}
// Make space for remove button?
if (HasRemoveButtons)
itemContentPosition.width -= 27;
try {
s_CurrentItemIndex.Push(itemIndex);
EditorGUI.BeginChangeCheck();
if (eventType == EventType.Repaint && visible) {
// Draw background of list item.
var backgroundPosition = new Rect(position.x, position.y, position.width, position.height - 1);
adaptor.DrawItemBackground(backgroundPosition, itemIndex);
// Draw grab handle?
if (draggable) {
var texturePosition = new Rect(position.x + 6, position.y + position.height / 2f - 3, 9, 5);
GUIHelper.DrawTexture(texturePosition, ReorderableListResources.GetTexture(ReorderableListTexture.GrabHandle));
}
// Draw splitter between list items.
if (itemIndex != 0 && (!_tracking || itemIndex != s_AnchorIndex)) {
var texturePosition = new Rect(position.x, position.y - 1, position.width, 1);
GUIHelper.DrawTexture(texturePosition, ReorderableListResources.texItemSplitter);
}
}
// Allow control to be automatically focused.
if (s_AutoFocusIndex == itemIndex)
GUI.SetNextControlName("AutoFocus_" + _controlID + "_" + itemIndex);
// Present actual control.
adaptor.DrawItem(itemContentPosition, itemIndex);
if (EditorGUI.EndChangeCheck())
ReorderableListGUI.IndexOfChangedItem = itemIndex;
// Draw remove button?
if (HasRemoveButtons && adaptor.CanRemove(itemIndex)) {
s_RemoveButtonPosition = position;
s_RemoveButtonPosition.width = 27;
s_RemoveButtonPosition.x = itemContentPosition.xMax + 2;
s_RemoveButtonPosition.height -= 2;
if (DoRemoveButton(s_RemoveButtonPosition, visible))
RemoveItem(adaptor, itemIndex);
}
// Check for context click?
if (eventType == EventType.ContextClick && position.Contains(Event.current.mousePosition) && (Flags & ReorderableListFlags.DisableContextMenu) == 0) {
ShowContextMenu(_controlID, itemIndex, adaptor);
Event.current.Use();
}
}
finally {
s_CurrentItemIndex.Pop();
}
}