public WeaponUI_SubWeaponItemUI GetInstance() { WeaponUI_SubWeaponItemUI instance = null; if (mCachedInstances != null) { while ((instance == null || instance.Equals(null)) && mCachedInstances.Count > 0) { instance = mCachedInstances.Dequeue(); } } if (instance == null || instance.Equals(null)) { instance = Instantiate <WeaponUI_SubWeaponItemUI>(m_SubWeaponItemUI); } Transform t0 = m_SubWeaponItemUI.transform; Transform t1 = instance.transform; t1.SetParent(t0.parent); t1.localPosition = t0.localPosition; t1.localRotation = t0.localRotation; t1.localScale = t0.localScale; t1.SetSiblingIndex(t0.GetSiblingIndex() + 1); return(instance); }
public bool CacheInstance(WeaponUI_SubWeaponItemUI instance) { if (instance == null || instance.Equals(null)) { return(false); } if (mCachedInstances == null) { mCachedInstances = new Queue <WeaponUI_SubWeaponItemUI>(); } if (mCachedInstances.Contains(instance)) { return(false); } instance.gameObject.SetActive(false); mCachedInstances.Enqueue(instance); return(true); }
//刷新ShowScrollItem private void ShowScrollItem(int itemType, int showOrder) { ClearShowList(); m_MainWeaponUi.SubWeaponItemUI.gameObject.SetActive(false); if (!Global.gApp.gGameData.ItemTypeMapData.ContainsKey(itemType)) { return; } int curIdx = 0; int count = 0; for (int i = 0; i < Global.gApp.gGameData.ItemTypeMapData[itemType].Count; i++) { ItemItem itemConfig = Global.gApp.gGameData.ItemTypeMapData[itemType][i]; if (Convert.ToUInt32(itemConfig.opencondition[0]) == FilterTypeConstVal.CAMP && !Global.gApp.gSystemMgr.GetWeaponMgr().GetWeaponOpenState(itemConfig)) { continue; } WeaponUI_SubWeaponItemUI itemUI = m_MainWeaponUi.SubWeaponItemUI.GetInstance(); itemUI.Init(itemConfig, showOrder, this); m_ShowItemList.Add(itemUI); if (itemConfig.name.Equals(Global.gApp.gSystemMgr.GetWeaponMgr().GetCurSubWeapon())) { curIdx = i; } count = i; } for (int i = 0; i < m_AskNum; i++) { WeaponUI_SubWeaponItemUI itemUI = m_MainWeaponUi.SubWeaponItemUI.GetInstance(); m_ShowItemList.Add(itemUI); itemUI.transform.SetSiblingIndex(1 * (showOrder * 10000 + 10000)); itemUI.gameObject.SetActive(true); itemUI.Item.gameObject.SetActive(false); itemUI.AskIcon.gameObject.SetActive(true); } m_MainWeaponUi.SubWeaponContent.rectTransform.localPosition = new Vector3(m_MainWeaponUi.SubWeaponContent.rectTransform.localPosition.x, m_MainWeaponUi.SubWeaponContent.rectTransform.localPosition.y - 1, m_MainWeaponUi.SubWeaponContent.rectTransform.localPosition.z); }