void setSchemes(bool setscheme) { if (setscheme) { m_WebView.AddUrlScheme("http"); m_WebView.AddUrlScheme("https"); } else { m_WebView.RemoveUrlScheme("http"); m_WebView.RemoveUrlScheme("https"); } }
public void Show(string url) { /*if(WebView == null) { * if(complete != null)complete(); * return; * }*/ UniWebView.CleanCache(); UniWebView.AddUrlScheme("lufy"); UniWebView.OnLoadComplete += OnLoadCompleteEvent; // 読み込み完了後のイベント登録 /* * UniWebView.OnReceivedMessage += OnReceivedMessage; // URLスキーマー取得のイベント登録 * UniWebView.OnEvalJavaScriptFinished += OnEvalJavaScriptFinished; // JavaScript実行完了時のイベント登録 */ UniWebView.SetBackgroundColor(Color.clear); // 透過処理を有効化 UniWebView.backButtonEnable = false; // Androidの戻るボタン(ソフトウェア)を無効化 UniWebView.SetShowSpinnerWhenLoading(false); // iOSの読み込み中スピナーを無効化 UniWebView.toolBarShow = false; // iOSのツールブラウザーを無効化 UniWebView.HideToolBar(false); // iOSのツールブラウザーを無効化 UniWebView.zoomEnable = false; // iOSの ズームを無効化 string userAgent = "Mozilla /5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B5110e Safari/601.1 "; UniWebView.SetUserAgent(userAgent); /*UniWebView.insets.left = 0; * UniWebView.insets.top = 10; * UniWebView.insets.right = 0;*/ UniWebView.insets.bottom = 106; RequestLoad(url); //if(complete != null)complete(); }
// Use this for initialization void Awake() { #if UNITY_IPHONE if (_webView == null) { _webView = gameObject.AddComponent <UniWebView>(); _webView.OnReceivedMessage += OnReceivedMessage; _webView.OnLoadComplete += OnLoadComplete; _webView.OnWebViewShouldClose += OnWebViewShouldClose; _webView.OnEvalJavaScriptFinished += OnEvalJavaScriptFinished; _webView.InsetsForScreenOreitation += InsetsForScreenOreitation; _webView.AddUrlScheme("http"); } #endif }
//----- method ----- public override void Initialize() { UniWebView = UnityUtility.GetComponent <UniWebView>(gameObject); // RectTransform追従. var rectTransform = transform as RectTransform; if (rectTransform != null) { UniWebView.ReferenceRectTransform = rectTransform; } // URLリンクをデバイスのデフォルトブラウザで開くかどうかの設定. UniWebView.SetOpenLinksInExternalBrowser(false); // ツールバー非表示. UniWebView.SetShowToolbar(false); // 横スクロールバー. UniWebView.SetHorizontalScrollBarEnabled(false); // 縦スクロールバー. UniWebView.SetVerticalScrollBarEnabled(false); // URLScheme追加. UniWebView.AddUrlScheme("webview"); #if UNITY_ANDROID UniWebView.SetUseWideViewPort(false); UniWebView.SetBackButtonEnabled(true); // デバッグ有効. #if DEBUG UniWebView.SetWebContentsDebuggingEnabled(Debug.isDebugBuild); #endif #endif #if UNITY_IOS || UNITY_ANDROID || UNITY_WP8 UniWebView.OnPageFinished += OnPageFinished; UniWebView.OnPageErrorReceived += OnPageErrorReceived; UniWebView.OnMessageReceived += OnReceivedMessage; UniWebView.OnShouldClose += OnShouldClose; #endif }
/// <summary> /// Awake this instance. /// </summary> void Awake() { _webView = gameObject.AddComponent <UniWebView> (); //TODO: 予めロードしているデータのデータが存在しない場合は通信してサーバーから再取得する必要がある //UserDeviceEntity.UserDevice uDevice = Extention.CommonPlayerPrefs.CommonLoad<UserDeviceEntity.UserDevice> (ApiConstants.API_USER_DEVICE); _webView.CleanCache(); _webView.SetShowSpinnerWhenLoading(true); _webView.backButtonEnable = true; _webView.autoShowWhenLoadComplete = true; // 設定サイズを取得 //WebviewLayout.InsetsParameter wInsets = WebviewLayout.GetInsetsWebview (0.1785f, 0.0f, 0.097f); WebviewLayout.InsetsParameter wInsets = WebviewLayout.GetInsetsWebview(0.13f, 0.0f, 0.2f); _webView.insets = new UniWebViewEdgeInsets(wInsets.top, wInsets.side, wInsets.bottom, wInsets.side); _webView.SetShowSpinnerWhenLoading(true); _webView.SetTransparentBackground(true); _webView.AddUrlScheme("campaign"); }
/// <summary> /// 添加schemes /// </summary> /// <param name="webview"></param> /// <param name="schemes"></param> private void AddSchemes(UniWebView webview, string[] schemes) { if (webview) { if (schemes != null && schemes.Length >= 0) { foreach (var scheme in schemes) { webview.AddUrlScheme(scheme); } webview.OnReceivedMessage += delegate(UniWebView view, UniWebViewMessage message) { YxDebug.LogError(string.Format("响应指定协议,协议名称是:{0}", message.scheme)); switch (message.scheme) { case _keyGameNotice: var action = message.path; YxDebug.LogError(string.Format("协议操作是:{0}", action)); int index = ActionName.IndexOf(action); YxDebug.LogError(string.Format("协议操作索引是:{0}", index)); if (index > -1) { if (Actions.Count > index) { YxDebug.LogError(string.Format("执行动作")); Actions[index].Execute(); } } break; default: YxDebug.Log(string.Format("协议是{0},爱干啥干啥,我这没有。。。", message.scheme)); break; } }; } } }
/// <summary> /// Gps Map the webview load. /// Map用のWEBViewデータを取得する /// </summary> public void Init() { _loadingOverlay.SetActive(true); LoadingTimer.Instance.IsTimerStop(true); _webView = this.gameObject.AddComponent <UniWebView> (); _webView.backButtonEnable = false; _webView.autoShowWhenLoadComplete = true; // 設定サイズを取得 WebviewLayout.InsetsParameter wInsets = WebviewLayout.GetInsetsWebview(0.19f, 0.0f, 0.2f); _webView.insets = new UniWebViewEdgeInsets(wInsets.top, wInsets.side, wInsets.bottom, wInsets.side); _webView.SetTransparentBackground(true); _webView.AddUrlScheme("chat"); string url = DomainData.GetWebviewDataURL(DomainData.WEBVIEW_INTRODUCTION); string querystring = ""; querystring = "?user_key=" + AppStartLoadBalanceManager._userKey; _webView.url = url += querystring; _webView.Load(); _webView.OnLoadComplete += OnLoadComplete; _webView.OnReceivedMessage += OnReceivedMessage; }
public void initWebviewIfNeeded() { if (webView == null) { UniWebView.SetAllowAutoPlay(true); UniWebView.SetAllowInlinePlay(true); webView = gameObject.AddComponent <UniWebView>(); webView.SetLoadWithOverviewMode(true); webView.SetBackButtonEnabled(false); //Prevent the back button from destroying and recycling the webview webView.OnShouldClose += (view) => { closeWebView(); return(false); //returning false stops the webview from being closed. }; webView.OnPageFinished += (view, statusCode, url) => { if (webviewMode == WebviewMode.offerWall) { offerWallLoading = false; adLoading = false; AdGemPlugin.offerWallExpirationDate = AdGemPlugin.CurrentTimeMillis() + (AdGemPlugin.milliesPerMinute * 300); if (AdGemManager.staticRef != null) { AdGemManager.staticRef.refreshingOfferWall = false; } failCount = 0; StartCoroutine(refreshWindowDimensions()); } if (webviewMode == WebviewMode.videoAd) { offerWallLoading = false; adLoading = false; webView.Show(); StartCoroutine(waitThenStartAdVideoWithJavascriptCall()); StartCoroutine(refreshWindowDimensions()); } }; webView.OnPageErrorReceived += (view, statusCode, errorMessage) => { if (AdGemManager.staticRef != null) { AdGemManager.staticRef.refreshingOfferWall = false; } if (failCount < 15) { failCount++; } Debug.Log("ERROR Loading web page! " + errorMessage); }; webView.OnOrientationChanged += (view, orientation) => { StartCoroutine(refreshWindowDimensions()); }; webView.AddUrlScheme("adgem"); webView.OnMessageReceived += (view, message) => { processAdgemUrlSchemeMessage(message); }; } }
/// <summary> /// Creates the web view. /// </summary> /// <returns>The web view.</returns> public void Init() { _loadingOverlay.SetActive(true); LoadingTimer.Instance.IsTimerStop(true); this.gameObject.AddComponent <UniWebView> (); _webView = this.gameObject.GetComponent <UniWebView> (); string url = DomainData.GetWebviewDataURL(DomainData.WEBVIEW_MAP) + AppStartLoadBalanceManager._userKey; // 条件しばり追加 string querystring = ""; if (EventManager.SearchEventManager.Instance._lat != "") { querystring += "&lat=" + EventManager.SearchEventManager.Instance._lat; } if (EventManager.SearchEventManager.Instance._lng != "") { querystring += "&lng=" + EventManager.SearchEventManager.Instance._lng; } if (EventManager.SearchEventManager.Instance._sex != "") { querystring += "&sex_cd=" + EventManager.SearchEventManager.Instance._sex; } if (EventManager.SearchEventManager.Instance._ageFrom != "") { querystring += "&age_from=" + EventManager.SearchEventManager.Instance._ageFrom; } if (EventManager.SearchEventManager.Instance._ageTo != "") { querystring += "&age_to=" + EventManager.SearchEventManager.Instance._ageTo; } if (EventManager.SearchEventManager.Instance._heightFrom != "") { querystring += "&height_from=" + EventManager.SearchEventManager.Instance._heightFrom; } if (EventManager.SearchEventManager.Instance._heightTo != "") { querystring += "&height_to=" + EventManager.SearchEventManager.Instance._heightTo; } if (EventManager.SearchEventManager.Instance._bodyType != "") { querystring += "&body_type=" + WWW.EscapeURL(EventManager.SearchEventManager.Instance._bodyType); } if (EventManager.SearchEventManager.Instance._isImage != "") { querystring += "&is_image=" + EventManager.SearchEventManager.Instance._isImage; } if (EventManager.SearchEventManager.Instance._keyword != "") { querystring += "&keyword=" + EventManager.SearchEventManager.Instance._keyword; } _webView.OnLoadComplete += OnLoadComplete; url += querystring; Debug.Log(url + " U R L "); _webView.url = url; _webView.backButtonEnable = false; _webView.autoShowWhenLoadComplete = true; _webView.SetTransparentBackground(true); _webView.AddUrlScheme("profile"); // 設定サイズを取得 //WebviewLayout.InsetsParameter wInsets = WebviewLayout.GetInsetsWebview (0.1785f, 0.0f, 0.097f); WebviewLayout.InsetsParameter wInsets = WebviewLayout.GetInsetsWebview(0.19f, 0.0f, 0.2f); _webView.insets = new UniWebViewEdgeInsets(wInsets.top, wInsets.side, wInsets.bottom, wInsets.side); //_webView.SetShowSpinnerWhenLoading (true); _webView.OnReceivedMessage += OnReceivedMessage; _webView.Load(); }
public void AddUrlScheme(string scheme) { #if UNITY_IOS || UNITY_ANDROID || UNITY_EDITOR uniWebView.AddUrlScheme(scheme); #endif }