-
添加ScrollView,注意ScrollView下面的depth和sortOrder
- image.png
- ScrollView下面添加Container,作为参考的父容器,主要是为了获取他的位置和大小,添加子控件然后设置位置。
var rank = LongJingRankModle.Instance.getMySelfRank(nowBtnSelect);
///////////////////////////////////
int count = data.longJingRandInfos.Count;
if(count>0)
{
var flagCount = 0;
for (var i = 0; i < count; i++)
{
if (flagCount == AllPlayerItems.Count)
{
var cloneItem = Instantiate(bigPlayerItem);
cloneItem.transform.parent = Container.transform;
cloneItem.transform.localScale = Vector3.one;
cloneItem.transform.localEulerAngles = Vector3.zero;
AllPlayerItems.Add(cloneItem);
}
AllPlayerItems[flagCount].gameObject.SetActive(true);
flagCount++;
}
int useNum = 0;
for (var i = 0; i < data.longJingRandInfos.Count; i++)
{
// AllPlayerItems[i].InitItemData(i+1,data.longJingRandInfos[i].VipLevel,data.longJingRandInfos[i].NickName,data.longJingRandInfos[i].Point);
AllPlayerItems[i].InitItemData(i,data.longJingRandInfos);
AllPlayerItems[i].transform.localPosition = new Vector3(0, -(Container.height+5) * i, 0);
print("i=========================" + i);
AllPlayerItems[i].gameObject.SetActive(true);
useNum++;
}
for (var i = useNum; i < AllPlayerItems.Count; i++)
{
AllPlayerItems[i].gameObject.SetActive(false);
}
ScrollView.gameObject.SetActive(true);
}else
{
ScrollView.gameObject.SetActive(false);
}
4.ScrollView上添加一个拖拽层panelDrag,
panelDrag是一个UIWidget 下面添加一个UIDragScrollView(拖拽)和BoxCollider(点击)
image.png5.添加ScrollView下面的firstItem,添加子控件,添加UIDragScrollView和BoxCollider,添加完子控件后隐藏。
image.png
网友评论