public WeaponUI_PetItemUI GetInstance() { WeaponUI_PetItemUI 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_PetItemUI>(m_PetItemUI); } Transform t0 = m_PetItemUI.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_PetItemUI instance) { if (instance == null || instance.Equals(null)) { return(false); } if (mCachedInstances == null) { mCachedInstances = new Queue <WeaponUI_PetItemUI>(); } 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.PetItemUI.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_PetItemUI itemUI = m_MainWeaponUi.PetItemUI.GetInstance(); itemUI.Init(itemConfig, showOrder, this); m_ShowItemList.Add(itemUI); if (itemConfig.name.Equals(Global.gApp.gSystemMgr.GetWeaponMgr().GetCurPet())) { curIdx = i; } count = i; } for (int i = 0; i < m_AskNum; i++) { WeaponUI_PetItemUI itemUI = m_MainWeaponUi.PetItemUI.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.PetContent.rectTransform.localPosition = new Vector3(m_MainWeaponUi.PetContent.rectTransform.localPosition.x, m_MainWeaponUi.PetContent.rectTransform.localPosition.y - 1, m_MainWeaponUi.PetContent.rectTransform.localPosition.z); }