예제 #1
0
        private void onWebViewPopupPrefabLoaded(GameObject prefab)
        {
            webViewPopup = Object.Instantiate(prefab);
            WebViewPrefabController component = webViewPopup.GetComponent <WebViewPrefabController>();

            if (component != null)
            {
                if (component.WebViewerPanel != null)
                {
                    webViewPanel = component.WebViewerPanel;
                }
                if (component.CloseButton != null)
                {
                    component.CloseButton.onClick.AddListener(Destroy);
                }
                if (component.LoadingPanel != null)
                {
                    loadingPanel = component.LoadingPanel;
                    loadingPanel.SetActive(value: true);
                }
            }
            if ((bool)GameObject.Find("TopCanvas"))
            {
                Service.Get <EventDispatcher>().DispatchEvent(new PopupEvents.ShowTopPopup(webViewPopup));
            }
            else
            {
                Service.Get <EventDispatcher>().DispatchEvent(new PopupEvents.ShowPopup(webViewPopup));
            }
        }
예제 #2
0
        private IEnumerator loadPopupFromPrefab(PrefabContentKey popupKey, string URLToken, IContentInterruption gate, string popupTitleToken, bool allowPopups = false, bool openPopupInNewBrowser = false, float zoomLevel = 0f, float newBrowserZoomLevel = 0f)
        {
            AssetRequest <GameObject> assetRequest = Content.LoadAsync(popupKey);

            yield return(assetRequest);

            instantiatedPrefab = UnityEngine.Object.Instantiate(assetRequest.Asset);
            WebViewPrefabController webViewPrefabController = instantiatedPrefab.GetComponent <WebViewPrefabController>();

            title = webViewPrefabController.TitleText;
            Button scrollUpButton   = webViewPrefabController.ScrollUp;
            Button scrollDownButton = webViewPrefabController.ScrollDown;

            backButton        = webViewPrefabController.CloseButton;
            webViewPopupPanel = webViewPrefabController.WebViewerPanel;
            loadingPanel      = webViewPrefabController.LoadingPanel;
            if (title != null && backButton != null && webViewPopupPanel != null)
            {
                title.text = getLocalizedURL(popupTitleToken);
                backButton.onClick.AddListener(handlePopupClose);
                if ((bool)GameObject.Find("TopCanvas"))
                {
                    Service.Get <EventDispatcher>().DispatchEvent(new PopupEvents.ShowTopPopup(instantiatedPrefab));
                }
                else
                {
                    Service.Get <EventDispatcher>().DispatchEvent(new PopupEvents.ShowPopup(instantiatedPrefab));
                }
                yield return(new WaitForEndOfFrame());

                if (loadingPanel != null)
                {
                    loadingPanel.SetActive(value: true);
                }
                Show(URLToken, gate, webViewPopupPanel, scrollUpButton, scrollDownButton, isDownsampled: false, allowPopups, openPopupInNewBrowser, zoomLevel, newBrowserZoomLevel);
            }
            else
            {
                Log.LogError(this, "Missing key elements from prefab for " + popupKey);
                this.OnFailed.InvokeSafe();
            }
            yield return(null);
        }