InfiniteScroll 데이터 생성
casphoe opened this issue · comments
Service
- WebView
- AssetManagement
- Communicator
- LogViewer
- Manager
- UI
- Profiler
- Adapter
- DLST
Version
Write the version that you are currently using.
GPM : 2.2.5
Common 2.3.1
UI 2.7.4 => 역순 정렬에서 준 InfiniteScroll 사용
Summary
A clear and concise description of what the question is.
InfiniteScroll 데이터 생성 될 때 ScrollRect에서 보여지는 범위까지만 생성되고 안 보여지는 부분의 오브젝트들은 스크롤을 UpdateAllData를 통해서 데이터를 재분배 하는 것으로 알고 있는데 그렇지 않고 ScrollRect에서 보여지는 범위가 넘어갔는데 오브젝트가 계속 생성이 되어서 해결 방법을 알고 싶어서 질문합니다.
예를 들어서 10개만 보여지는 ScrollRect 인데 10개가 넘어가서 생성이 되어서 문제입니다.
Screenshots
If applicable, add screenshots to help explain your question.
Additional context
Add any other context about the problem here.
InsertData 함수입니다.
ShotDataItem data = new ShotDataItem();
data.index = index++;
dataList.Add(data);
shotScrollList.InsertData(data,0, true);
scrollIndex = shotScrollList.GetDataCount();
InsertData를 추가해주는 함수는 밑에 있습니다.
if(dataList.Count != PM._Guest.ShotList.Count)
{
int difference = Mathf.Abs(dataList.Count - PM._Guest.ShotList.Count);
for (int i = 0; i < difference; i++)
{
InsertData();
}
AllUpdate();
}
안녕하세요. 제보 감사합니다.
이전 버전에서 현재 중간에 추가 시 아이템이 계속 추가되는 현상을 확인했습니다.
현재 축, 아이템 방향 개선되도록 구조 개선 중으로 같이 포함되어 배포될 예정입니다.
우선 해결 코드 전달드립니다.
- UnfiniteScroll.ItemData.cs
- protected void InsertData(InfiniteScrollData data, int insertIndex) 함수
- for (int dataIndex = insertIndex; dataIndex < dataList.Count; dataIndex++) 반복문 아래
- if (insertIndex < lastDataIndex) 코드 추가로 해결할 수 있습니다.
{
lastDataIndex++;
}
protected void InsertData(InfiniteScrollData data, int insertIndex)
{
if (insertIndex < 0 || insertIndex > dataList.Count)
{
throw new ArgumentOutOfRangeException();
}
if (insertIndex < dataList.Count)
{
for (int dataIndex = insertIndex; dataIndex < dataList.Count; dataIndex++)
{
dataList[dataIndex].index++;
}
if (insertIndex < lastDataIndex)
{
lastDataIndex++;
}
dataList.Insert(insertIndex, new DataContext(data, insertIndex));
}
else
{
dataList.Add(new DataContext(data, dataList.Count));
}
}
감사합니다.
넵 감사합니다.