public void SetLoadingRate(int nIndex, int nRate) { LoadingPlayerItem updateItem = null; if (nIndex < (int)CAMP_NUM.EACH_CAMP_MAX_PLAYER) { updateItem = m_upPlayerItems[nIndex]; } else if (nIndex < 2 * (int)CAMP_NUM.EACH_CAMP_MAX_PLAYER) { updateItem = m_downPlayerItems[nIndex - (int)CAMP_NUM.EACH_CAMP_MAX_PLAYER]; } if (updateItem == null) { return; } updateItem.SetLoadingRate(nRate); }
private void InitFrameView(RectTransform rect, ref LoadingPlayerItem[] itemContainer) { int nCount = rect.childCount; for (int i = nCount - 1; i >= 0; --i) { Transform childTrans = rect.GetChild(i); if (childTrans) { var temp = childTrans.gameObject; ResNode.DestroyRes(ref temp); } } PlayerTemplate.SetActive(true); itemContainer = new LoadingPlayerItem[(int)CAMP_NUM.EACH_CAMP_MAX_PLAYER]; for (int i = 0; i < (int)CAMP_NUM.EACH_CAMP_MAX_PLAYER; ++i) { GameObject playerItemGo = ResNode.InstantiateRes(PlayerTemplate); if (!playerItemGo) { return; } playerItemGo.name = "PlayerItem" + (i + 1); RectTransform rectTrans = playerItemGo.transform as RectTransform; rectTrans.SetParent(rect, false); itemContainer[i] = playerItemGo.GetComponent <LoadingPlayerItem>(); if (!itemContainer[i]) { return; } itemContainer[i].SetItemClear(); } PlayerTemplate.SetActive(false); }