private void OnAssetShouldBeLoadedCallback(LoadPopupAssetRequest request) { var result = cachedPopups.FirstOrDefault(x => x.gameObject.name == request.AssetId); var response = new LoadPopupAssetResponse(result); request.Callback(response); }
public async void Open(PopupEntityBase popupData, Action <PopupViewBase> onOpened = null, Action onFail = null) { var rulesToOpen = container.TryResolveId <List <PopupRuleBase> >(popupData.PopupOpenRule); var canBePopupOpened = popupsManager.CanPopupBeOpened(rulesToOpen); if (canBePopupOpened) { PopupViewBase view = null; if (popupData is PopupEntityWithId entityWithId) { var request = new LoadPopupAssetRequest() { AssetId = entityWithId.PopupId, }; var response = await eventBus.FireAsync <LoadPopupAssetRequest, LoadPopupAssetResponse>(request); var isError = response.Exception != null; if (isError) { OnPopupLoadedFailHandler(response.Exception); } else { view = response.Result; } } else if (popupData is PopupEntityWithAssetPrefab entityWithPrefab) { view = entityWithPrefab.PopupViewPrefab; } OnPopupLoadedSuccessHandler(view, popupData, onOpened); } else { popupsManager.EnqueuePopup(popupData, onOpened, onFail); } }