Post by meatloaf1024 on Aug 29, 2023 22:23:08 GMT
I'm currently running up against an issue trying to configure the first and last element of the scroller.
At first my thought was to do this in GetCellView with something like the following oc
But the list isn't fully created yet, so the EndDataIndex and StartDataIndex are incorrect as GetCellView is called initially.
One way I've thought of fixing this is waiting one frame after ReloadData() is called and traversing the list. In general though I'm curious if there are any best practices for this?
Thanks in advance?
At first my thought was to do this in GetCellView with something like the following oc
public EnhancedScrollerCellView GetCellView(EnhancedScroller scroller, int dataIndex, int cellIndex)
{
var friendUiItem = scroller.GetCellView(friendUiItemPrefab) as FriendUIItem;
friendUiItem.name = "Friend UI Item " + dataIndex;
var entry = friendListEntries[dataIndex];
//convert the data index to a list position so we can configure our ui Item appropriately
var listPosition = dataIndex switch
{
var x when x == scroller.StartDataIndex && x == scroller.EndDataIndex => FriendUIItem.ListPosition.Solo,
var x when x == scroller.StartDataIndex => FriendUIItem.ListPosition.First,
var x when x == scroller.EndDataIndex => FriendUIItem.ListPosition.Last,
_ => FriendUIItem.ListPosition.Middle
};
friendUiItem.Configure(entry,playFabFriendsListService,friendsCanvasController,listPosition);
friendUiItem.buttonGroupEventNotifier.OnButtonGroupSelectionEntered += (button) =>
{
OnRowSelectionAttempted?.Invoke(friendUiItem,button.gameObject,true);
};
return friendUiItem;
}
But the list isn't fully created yet, so the EndDataIndex and StartDataIndex are incorrect as GetCellView is called initially.
One way I've thought of fixing this is waiting one frame after ReloadData() is called and traversing the list. In general though I'm curious if there are any best practices for this?
Thanks in advance?