示例#1
0
        private uMyGUI_Popup LoadPopupFromResources(string p_name)
        {
            uMyGUI_Popup popupPrefab = (uMyGUI_Popup)Instantiate(Resources.Load <uMyGUI_Popup>("popup_" + p_name + "_root"));

            if (popupPrefab != null)
            {
                if (AddPopup(popupPrefab, p_name))
                {
                    return(popupPrefab);
                }
            }
            return(null);
        }
示例#2
0
 public bool RemovePopup(uMyGUI_Popup p_popup)
 {
     for (int i = 0; i < m_popups.Length; i++)
     {
         if (m_popups[i] == p_popup)
         {
             List <uMyGUI_Popup> popups = new List <uMyGUI_Popup>(m_popups);
             popups.RemoveAt(i);
             m_popups = popups.ToArray();
             List <string> popupNames = new List <string>(m_popupNames);
             popupNames.RemoveAt(i);
             m_popupNames = popupNames.ToArray();
             return(true);
         }
     }
     return(false);
 }
示例#3
0
        public bool AddPopup(uMyGUI_Popup p_popup, string p_name)
        {
            // find popup canvas
            Canvas canvas = null;

            if (m_popups.Length > 0 && m_popups[0] != null && m_popups[0].transform.parent != null)
            {
                canvas = m_popups[0].transform.parent.GetComponentInParent <Canvas>();
            }
            if (canvas == null)
            {
                canvas = GetComponentInParent <Canvas>();
            }
            if (canvas == null)
            {
                canvas = FindObjectOfType <Canvas>();
            }
            if (canvas == null)
            {
                Debug.LogError("uMyGUI_PopupManager: AddPopup: there is no Canvas in this level!");
                return(false);
            }

            // update internal storage
            uMyGUI_Popup[] bufferPopups = m_popups;
            string[]       bufferNames  = m_popupNames;
            m_popups     = new uMyGUI_Popup[m_popups.Length + 1];
            m_popupNames = new string[m_popupNames.Length + 1];
            System.Array.Copy(bufferPopups, m_popups, bufferPopups.Length);
            System.Array.Copy(bufferNames, m_popupNames, bufferNames.Length);
            m_popups[m_popups.Length - 1]     = p_popup;
            m_popupNames[m_popups.Length - 1] = p_name;

            // parent new popup
            p_popup.transform.SetParent(canvas.transform, false);

            // hide new popup
            HidePopup(m_popups.Length - 1);

            return(true);
        }