static void ShowCacheUIItems(UnityEditor.MenuCommand cmd) { if (Application.isPlaying) { return; } UICachePrefabBase current = cmd.context as UICachePrefabBase; if (current != null) { current.UpdateRelativeCachePath(); } }
/// <summary> /// 回收UI项 /// </summary> /// <param name="uiitem"></param> public void RecycleUIItem(UICachePrefabBase uiitem) { if (uiitem == null) { Debug.LogError("RecycleUIItem Fail,is Null"); return; } uiitem.OnRecycleUIItem(); uiitem.gameObject.transform.SetParent(PoolCanvas.transform, false); if (AllCacheUIItemsDic.ContainsKey(uiitem.CachePrefabName)) { AllCacheUIItemsDic[uiitem.CachePrefabName].Push(uiitem.transform as RectTransform); return; } Stack <RectTransform> pool = new Stack <RectTransform>(); pool.Push(uiitem.transform as RectTransform); AllCacheUIItemsDic.Add(uiitem.CachePrefabName, pool); }
public virtual void LoadCacheUIItem(UICacheMarkOperate operateEnum, string parameter) { if (m_IsLoaded) UnLoadItem(); m_IsLoaded = true; // Debug.Log("UICachePoolManager.Instance " + (UICachePoolManager.Instance == null)); m_LoadUIItem = UICachePoolManager.Instance.GetUIItemByPath(m_LoadPrefabPath); m_UICachePrefabScript = m_LoadUIItem.GetComponent<UICachePrefabBase>(); //设置自动对其到父节点下 m_LoadUIItem.SetParent(transform, false); m_LoadUIItem.SetAsFirstSibling(); m_LoadUIItem.localScale = Vector3.one; if (m_LoadUIItem.gameObject.activeSelf == false) m_LoadUIItem.gameObject.SetActive(true); // Debug.Log("UICacheItemMark"); m_UICachePrefabScript.OnGetUIItemInitial(operateEnum, parameter); //对获取的UI缓存的额额哎处理 m_LoadUIItem.localScale = Vector3.one; m_LoadUIItem.anchoredPosition = Vector2.zero; m_LoadUIItem.anchorMax = Vector2.one; m_LoadUIItem.anchorMin = Vector2.zero; m_LoadUIItem.sizeDelta = Vector2.zero; //设置位于父节点下的最前面,防止挡住其他节点 m_LoadUIItem.SetAsFirstSibling(); //在编辑模式下设置不可被保存,也就是apply后不会再被保存在prefab上 #if UNITY_EDITOR foreach (Transform t in m_LoadUIItem.GetComponentsInChildren<Transform>()) { t.gameObject.hideFlags = HideFlags.NotEditable | HideFlags.DontSave; } #endif if (onLoad != null) onLoad(); }