public WeaponUI_WeaponItemUI GetInstance() { WeaponUI_WeaponItemUI 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_WeaponItemUI>(m_WeaponItemUI); } Transform t0 = m_WeaponItemUI.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_WeaponItemUI instance) { if (instance == null || instance.Equals(null)) { return(false); } if (mCachedInstances == null) { mCachedInstances = new Queue <WeaponUI_WeaponItemUI>(); } if (mCachedInstances.Contains(instance)) { return(false); } instance.gameObject.SetActive(false); mCachedInstances.Enqueue(instance); return(true); }
//刷新ShowScrollItem private void ShowScrollItem(int itemType, int showOrder) { ClearShowList(); if (!Global.gApp.gGameData.ItemTypeMapData.ContainsKey(itemType)) { return; } int curIdx = 0; int count = 0; m_MainWeaponUi.WeaponItemUI.gameObject.SetActive(false); 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_WeaponItemUI itemUI = m_MainWeaponUi.WeaponItemUI.GetInstance(); itemUI.Init(itemConfig, showOrder, this); m_ShowItemList.Add(itemUI); if (itemConfig.name.Equals(Global.gApp.gSystemMgr.GetWeaponMgr().GetCurMainWeapon())) { curIdx = i; } count = i; } if (curIdx > count - 3) { curIdx = count - 5; } else { curIdx = Mathf.Max(0, curIdx - 3); } m_MainWeaponUi.WeaponContent.rectTransform.localPosition = new UnityEngine.Vector3(m_MainWeaponUi.WeaponContent.rectTransform.localPosition.x, curIdx * 255, m_MainWeaponUi.WeaponContent.rectTransform.localPosition.z); }