public void Initialize() { if (IsInitialized) { return; } infiniteCell = cellPrefab.GetComponent <InfiniteCell <T> >(); scrollRect = GetComponent <ScrollRect>(); scrollRect.onValueChanged.AddListener(OnValueChanged); for (int i = 0; i < cellPoolSize; i++) { var newCell = Instantiate(infiniteCell, scrollRect.content); newCell.gameObject.SetActive(false); cellPool.Enqueue(newCell); } movementType = scrollRect.movementType; IsInitialized = true; }
private void OnCellSelected(InfiniteCell <T> selectedCell) { onCellSelected?.Invoke(selectedCell); }