protected override void DrawInternal(int itemIdx, int endItem, float yOffset) { int endContainerItem = m_Assets.Count; int startItemIdx = itemIdx; // The seperator bar is drawn before all items yOffset += kGroupSeparatorHeight; bool isRepaintEvent = Event.current.type == EventType.Repaint; Rect r; if (ListMode) { // Draw row //position.width = Mathf.Max (position.width, 500); // For some reason the icon is clipped if the rect cannot contain both the text and icon so make sure its large for (; itemIdx < endItem && itemIdx < endContainerItem; itemIdx++) { r = m_Grid.CalcRect(itemIdx, yOffset); // Mouse event handling int clicks = HandleMouse(r); if (clicks != 0) { m_Owner.SetSelection(m_Assets[itemIdx], clicks == 2); } if (isRepaintEvent) { bool selected = !AssetStoreAssetSelection.Empty && AssetStoreAssetSelection.ContainsAsset(m_Assets[itemIdx].id); DrawLabel(r, m_Assets[itemIdx], selected); } } } else { // First loop over assets to draw icons and the loop again to // draw labels. Two loops in order to get rid of too many // expensive setShader calls. for (; itemIdx < endItem && itemIdx < endContainerItem; itemIdx++) { r = m_Grid.CalcRect(itemIdx, yOffset); // Mouse event handling int clicks = HandleMouse(r); if (clicks != 0) { m_Owner.SetSelection(m_Assets[itemIdx], clicks == 2); } if (isRepaintEvent) { Rect position = new Rect(r.x, r.y, r.width, r.height - s_Styles.resultsGridLabel.fixedHeight); DrawIcon(position, m_Assets[itemIdx]); } } itemIdx = startItemIdx; // Labels if (isRepaintEvent) { for (; itemIdx < endItem && itemIdx < endContainerItem; itemIdx++) { r = m_Grid.CalcRect(itemIdx, yOffset); bool selected = !AssetStoreAssetSelection.Empty && AssetStoreAssetSelection.ContainsAsset(m_Assets[itemIdx].id); DrawLabel(r, m_Assets[itemIdx], selected); } } } // "Show more" button if more asset can by found in asset store if (ItemsAvailable <= (m_Grid.rows * m_Grid.columns)) { return; // no more items to fetch from A$ server } r = new Rect(m_Owner.GetVisibleWidth() - m_ShowMoreDims.x - 6, yOffset + m_Grid.height + kMoreButtonOffset, m_ShowMoreDims.x, m_ShowMoreDims.y); if (ItemsAvailable > (m_Grid.rows * m_Grid.columns) && ItemsAvailable >= Assets.Count && Assets.Count < kMaxQueryItems) { Event evt = Event.current; switch (evt.type) { case EventType.MouseDown: if (evt.button == 0 && r.Contains(evt.mousePosition)) { if (ListMode) { ItemsWantedShown += kMoreRowsAddedListMode; } else { // Try to make sure that we have full rows of preview // after the update. Partly filled rows can occur when resizing the // listarea or when we reached the limit of results from server. int itemsNeededToFillLastRow = m_Grid.columns - (ItemCount % m_Grid.columns); itemsNeededToFillLastRow = itemsNeededToFillLastRow % m_Grid.columns; ItemsWantedShown += (kMoreRowsAdded * m_Grid.columns) + itemsNeededToFillLastRow; } if (NeedItems) // Check that we need to fetch it since we might already have it prefetched { m_Owner.QueryAssetStore(); } evt.Use(); } break; case EventType.Repaint: { EditorStyles.miniButton.Draw(r, "More", false, false, false, false); } break; } } }