/// @param popupID /// popup ID to present /// /// @return The PopupView of the created popup, or null /// private PopupView CreatePopup(string popupID) { PopupView popupView = null; // Check if the popup is registered var popupPrefab = m_popupPrefabs.GetValueOrDefault(popupID, null); if (popupPrefab == null) { // Popup not registered, try to load from default location string popupPath = k_popupPrefabsPath + popupID; popupPrefab = Resources.Load <GameObject>(popupPath); } if (popupPrefab != null) { GameObject popupObject = GameObject.Instantiate(popupPrefab) as GameObject; popupView = popupObject.GetComponent <PopupView>(); popupView.Initialise(); popupView.transform.SetParent(m_popupCanvasObject.transform, false); if (popupView == null) { Debug.LogError(string.Format("Failed to get PopupView component from object '{0}'", popupObject.name)); } popupObject.name = popupID; } else { Debug.LogError(string.Format("Failed to load popup prefab '{0}'", popupID)); } return(popupView); }
/// @param popupView /// The PopupView to attempt to dismiss /// public void DismissPopup(PopupView popupView) { if (popupView != null) { popupView.RequestDismiss(); } if (m_popupQueue.Remove(popupView) == false) { m_priorityPopupQueue.Remove(popupView); } UpdatePopupVisiblities(); }
/// @param popupID /// popup ID to present /// @param [optional] layerable /// If this popup allows other popups to be displayed on top of it. Defaults to true. /// /// @return The created PopupView. Null if the prefab could not be loaded /// public PopupView QueuePopup(string popupID, bool layerable = true) { PopupView popupView = CreatePopup(popupID); if (popupView != null) { popupView.m_layerable = layerable; popupView.Hide(); m_popupQueue.Add(popupView); UpdatePopupVisiblities(); } return(popupView); }
/// @param popupID /// popup ID to present /// /// @return The created PopupView. Null if the prefab could not be loaded /// public PopupView QueueToastPopup(string popupID) { PopupView popupView = CreatePopup(popupID); if (popupView != null) { popupView.m_layerable = true; popupView.m_toast = true; popupView.Hide(); m_toastsPopupQueue.Add(popupView); UpdatePopupVisiblities(); } return(popupView); }
/// Used by PopupView::Dismiss to ensure the service has removed /// any references to this popup as it has been dismissed. /// Also updates popup visibilities /// /// @param popupView /// The PopupView to remove references to /// public void RemovePopup(PopupView popupView) { var popupList = m_popupQueue; if (popupView.m_toast == true) { popupList = m_toastsPopupQueue; } else if (popupView.m_priority == true) { popupList = m_priorityPopupQueue; } if (popupList.Remove(popupView) == true) { UpdatePopupVisiblities(); } }