[Unity UI Toolkit] ListView에 항목이 표시되지 않는 경우

1
2
3
4
5
6
7
_listView = root.Q<ListView>(k_listView);
_listView.itemsSource = _itemList;
_listView.makeItem = () => new Label();
_buildingListView.bindItem = (element, idx) => {
            var item = element as Label;
            item.text = _itemList[idx].Name);
        };
cs

이렇게 작성 했을 때 ListView에 아무런 항목이 표시 되지 않을 때가 있었는데
알고보니 _itemList의 인스턴스를 생성하지 않아서 ListView에 항목이 표기 되지 않았다.

_itemList = new List<T>(); 이 후 itemsSource에 할당 시켜주면 정상적으로 표시된다.

댓글

가장 많이 본 글