Beispiel #1
0
    /// <summary>
    /// Gets the cell to be displayed. You can have numerous cell types, allowing variety in your list.
    /// Some examples of this would be headers, footers, and other grouping cells.
    /// </summary>
    /// <param name="scroller">The scroller requesting the cell</param>
    /// <param name="dataIndex">The index of the data that the scroller is requesting</param>
    /// <param name="cellIndex">The index of the list. This will likely be different from the dataIndex if the scroller is looping</param>
    /// <returns>The cell for the scroller to use</returns>
    public EnhancedScrollerCellView GetCellView(EnhancedScroller scroller, int dataIndex, int cellIndex)
    {
        // first, we get a cell from the scroller by passing a prefab.
        // if the scroller finds one it can recycle it will do so, otherwise
        // it will create a new cell.
        PhotosBlockUiItem cellView = scroller.GetCellView(cellViewPrefab) as PhotosBlockUiItem;

        // set the name of the game object to the cell's data index.
        // this is optional, but it helps up debug the objects in
        // the scene hierarchy.
        cellView.name = "Cell " + dataIndex.ToString();

        // in this example, we just pass the data to our cell's view which will update its UI
        Texture2D[] data = new Texture2D[cellViewPrefab.numOfItems];

        // split to blocks
        int startIndex = dataIndex * data.Length;

        for (int i = 0; i < data.Length; i++)
        {
            if (startIndex + i < _data.Count)
            {
                data[i] = _data[startIndex + i];
            }
            else
            {
                data[i] = null;
            }
        }

        cellView.SetData(data);

        // return the cell to the scroller
        return(cellView);
    }
Beispiel #2
0
    public List <int> GetSelectedPhotosIndexes()
    {
        List <int> indexes = new List <int>();
        SmallList <EnhancedScrollerCellView> activeItems = scroller.GetActiveCellViews();

        PhotosUiItem[] items;
        for (int i = 0; i < activeItems.Count; i++)
        {
            PhotosBlockUiItem blockUiItem = activeItems[i].GetComponent <PhotosBlockUiItem>();
            items = blockUiItem.GetSelectedItems();

            for (int j = 0; j < items.Length; j++)
            {
                int index = _data.IndexOf(items[j].GetTexture());
                indexes.Add(index);
                Debug.Log($"Index added as selected photo index: {index}");
            }
        }

        return(indexes);
    }