public bool Close(GameObject dialog) { bool closed = (dialog != null); if (closed) { _dialogs.Remove(dialog); DialogView view = dialog.GetComponent <DialogView>(); view.OnClose(); GameObject.Destroy(dialog); gameObject.SetActive(_dialogs.Count > 0); } dialog = null; return(closed); }
public bool Close(string dialogID) { KeyValuePair <GameObject, string> dialog = _dialogs.FirstOrDefault(d => d.Value == dialogID); if (dialog.Equals(default(KeyValuePair <GameObject, string>))) { return(false); } DialogView view = dialog.Key.GetComponent <DialogView>(); if (view != null) { view.OnClose(); } _dialogs.Remove(dialog.Key); GameObject.Destroy(dialog.Key); gameObject.SetActive(_dialogs.Count > 0); return(true); }