public static Popup Open(string name, Params p, OnResultCallback resultCallback = null, OnLoadedCallback loadedCallback = null, Popup externalPrefab = null) { Popup pop = Popup.Load(name, p.foremost, externalPrefab); if (null != pop) { pop.Open(p, resultCallback, loadedCallback); return(pop); } else { if (Popup.testMode) { if (null != loadedCallback) { loadedCallback(null); } } if (null != resultCallback) { resultCallback(new Popup.Result { pop = pop, isOk = Popup.testMode ? true : false, }); } } return(null); }
public void Abort() { if (!this.IsOpened) { return; } this.resultCallback = null; this.Release(); }
public void Open(Params p, OnResultCallback resultCallback = null, OnLoadedCallback loadedCallback = null) { #if LOG_DEBUG Debug.Log("POPUP_OPEN:" + this.name + ", IS OPENED:" + this.IsOpened + ", POPUP_OPEN_COUNT:" + Popup.OpenCount + ", FOCUS:" + Popup.Focused + ", LAST_ORDER:" + Popup.lastOrder); #endif// LOG_DEBUG if (this.IsOpened) { this.Close(); } this.isOpened = true; this.resultCallback = resultCallback; this.gameObject.SetActive(false); this.gameObject.SetActive(true); this.SetShow(true); this.keepParam = p; this.order = Popup.lastOrder++; this.Managed = p.managed || this.forceManaged; if (this.isStarted) { if (p.directBuild || this.isRecycled) { if (!this.Build()) { Debug.LogError(string.Format("POPUP:OPEN_FAILED:{0}", this.name)); return; } } this.loadedCallback = null; if (null != loadedCallback) { loadedCallback(this); } } else { this.loadedCallback = loadedCallback; } if (null != Popup.onOpenedListener) { Popup.onOpenedListener(this); } }
public void Close() { if (!this.IsOpened) { return; } --Popup.lastOrder; #if LOG_DEBUG Debug.Log("POPUP_CLOSE:" + this.name + ", OPEN_COUNT:" + Popup.OpenCount + ", FOCUS:" + Popup.Focused + ", LAST_ORDER:" + Popup.lastOrder); #endif// LOG_DEBUG if (0 > Popup.lastOrder) { #if LOG_DEBUG Debug.LogWarning("POPUP_INVALID_LAST_ORDER:" + Popup.lastOrder); #endif// LOG_DEBUG Popup.lastOrder = 0; } this.isOpened = false; this.isBuildDone = false; var p = this.keepParam; if (null == p || !p.keepDestroy) { this.gameObject.SetActive(false); } this.loadedCallback = null; // NOTE: memory managing var resultCallback = this.resultCallback; this.resultCallback = null; var ret = this.CreateResult(); this.SetupResult(ret); var hideScene = this.keepParam.hideScene || this.forceHideScene; var solo = this.keepParam.solo || this.forceSolo; this.OnClose(); Popup.Unregist(this); if (null != Popup.onClosedListener) { Popup.onClosedListener(this); } var node = Popup.opened.First; while (null != node) { var pop = node.Value; node = node.Next; if (solo) { if (pop.order < this.order) { pop.ShowWithCount(true); } } if (pop.order >= this.order) { --pop.order; } } if (hideScene) { Present.Show(); } if (null != resultCallback) { resultCallback(ret); } }
/// <summary> /// Called when recognition results are ready. /// </summary> public void onResults(string results) { OnResultCallback?.Invoke(results); }