/// <summary> /// WebViewを開く。 /// </summary> /// <param name="url">Url。</param> public void OpenWebView(string url) { var webViewData = new WebViewData(); webViewData.Url = url; OpenWebView(webViewData); }
void Handle_Clicked(object sender, System.EventArgs e) { if (WebViewData.CanGoBack) { WebViewData.GoBack(); } }
/// <summary> /// Creates a new view instance of type <see cref="WebView"/>. /// </summary> /// <param name="reactContext">The React context.</param> /// <returns>The view instance.</returns> protected override WebView CreateViewInstance(ThemedReactContext reactContext) { var view = new WebView(WebViewExecutionMode.SeparateThread); var data = new WebViewData(); _webViewData.AddOrUpdate(view, data, (k, v) => data); return(view); }
/// <inheritdoc /> protected override WebBrowser CreateViewInstance(ThemedReactContext reactContext) { var view = new WebBrowser(); var data = new WebViewData(); _webViewData.AddOrUpdate(view, data); return(view); }
/// <summary> /// WebViewを開く。 /// </summary> void OnOpenWebView() { var webViewData = new WebViewData(); webViewData.Url = GetLocalFilePath("WebViewSample.html"); webViewData.OnOpened = () => statusLbl.text = "Open"; webViewData.OnClosed = () => statusLbl.text = "Close"; webView.OpenWebView(webViewData); }
/// <summary> /// WebView開くコルーチン。 /// </summary> /// <param name="webViewData">WebViewData。</param> IEnumerator OpenWebViewCoroutine(WebViewData webViewData) { if (webViewCanvas == null) { yield break; } if (webView == null) { // WebViewの作成。 var webViewObject = new GameObject("WebViewObject"); webViewObject.transform.SetParent(gameObject.transform); webViewObject.transform.localPosition = Vector3.zero; webViewObject.transform.localScale = Vector3.one; webView = webViewObject.AddComponent <WebViewObject>(); } if (webViewData.OnClosed != null) { OnClosedWebView = webViewData.OnClosed; } // WebViewの初期化。 webView.Init ( transparent: true, // コールバック。 cb: (msg) => { var urlScheme = WebViewURLController.GetUri(msg); if (urlScheme.Scheme == "file" || urlScheme.Scheme == "http" || urlScheme.Scheme == "https") { webView.LoadURL(msg); return; } WebViewURLController.ProcessURL(msg, CloseWebView, webViewData.CustomCallbackData); }, // エラー時。 err: (msg) => { if (webViewData.OnError != null) { webViewData.OnError(WebViewStatus.ACCESS_FAILUER); } }, // Httpeエラー。 httpErr: (msg) => { if (webViewData.OnError != null) { webViewData.OnError(WebViewStatus.HTTP_ERROR); } }, // ロード完了後。 ld: (msg) => { webView.EvaluateJS(@" document.body.style.background = 'white'; "); if (webViewData.OnOpened != null) { webViewData.OnOpened(); } }, enableWKWebView: true ); // URLの読み込み。 webView.LoadURL(webViewData.Url); // マージンのセット。 SetMargin(); // WebViewの表示。 webView.SetVisibility(true); yield break; }
/// <summary> /// WebViewを開く。 /// </summary> /// <param name="webViewData">WebViewData。</param> public void OpenWebView(WebViewData webViewData) { StartCoroutine(OpenWebViewCoroutine(webViewData)); }