public override void Init() { base.Init(); // record the item size IUListItemView itemView = itemPrefab.GetComponent <IUListItemView> (); itemSize = itemView.GetItemSize(-1); // record max numbers per row/column numPerRow = m_MaxRow; numPerColumn = m_MaxCol; if (numPerRow < 1) { numPerRow = (int)(scrollRectSize.x / (itemSize.x + spacing.x)); } if (numPerColumn < 1) { numPerColumn = (int)(scrollRectSize.y / (itemSize.y + spacing.y)); } if (numPerRow < 1 || numPerColumn < 1) { Debug.LogError("ScrollRect size is too small to contain even one item"); } // to make items center aligned padding = Vector2.zero; // spawn pool for listitems lstItems = new List <GameObject> (); }
public override void Init() { base.Init(); // record the item size IUListItemView itemView = itemPrefab.GetComponent <IUListItemView>(); itemSize = itemView.GetItemSize(-1); // spawn pool for listitems lstItems = new List <GameObject>(); }
public override int GetMaxShowItemNum() { int max = 0; int index = GetStartIndex(); float sum = 0; switch (layout) { case Layout.Horizontal: while (index < lstCount && sum < scrollRectSize.x) { sum += (itemView.GetItemSize(index).x + spacing.x); index++; max++; } break; case Layout.Vertical: while (index < lstCount && sum < scrollRectSize.y) { sum += (itemView.GetItemSize(index).y + spacing.y); index++; max++; } break; } return(max + 1); }