Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PromoController : MonoBehaviour {
- public string url;
- public float timeOut = 5f;
- public GameObject loadingOverlay;
- private UniWebView webView;
- private bool isLoading;
- public void ShowMoreGames () {
- if (!isLoading) {
- Debug.Log ("----------------------------------------> REQUEST");
- isLoading = true;
- Invoke ("WebViewCancelLoad",timeOut);
- GameObject webViewGO = new GameObject("webview");
- webView = webViewGO.AddComponent<UniWebView> ();
- webView.OnLoadComplete += (UniWebView webView, bool success, string errorMessage) => {
- Debug.Log ("----------------------------------------> COMPLETE");
- isLoading = false;
- CancelInvoke ();
- if (success) {
- Debug.Log ("----------------------------------------> SUCCESS");
- webView.Show (true,UniWebViewTransitionEdge.None,.5f,() => {
- loadingOverlay.SetActive (false);
- });
- } else {
- Debug.Log ("----------------------------------------> FAILURE");
- loadingOverlay.SetActive (false);
- }
- };
- webView.toolBarShow = true;
- webView.url = url;
- webView.Load();
- loadingOverlay.SetActive (true);
- }
- }
- private void WebViewCancelLoad () {
- isLoading = false;
- Debug.Log ("----------------------------------------> STOP");
- webView.Stop ();
- loadingOverlay.SetActive (false);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement