void InitMap()
{
float height = 0;
var list = TableManager.Instance.GetPStageData();
for (int i = 0; i < list.Count; i++)
{
var slotName = string.Format("Slots/Slot_{0}", i + 1);
RectTransform slotGo = UIHelper.GetRectTransform(this.m_ScrollView.content.gameObject, slotName);
if (slotGo == null)
{
continue;
}
slotGo.GetComponent<UI_MapItemCtrl>().UpdateItem(list[i]);
//获取最高关卡的高度
if (list[i].id == UserManager.Instance.Owner.MaxStage)
{
height = slotGo.anchoredPosition.y + m_ScrollView.content.GetComponent<VerticalLayoutGroup>().padding.bottom;
}
}
StartCoroutine(ScrollToSlot(height));
}
//将滚动条移动到最高关卡处
IEnumerator ScrollToSlot(float height)
{
yield return new WaitForEndOfFrame();
float normalizedPos = height / m_ScrollView.content.rect.height;
this.m_ScrollView.verticalNormalizedPosition = normalizedPos > 0.5f ? normalizedPos : 0;
}