public void CreateHeaderWebView() { return; if ( GameControllerBase.GetMarketKind() == GameControllerBase.MARKET.T_STORE ) { return; } if( Native.IsConnectedNetwork() ){ string display_name = "portrait"; if( App.GameControl.LandscapeMode ){ display_name = "landscape"; } m_WebView = App.CreateWebView(Property.ApiUrl + "ads/create?app=" + Property.BundleIdentifier + "&window=" + display_name + "&market=" + GameControllerBase.MarketName(), OnEvent, true); if( m_WebView != null ){ float webview_height = 0.1f; if( App.GameControl.LandscapeMode ){ webview_height = 0.15f; } int height = (int)(Screen.height * webview_height); if( App.GameControl.AddisUp ){ m_WebView.SetMargins(0, Screen.height - height, 0, 0 ); } else{ m_WebView.SetMargins(0, 0, 0, Screen.height - height); } } } }
public override void Open() { string display_name = "portrait"; if( App.GameControl.LandscapeMode ){ display_name = "landscape"; } m_WebView = App.CreateWebView(Property.ApiUrl + "ads/pickuplist?app=" + Property.BundleIdentifier + "&window=" + display_name + "&market=" + GameControllerBase.MarketName(), OnEvent, true); if( m_WebView != null ){ float rate = 0.2f; if( App.GameControl.LandscapeMode ){ rate = 0.1f; } int margin = (int)(Screen.width * rate); m_WebView.SetMargins(0, 0, 0, margin); } Native.enableAds(false); if ( ! Native.IsConnectedNetwork() ) { Native.ShowMessage(App.UI.GetCommonMessage(Message.Common_msg.RANKING_NETWORK_ERROR_TITLE ), App.UI.GetCommonMessage(Message.Common_msg.RANKING_NETWORK_ERROR_MESSAGE ), App.UI.GetCommonMessage(Message.Common_msg.RANKING_USER_NAME_ERROR_BUTTONCAPTION )); } base.Open(); }
IEnumerator Start() { webViewObject = (new GameObject("WebViewObject")).AddComponent<WebViewObject>(); webViewObject.Init((msg)=>{ Debug.Log(string.Format("CallFromJS[{0}]", msg)); status.text = msg; status.GetComponent<Animation>().Play(); }); webViewObject.SetMargins(5, 5, 5, Screen.height / 4); webViewObject.SetVisibility(true); switch (Application.platform) { case RuntimePlatform.OSXEditor: case RuntimePlatform.OSXPlayer: case RuntimePlatform.IPhonePlayer: case RuntimePlatform.Android: var src = System.IO.Path.Combine(Application.streamingAssetsPath, Url); var dst = System.IO.Path.Combine(Application.persistentDataPath, Url); var result = ""; if (src.Contains("://")) { var www = new WWW(src); yield return www; result = www.text; } else { result = System.IO.File.ReadAllText(src); } System.IO.File.WriteAllText(dst, result); webViewObject.LoadURL("file://" + dst.Replace(" ", "%20")); if (Application.platform != RuntimePlatform.Android) { webViewObject.EvaluateJS( "window.addEventListener('load', function() {" + " window.Unity = {" + " call:function(msg) {" + " var iframe = document.createElement('IFRAME');" + " iframe.setAttribute('src', 'unity:' + msg);" + " document.documentElement.appendChild(iframe);" + " iframe.parentNode.removeChild(iframe);" + " iframe = null;" + " }" + " }" + "}, false);"); } break; case RuntimePlatform.OSXWebPlayer: case RuntimePlatform.WindowsWebPlayer: webViewObject.LoadURL(Url.Replace(" ", "%20")); webViewObject.EvaluateJS( "parent.$(function() {" + " window.Unity = {" + " call:function(msg) {" + " parent.unityWebView.sendMessage('WebViewObject', msg)" + " }" + " };" + "});"); break; } }
// Use this for initialization void Start() { webViewObject = (new GameObject("WebViewObject")).AddComponent<WebViewObject>(); webViewObject.Init((msg) => { Debug.Log(msg); }); webViewObject.LoadURL("http://google.com/"); webViewObject.SetMargins(0, 0, 0, 100); webViewObject.SetVisibility(true); }
void Start() { webViewObject = (new GameObject("WebViewObject")).AddComponent<WebViewObject>(); webViewObject.Init((msg)=>{ Debug.Log(string.Format("CallFromJS[{0}]", msg)); status.text = msg; status.animation.Play(); }); webViewObject.SetMargins(5, 5, 5, 40); webViewObject.SetVisibility(true); switch (Application.platform) { case RuntimePlatform.OSXEditor: case RuntimePlatform.OSXPlayer: case RuntimePlatform.IPhonePlayer: webViewObject.LoadURL("files:/" + Application.dataPath + "/WebPlayerTemplates/unity-webview/" + Url); webViewObject.EvaluateJS( "window.addEventListener('load', function() {" + " window.Unity = {" + " call:function(msg) {" + " var iframe = document.createElement('IFRAME');" + " iframe.setAttribute('src', 'unity:' + msg);" + " document.documentElement.appendChild(iframe);" + " iframe.parentNode.removeChild(iframe);" + " iframe = null;" + " }" + " }" + "}, false);"); webViewObject.EvaluateJS( "window.addEventListener('load', function() {" + " window.addEventListener('click', function() {" + " Unity.call('clicked');" + " }, false);" + "}, false);"); break; case RuntimePlatform.OSXWebPlayer: case RuntimePlatform.WindowsWebPlayer: webViewObject.LoadURL(Url); webViewObject.EvaluateJS( "parent.$(function() {" + " window.Unity = {" + " call:function(msg) {" + " parent.unityWebView.sendMessage('WebViewObject', msg)" + " }" + " };" + " parent.$(window).click(function() {" + " window.Unity.call('clicked');" + " });" + "});"); break; } }
// Use this for initialization void Start() { wb = gameObject.GetComponent <WebViewObject>(); wb.Init((msg) => { Debug.Log(msg); }); wb.LoadURL(AssetsPath() + "/Web/index.html"); // 中央に配置 wb.SetMargins(0, 0, 0, 0); wb.SetVisibility(true); }
public void StartWebView() { string strUrl = "http://52.79.169.121/%EA%B5%90%EC%9C%A1%EC%98%81%EC%83%81/%EC%A3%BC%EB%AC%B8-%EB%B0%9B%EA%B8%B0/"; webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>(); webViewObject.Init((msg) => { Debug.Log(string.Format("CallFromJS[{0}]", msg)); }); webViewObject.LoadURL(strUrl); webViewObject.SetVisibility(true); webViewObject.SetMargins(50, 50, 50, 50); }
private void OnUnityWebviewResize(JObject msg) { Debug.Log("OnUnityWebviewResize"); if (_devices.Count > 0) { Debug.Log("screen device data: " + _devices[0].ToString()); } int h = Screen.height; if (msg["top_bar_height"] != null) { h = (int)msg["top_bar_height"] * 2; webViewHeight = h; } webViewObject.SetMargins(0, 0, 0, Screen.height - h); if (androidUIResizeMode == AndroidUIResizeMode.ResizeCamera || androidUIResizeMode == AndroidUIResizeMode.ResizeCameraAndReferenceResolution) { Camera.main.pixelRect = new Rect(0, 0, Screen.width, Screen.height - h); } }
private void InitWebView() { if (this.androidTvGameVersion != null && this.androidTvGameVersion != "") { if (webViewObject == null) { webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>(); GameObject.DontDestroyOnLoad(webViewObject.gameObject); webViewObject.Init((msg) => ProcessJS(msg)); string url = Settings.AIRCONSOLE_BASE_URL; url += "client?id=androidunity-" + Settings.VERSION; url += "&game-id=" + Application.bundleIdentifier; url += "&game-version=" + this.androidTvGameVersion; webViewObject.SetMargins(0, Screen.height, 0, -Screen.height); webViewObject.SetVisibility(true); webViewObject.LoadURL(url); //Display loading Screen webViewLoadingCanvas = (new GameObject("WebViewLoadingCanvas")).AddComponent <Canvas>(); #if !UNITY_EDITOR webViewLoadingCanvas.renderMode = RenderMode.ScreenSpaceOverlay; webViewLoadingBG = (new GameObject("WebViewLoadingBG")).AddComponent <UnityEngine.UI.Image>(); webViewLoadingImage = (new GameObject("WebViewLoadingImage")).AddComponent <UnityEngine.UI.Image>(); webViewLoadingBG.transform.SetParent(webViewLoadingCanvas.transform, true); webViewLoadingImage.transform.SetParent(webViewLoadingCanvas.transform, true); webViewLoadingImage.sprite = webViewLoadingSprite; webViewLoadingBG.color = Color.black; webViewLoadingImage.rectTransform.localPosition = new Vector3(0, 0, 0); webViewLoadingBG.rectTransform.localPosition = new Vector3(0, 0, 0); webViewLoadingImage.rectTransform.sizeDelta = new Vector2(Screen.width / 2, Screen.height / 2); webViewLoadingBG.rectTransform.sizeDelta = new Vector2(Screen.width, Screen.height); webViewLoadingImage.preserveAspect = true; if (webViewLoadingSprite == null) { webViewLoadingImage.sprite = Resources.Load("AirConsoleLogoLoadingScreen", typeof(Sprite)) as Sprite; } #endif } } else { if (Settings.debug.error) { Debug.LogError("AirConsole: for Android builds you need to provide the Game Version Identifier on the AirConsole object in the scene."); } } }
public void StartWebView(string url) { string strUrl = "http://192.168.0.8:8080/BoardGame/gameList.do"; webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>(); webViewObject.Init((msg) => { Debug.Log(string.Format("CallFromJS[{0}]", msg)); }); webViewObject.LoadURL(strUrl); webViewObject.SetVisibility(true); webViewObject.SetMargins(50, 50, 50, 50); }
public void StartWebView() { string strUrl = "http://www.fb.com"; webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>(); webViewObject.Init((msg) => { Debug.Log(string.Format("CallFromJS[{0}]", msg)); }); webViewObject.LoadURL(strUrl); webViewObject.SetVisibility(true); webViewObject.SetMargins(100, 100, 100, 100); }
//------------------------------ Public Methods ------------------------------// #region Control /// <summary> /// Load and show <paramref name="url"/> page. /// </summary> public static void LoadUrl(string url) { // Init if (m_webViewObject == null) { m_webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>(); m_webViewObject.Init( cb: unityCallback, // JS -> "Unity.call('msg'); return false;" / <a href="unity:msg"> ld: OnLoadedCallback, // Loaded anything including error page. err: OnErrorCallback, // On Error only transparent: true, //ua: "custom user agent string", enableWKWebView: true // iOS ); } #if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX m_webViewObject.bitmapRefreshCycle = 1; #endif m_webViewObject.SetMargins(m_margin.left, m_margin.top, m_margin.right, m_margin.bottom); m_webViewObject.SetVisibility(true); // Load page #if !UNITY_WEBPLAYER // Remote if (url.StartsWith("http")) { m_webViewObject.LoadURL(url.Replace(" ", "%20")); } // Local else { var dst = System.IO.Path.Combine(Application.persistentDataPath, url); m_webViewObject.LoadURL("file://" + dst.Replace(" ", "%20")); } #endif }
void Start() { #if UNITY_STANDALONE_WIN || UNITY_EDITOR #else webViewObject = webWindow.AddComponent <WebViewObject>(); webViewObject.Init((msg) => { StartCoroutine(FileDownload(msg)); } , enableWKWebView: true); webViewObject.LoadURL(url); webViewObject.SetMargins(0, 0, 60, 100); webViewObject.SetVisibility(false); #endif }
// Use this for initialization void Start() { //웹뷰 오브젝트 얻기 m_Web = gameObject.GetComponent <WebViewObject>(); //없을 경우 추가하기 if (m_Web == null) { m_Web = gameObject.AddComponent <WebViewObject>(); } m_Web.Init(RecvURL); m_Web.SetMargins(50, 150, 50, 50); m_Web.LoadURL(m_URL.text); //http:// 필수 m_Web.SetVisibility(true); }
public void StartWebView() { webView = (new GameObject("WebViewObject")).AddComponent <WebViewObject>(); webView.Init((msg) => { Debug.Log(string.Format("CallFromJS[{0}]", msg)); }, false); webView.SetMargins(0, 20, 0, 0); webView.LoadURL("https://www.tradealo.com/"); webView.SetVisibility(true); webView.EvaluateJS( "window.addEventListener('onpageshow', function(){" + "Unity.call('url:' + window.location.href);" + "}, false);"); }
void Start() { webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>(); webViewObject.Init( ld: (msg) => Debug.Log(string.Format("CallOnLoaded[{0}]", msg)), enableWKWebView: true); #if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX webViewObject.bitmapRefreshCycle = 1; #endif // お好きなMarginにしてください webViewObject.SetMargins(100, 100, 100, 100); webViewObject.SetVisibility(true); // お好きなURLにしてください webViewObject.LoadURL("https://www.google.co.jp"); }
public void StartmovieView() { Debug.Log("movieView!!!============"); string strUrl = "http://ter23api.viewlab.kr/api/movie/?cidx=1"; movieViewObject = (new GameObject("movieViewObject")).AddComponent <WebViewObject>(); movieViewObject.Init((msg) => { Debug.Log(string.Format("CallFromJS[{0}]", msg)); }); check_view = 3; movieViewObject.LoadURL(strUrl); movieViewObject.SetVisibility(true); movieViewObject.SetMargins(LeftMargins, TopMargins, RightMargins, BotMargins); }
public void openExamsView() { Debug.LogWarning("open exams web view"); webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>(); webViewObject.Init(enableWKWebView: true); webViewObject.SetMargins(0, (int)(scaleFactorRefCanvas.scaleFactor * 64), 0, 0); webViewObject.SetVisibility(true); var url = "http://timetable.spbu.ru/" + PlayerPrefs.GetString("tt_study_group_link").Replace("Primary", "Attestation"); webViewObject.LoadURL(url); examsHeader.SetActive(true); }
public override void Open() { m_WebView = App.CreateWebView(POLICY_URL + "?app=" + Property.BundleIdentifier, OnEvent, true); if( m_WebView != null ){ float rate = 0.2f; if( App.GameControl.LandscapeMode ){ rate = 0.1f; } int margin = (int)(Screen.width * rate); m_WebView.SetMargins(0, 0, 0, margin); } Native.enableAds(false); base.Open(); }
public void Search() { if (PlayerPrefs.GetString(searchWordInput.text.ToString(), "") != "") //어플리케이션에 시뮬레이션이 저장되어있는 단어일 경우 { CanvasObject.SetActive(false); temp = (GameObject)Instantiate(Resources.Load(PlayerPrefs.GetString(searchWordInput.text.ToString(), "") + "labChildren")); } else //아닐 경우, 웹사이트 사전 검색페이지로 이동 { string strUrl = "https://terms.naver.com/search.nhn?query=" + searchWordInput.text.ToString() + "&searchType=&dicType=&subject=all"; webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>(); webViewObject.Init((msg) => { Debug.Log(string.Format("CallFromJS[{0}]", msg)); }); webViewObject.LoadURL(strUrl); webViewObject.SetVisibility(true); webViewObject.SetMargins(0, 0, 0, 0); } }
public void OpenWeb(string url) { WebView webviewUI = UIController.Instance.Push("WebViewLayer").GetComponent <WebView>(); if (!isUpdateSize) { int iphonex_down = 0; if (SystemInfo.deviceModel == "iPhone10,3" || SystemInfo.deviceModel == "iPhone10,6") { iphonex_down = 68; } webViewObject.SetMargins(0, 0, 0, iphonex_down + (int)(webviewUI.GetBarHeight())); isUpdateSize = true; } homeUrl = url; webViewObject.SetVisibility(true); webViewObject.LoadURL(url.Replace(" ", "%20")); }
public void StartWebView() { //https.GetComponent<https>() Debug.Log("webView!!!============"); string strUrl = "http://ter23chat.viewlab.co.kr/chat?userId=" + GameManager.idSave + "&roomName=" + GameManager.seqSave + "_" + GameManager.channelSave; Debug.Log("webView = " + strUrl); //h ttp://ter23chat.viewlab.co.kr/chat?userId=유저아이디&roomName=주제시퀀스_채널번호 webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>(); webViewObject.Init((msg) => { Debug.Log(string.Format("CallFromJS[{0}]", msg)); }); check_view = 2; webViewObject.LoadURL(strUrl); webViewObject.SetVisibility(true); webViewObject.SetMargins(LeftMargins, TopMargins, RightMargins, BotMargins); }
private void OnEnable() { _object = new GameObject($"webview-{++_counter:X4}"); _webview = _object.AddComponent <WebViewObject>(); _webview.Init( ld: OnWebviewLoaded, enableWKWebView: true ); _webview.SetVisibility(_visible = visible); _webview.SetMargins(0, 0, 0, 0); Debug.Log("webview init"); var path = Path.Combine(Application.streamingAssetsPath, "sample.html"); var data = File.ReadAllBytes(path); Debug.Log($"html loaded: {data.Length} bytes"); _webview.LoadHTML(Encoding.UTF8.GetString(data), null); }
private void ShowWebLayer() { webLayerObj = Instantiate(webLayerPb, canvsTf); Button closeBtn = webLayerObj.GetComponentInChildren <Button>(); closeBtn.onClick.AddListener(() => { Destroy(webLayerObj); }); Vector2 btnSize = closeBtn.GetComponent <RectTransform>().sizeDelta; WebViewObject wvobj = webLayerObj.GetComponentInChildren <WebViewObject>(); wvobj.Init(); int realheight = GetWidgetRealPixel(canvsTf, btnSize.y); wvobj.SetMargins(0, 0, 0, realheight); wvobj.LoadURL(url.Replace(" ", "%20")); wvobj.SetVisibility(true); }
public void Open(string url) { if (webViewObject == null) { return; } try { webViewObject.Init(); webViewObject.LoadURL(url + Common.CO.WEBVIEW_KEY); webViewObject.SetMargins(0, 0, 0, 110); webViewObject.SetVisibility(true); webViewCanvas.SetActive(true); } catch { Application.OpenURL(url); } }
// Update is called once per frame void Update() { if (Application.platform == RuntimePlatform.Android) { //BotMargins = GameManager.chatSizebot; //text1.text = "TouchScreenKeyboard.isSupported : " + GetKeyboardSize(); if (GetKeyboardSize() != 0) { testbool = GetKeyboardSize(); } else { testbool = 0; } } switch (check_view) { case 1: signupViewObject.SetMargins(0, 0, 0, 0 + testbool); break; case 2: webViewObject.SetMargins(LeftMargins, TopMargins, RightMargins, BotMargins + testbool); break; case 3: movieViewObject.SetMargins(LeftMargins, TopMargins, RightMargins, BotMargins + testbool); break; case 4: webViewObject.SetMargins(myMagins[1].LeftMargins, myMagins[1].TopMargins, myMagins[1].RightMargins, myMagins[1].BotMargins); break; case 5: webViewObject.SetMargins(myMagins[2].LeftMargins, myMagins[2].TopMargins, myMagins[2].RightMargins, myMagins[2].BotMargins); break; } }
void Start() { webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>(); webViewObject.Init((msg) => { if (msg == "clicked") { Debug.Log("hogehogehogehoge"); } }); webViewObject.LoadURL(url); webViewObject.SetVisibility(true); webViewObject.EvaluateJS( "window.addEventListener('load', function() {" + " window.addEventListener('click', function() {" + " Unity.call('clicked');" + " }, false);" + "}, false);"); webViewObject.SetMargins(0, 0, 0, 100); //下に100pxマージンを取る }
public void show() { if (webViewObject == null) { webViewObject = GetComponent<WebViewObject>(); webViewObject.Init(); webViewObject.LoadURL(url); webViewObject.SetMargins(0,58,0,0); // マージン(単位px) 左、上、右、下 Debug.Log("nai"); } else Debug.Log("aru"); webViewObject.SetVisibility(true); _bg.SetActive(true); _closeButton.SetActive(true); Util.Resource.getModel().GetComponent<Model>().pause(); }
// Start is called before the first frame update void Start() { // ジャンル番号を受け取る int Genre = ButtonScript.getterNumber(); // ここに料理名を渡してあげる string encodeStr = HttpUtility.UrlEncode(urls[Genre, ChangeSprite.urlName]); string formalUrl = SearchURL + encodeStr; webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject> (); webViewObject.Init( ld: (msg) => Debug.Log(string.Format("CallOnLoaded[{0}]", msg)), enableWKWebView: true); // iPhoneの外枠からのマージン設定 webViewObject.SetMargins(0, 0, 0, 0); webViewObject.SetVisibility(true); // このURLのサイトを開く webViewObject.LoadURL(formalUrl); }
/// <summary> /// マージンのセット。 /// </summary> void SetMargin() { var viewRect = transform.GetComponent <RectTransform>(); // 角の座標を取得。 var rectCorners = new Vector3[4]; viewRect.GetWorldCorners(rectCorners); // World座標からスクリーン座標に変換。 var uiCamera = webViewCanvas.worldCamera; var upperLeft = RectTransformUtility.WorldToScreenPoint(uiCamera, rectCorners[1]); var lowerRight = RectTransformUtility.WorldToScreenPoint(uiCamera, rectCorners[3]); var margin = new Vector4(upperLeft.x, Screen.height - upperLeft.y, Screen.width - lowerRight.x, lowerRight.y); if (webView != null) { webView.SetMargins((int)margin.x, (int)margin.y, (int)margin.z, (int)margin.w); } }
// Use this for initialization void Start() { // プラグインの読み込み webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>(); // インスタンス生成 webViewObject.Init( // JSコールバック cb: (msg) => { Debug.Log(string.Format("CallFromJS[{0}]", msg)); // status.text = msg; // status.GetComponent<Animation>().Play(); }, // エラーコールバック err: (msg) => { Debug.Log(string.Format("CallOnError[{0}]", msg)); // status.text = msg; // status.GetComponent<Animation>().Play(); }, // ロード時コールバック ld: (msg) => { Debug.Log(string.Format("CallOnLoaded[{0}]", msg)); }, // iPhone webkit webview で起動 enableWKWebView: true); // 全画面描画 // webViewObject.SetMargins (left, top, right, bottom); webViewObject.SetMargins(0, 0, 0, 0); // 描画開始 webViewObject.SetVisibility(true); // URLの読み込み開始 webViewObject.LoadURL(url); }
void Start() { webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>(); webViewObject.Init((msg) => { Debug.Log(msg); }); webViewObject.LoadURL(url); BlogTitlePanel = GameObject.FindGameObjectsWithTag("BlogTitlePanel"); float topMargin = BlogTitlePanel[0].GetComponent <RectTransform>().sizeDelta.y; Debug.Log("topMargin:" + topMargin); BottomNavigationBar = GameObject.FindGameObjectsWithTag("BottomNavigationBar"); float bottomMargin = BottomNavigationBar[0].GetComponent <RectTransform>().sizeDelta.y *BottomNavigationBar[0].GetComponent <RectTransform>().localScale.y; Debug.Log("bottomMargin:" + bottomMargin); webViewObject.SetMargins(0, (int)topMargin, 0, (int)bottomMargin); webViewObject.SetVisibility(false); webViewObject.transform.SetParent(parent); }
public void OpenWebView() { webViewPanel.gameObject.SetActive(true); webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>(); webViewObject.Init((msg) => { // Dev.Log(string.Format("CallFromJS[{0}]", msg)); //if (msg == "close") //CloseAll(); }); int webViewWidth = (int)(( Screen.height - (Screen.height / varticalMarginOffset) * 2.2f) * (contentsPanel.sizeDelta.x / contentsPanel.sizeDelta.y)); webViewObject.SetMargins( (int)((float)(Screen.width - webViewWidth) / 2), (int)(Screen.height / (varticalMarginOffset - 2)), (int)((float)(Screen.width - webViewWidth) / 2), (int)((Screen.height / (varticalMarginOffset - 2)) * 1.2f) ); webViewObject.LoadURL(webViewURL); }
public void StartSignup() { data = System.DateTime.Now.Ticks; string strUrl = "http://ter23api.viewlab.kr/cpc/checkplus_main.php?user_id=" + data; Debug.Log("webView = " + strUrl); signupViewObject = (new GameObject("signupViewObject")).AddComponent <WebViewObject>(); signupViewObject.Init((msg) => { Debug.Log(string.Format("CallFromJS[{0}]", msg)); }); check_view = 1; signupViewObject.LoadURL(strUrl); signupViewObject.SetVisibility(true); signupViewObject.SetMargins(0, 0, 0, 0 + testbool); https.GetComponent <https>().signCheckdata_r.checkNum = data.ToString(); https.GetComponent <https>().Sign_check(); }
void Start() #endif { webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>(); webViewObject.Init((msg) => { Debug.Log(string.Format("CallFromJS[{0}]", msg)); status.text = msg; status.GetComponent <Animation>().Play(); }); webViewObject.SetMargins(5, 5, 5, Screen.height / 4); webViewObject.SetVisibility(true); switch (Application.platform) { #if !UNITY_WEBPLAYER case RuntimePlatform.OSXEditor: case RuntimePlatform.OSXPlayer: case RuntimePlatform.IPhonePlayer: case RuntimePlatform.Android: if (Url.StartsWith("http")) { webViewObject.LoadURL(Url.Replace(" ", "%20")); } else { var src = System.IO.Path.Combine(Application.streamingAssetsPath, Url); var dst = System.IO.Path.Combine(Application.persistentDataPath, Url); var result = ""; if (src.Contains("://")) { var www = new WWW(src); yield return(www); result = www.text; } else { result = System.IO.File.ReadAllText(src); } System.IO.File.WriteAllText(dst, result); webViewObject.LoadURL("file://" + dst.Replace(" ", "%20")); } if (Application.platform != RuntimePlatform.Android) { webViewObject.EvaluateJS( "window.addEventListener('load', function() {" + " window.Unity = {"+ " call:function(msg) {"+ " var iframe = document.createElement('IFRAME');"+ " iframe.setAttribute('src', 'unity:' + msg);"+ " document.documentElement.appendChild(iframe);"+ " iframe.parentNode.removeChild(iframe);"+ " iframe = null;"+ " }"+ " }"+ "}, false);"); } break; #else case RuntimePlatform.OSXWebPlayer: case RuntimePlatform.WindowsWebPlayer: webViewObject.LoadURL(Url.Replace(" ", "%20")); webViewObject.EvaluateJS( "parent.$(function() {" + " window.Unity = {"+ " call:function(msg) {"+ " parent.unityWebView.sendMessage('WebViewObject', msg)"+ " }"+ " };"+ "});"); break; #endif } }
void Start() { //listen for GooglePlayConnection events /*GooglePlayConnection.instance.addEventListener(GooglePlayConnection.PLAYER_CONNECTED, OnPlayerConnected); GooglePlayConnection.instance.addEventListener(GooglePlayConnection.PLAYER_DISCONNECTED, OnPlayerDisconnected); GooglePlayConnection.ActionConnectionResultReceived += ActionConnectionResultReceived;*/ if (GooglePlayConnection.state == GPConnectionState.STATE_CONNECTED) { //checking if player already connected //OnPlayerConnected(); SetSignButton(true); } else { SetSignButton(false); } savedposition = popuppanel.transform.position; savedposition.y -= 0.2f; EventDelegate.Add(BBack.GetComponent<UIEventTrigger>().onClick, GameObject.Find("UI Manager").GetComponent<UIManager>().gotoLobby); if (WebviewCloseButton != null) { WebviewCloseButton.gameObject.SetActive(false); } if (WebviewBlackOut != null) { WebviewBlackOut.SetActive(false); } if (Application.platform == RuntimePlatform.Android) { webViewObject = (new GameObject("WebViewObject")).AddComponent<WebViewObject>(); webViewObject.Init((msg) => { Debug.Log(string.Format("CallFromJS[{0}]", msg)); }); webViewObject.SetMargins(0, 50, 0, 0); strBuffer.Remove(0, strBuffer.Length); strBuffer.Append("http://intragames.iptime.org:9201/index.php?uid="); if (PacketManager.instance.packetHandler[PacketManager.PacketID.ROBBY] != null) { RobbyPacket robbyPacket = PacketManager.instance.packetHandler[PacketManager.PacketID.ROBBY] as RobbyPacket; if (robbyPacket != null) { strBuffer.Append(robbyPacket.responseData.GetProfileUID().ToString()); strBuffer.Append("&cnno=1"); webViewObject.LoadURL(strBuffer.ToString()); webViewObject.SetVisibility(false); } } } }
IEnumerator Start() { webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>(); webViewObject.Init( cb: (msg) => { Debug.Log(string.Format("CallFromJS[{0}]", msg)); status.text = msg; status.GetComponent <Animation>().Play(); }, err: (msg) => { Debug.Log(string.Format("CallOnError[{0}]", msg)); status.text = msg; status.GetComponent <Animation>().Play(); }, started: (msg) => { Debug.Log(string.Format("CallOnStarted[{0}]", msg)); }, hooked: (msg) => { Debug.Log(string.Format("CallOnHooked[{0}]", msg)); }, ld: (msg) => { Debug.Log(string.Format("CallOnLoaded[{0}]", msg)); #if UNITY_EDITOR_OSX || (!UNITY_ANDROID && !UNITY_WEBPLAYER && !UNITY_WEBGL) // NOTE: depending on the situation, you might prefer // the 'iframe' approach. // cf. https://github.com/gree/unity-webview/issues/189 #if true webViewObject.EvaluateJS(@" if (window && window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.unityControl) { window.Unity = { call: function(msg) { window.webkit.messageHandlers.unityControl.postMessage(msg); } } } else { window.Unity = { call: function(msg) { window.location = 'unity:' + msg; } } } "); #else webViewObject.EvaluateJS(@" if (window && window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.unityControl) { window.Unity = { call: function(msg) { window.webkit.messageHandlers.unityControl.postMessage(msg); } } } else { window.Unity = { call: function(msg) { var iframe = document.createElement('IFRAME'); iframe.setAttribute('src', 'unity:' + msg); document.documentElement.appendChild(iframe); iframe.parentNode.removeChild(iframe); iframe = null; } } } "); #endif #elif UNITY_WEBPLAYER || UNITY_WEBGL webViewObject.EvaluateJS( "window.Unity = {" + " call:function(msg) {" + " parent.unityWebView.sendMessage('WebViewObject', msg)" + " }" + "};"); #endif webViewObject.EvaluateJS(@"Unity.call('ua=' + navigator.userAgent)"); }, //transparent: false, //zoom: true, //ua: "custom user agent string", #if UNITY_EDITOR separated: false, #endif //androidForceDarkMode: 0, // 0: follow system setting, 1: force dark off, 2: force dark on enableWKWebView: true, wkContentMode: 0); // 0: recommended, 1: mobile, 2: desktop #if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX webViewObject.bitmapRefreshCycle = 1; #endif // cf. https://github.com/gree/unity-webview/pull/512 // Added alertDialogEnabled flag to enable/disable alert/confirm/prompt dialogs. by KojiNakamaru · Pull Request #512 · gree/unity-webview //webViewObject.SetAlertDialogEnabled(false); // cf. https://github.com/gree/unity-webview/pull/550 // introduced SetURLPattern(..., hookPattern). by KojiNakamaru · Pull Request #550 · gree/unity-webview //webViewObject.SetURLPattern("", "^https://.*youtube.com", "^https://.*google.com"); // cf. https://github.com/gree/unity-webview/pull/570 // Add BASIC authentication feature (Android and iOS with WKWebView only) by takeh1k0 · Pull Request #570 · gree/unity-webview //webViewObject.SetBasicAuthInfo("id", "password"); webViewObject.SetMargins(5, 100, 5, Screen.height / 4); webViewObject.SetTextZoom(100); // android only. cf. https://stackoverflow.com/questions/21647641/android-webview-set-font-size-system-default/47017410#47017410 webViewObject.SetVisibility(true); #if !UNITY_WEBPLAYER && !UNITY_WEBGL if (Url.StartsWith("http")) { webViewObject.LoadURL(Url.Replace(" ", "%20")); } else { var exts = new string[] { ".jpg", ".js", ".html" // should be last }; foreach (var ext in exts) { var url = Url.Replace(".html", ext); var src = System.IO.Path.Combine(Application.streamingAssetsPath, url); var dst = System.IO.Path.Combine(Application.persistentDataPath, url); byte[] result = null; if (src.Contains("://")) // for Android { #if UNITY_2018_4_OR_NEWER // NOTE: a more complete code that utilizes UnityWebRequest can be found in https://github.com/gree/unity-webview/commit/2a07e82f760a8495aa3a77a23453f384869caba7#diff-4379160fa4c2a287f414c07eb10ee36d var unityWebRequest = UnityWebRequest.Get(src); yield return(unityWebRequest.SendWebRequest()); result = unityWebRequest.downloadHandler.data; #else var www = new WWW(src); yield return(www); result = www.bytes; #endif } else { result = System.IO.File.ReadAllBytes(src); } System.IO.File.WriteAllBytes(dst, result); if (ext == ".html") { webViewObject.LoadURL("file://" + dst.Replace(" ", "%20")); break; } } } #else if (Url.StartsWith("http")) { webViewObject.LoadURL(Url.Replace(" ", "%20")); } else { webViewObject.LoadURL("StreamingAssets/" + Url.Replace(" ", "%20")); } #endif yield break; }
IEnumerator Start() { webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>(); webViewObject.Init( cb: (msg) => { Debug.Log(string.Format("CallFromJS[{0}]", msg)); }, err: (msg) => { Debug.Log(string.Format("CallOnError[{0}]", msg)); }, started: (msg) => { Debug.Log(string.Format("CallOnStarted[{0}]", msg)); }, ld: (msg) => { Debug.Log(string.Format("CallOnLoaded[{0}]", msg)); #if UNITY_EDITOR_OSX || !UNITY_ANDROID // NOTE: depending on the situation, you might prefer // the 'iframe' approach. // cf. https://github.com/gree/unity-webview/issues/189 #if true webViewObject.EvaluateJS(@" if (window && window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.unityControl) { window.Unity = { call: function(msg) { window.webkit.messageHandlers.unityControl.postMessage(msg); } } } else { window.Unity = { call: function(msg) { window.location = 'unity:' + msg; } } } "); #else webViewObject.EvaluateJS(@" if (window && window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.unityControl) { window.Unity = { call: function(msg) { window.webkit.messageHandlers.unityControl.postMessage(msg); } } } else { window.Unity = { call: function(msg) { var iframe = document.createElement('IFRAME'); iframe.setAttribute('src', 'unity:' + msg); document.documentElement.appendChild(iframe); iframe.parentNode.removeChild(iframe); iframe = null; } } } "); #endif #endif webViewObject.EvaluateJS(@"Unity.call('ua=' + navigator.userAgent)"); }, //ua: "custom user agent string", enableWKWebView: true); #if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX webViewObject.bitmapRefreshCycle = 1; #endif var safeArea = GetSafeArea(); Debug.Log("ScreenSize:" + "w_" + Screen.width + ",h_" + Screen.height); Debug.Log("SafeArea:" + "width_" + safeArea.width + ",height_" + safeArea.height + ",x_" + safeArea.x + ",y_" + safeArea.y); webViewObject.SetMargins( TransCanvasScalerResolutionToScreenResolution(webViewLeftMargin) + (int)(((Screen.width - safeArea.width) / 2)), TransCanvasScalerResolutionToScreenResolution(webViewTopMargin) + (int)(((Screen.height - safeArea.height) / 2)), TransCanvasScalerResolutionToScreenResolution(webViewRightMargin) + (int)(((Screen.width - safeArea.width) / 2)), TransCanvasScalerResolutionToScreenResolution(webViewDownMargin) + (int)(((Screen.height - safeArea.height) / 2))); webViewObject.SetVisibility(true); #if !UNITY_WEBPLAYER if (Url.StartsWith("http")) { webViewObject.LoadURL(Url.Replace(" ", "%20")); } else { var exts = new string[] { ".jpg", ".js", ".html" // should be last }; foreach (var ext in exts) { var url = Url.Replace(".html", ext); var src = System.IO.Path.Combine(Application.streamingAssetsPath, url); var dst = System.IO.Path.Combine(Application.persistentDataPath, url); byte[] result = null; if (src.Contains("://")) // for Android { var www = new WWW(src); yield return(www); result = www.bytes; } else { result = System.IO.File.ReadAllBytes(src); } System.IO.File.WriteAllBytes(dst, result); if (ext == ".html") { webViewObject.LoadURL("file://" + dst.Replace(" ", "%20")); break; } } } #else if (Url.StartsWith("http")) { webViewObject.LoadURL(Url.Replace(" ", "%20")); } else { webViewObject.LoadURL("StreamingAssets/" + Url.Replace(" ", "%20")); } webViewObject.EvaluateJS( "parent.$(function() {" + " window.Unity = {" + " call:function(msg) {" + " parent.unityWebView.sendMessage('WebViewObject', msg)" + " }" + " };" + "});"); #endif yield break; }
private void InitWebView() { if (this.androidTvGameVersion != null && this.androidTvGameVersion != "") { if(webViewObject == null) { webViewObject = (new GameObject("WebViewObject")).AddComponent<WebViewObject>(); GameObject.DontDestroyOnLoad(webViewObject.gameObject); webViewObject.Init((msg) => ProcessJS(msg)); string url = Settings.AIRCONSOLE_BASE_URL; url += "client?id=androidunity-" + Settings.VERSION; url += "&game-id=" + Application.bundleIdentifier; url += "&game-version=" + this.androidTvGameVersion; webViewObject.SetMargins(0, Screen.height, 0, -Screen.height); webViewObject.SetVisibility(true); webViewObject.LoadURL(url); //Display loading Screen webViewLoadingCanvas = (new GameObject("WebViewLoadingCanvas")).AddComponent<Canvas>(); #if !UNITY_EDITOR webViewLoadingCanvas.renderMode = RenderMode.ScreenSpaceOverlay; webViewLoadingBG = (new GameObject("WebViewLoadingBG")).AddComponent<UnityEngine.UI.Image>(); webViewLoadingImage = (new GameObject("WebViewLoadingImage")).AddComponent<UnityEngine.UI.Image>(); webViewLoadingBG.transform.SetParent(webViewLoadingCanvas.transform, true); webViewLoadingImage.transform.SetParent(webViewLoadingCanvas.transform, true); webViewLoadingImage.sprite = webViewLoadingSprite; webViewLoadingBG.color = Color.black; webViewLoadingImage.rectTransform.localPosition = new Vector3 (0, 0, 0); webViewLoadingBG.rectTransform.localPosition = new Vector3 (0, 0, 0); webViewLoadingImage.rectTransform.sizeDelta = new Vector2 (Screen.width / 2, Screen.height / 2); webViewLoadingBG.rectTransform.sizeDelta = new Vector2 (Screen.width, Screen.height); webViewLoadingImage.preserveAspect = true; if (webViewLoadingSprite == null){ webViewLoadingImage.sprite = Resources.Load("AirConsoleLogoLoadingScreen", typeof(Sprite)) as Sprite; } #endif } } else { if (Settings.debug.error) { Debug.LogError("AirConsole: for Android builds you need to provide the Game Version Identifier on the AirConsole object in the scene."); } } }
IEnumerator Start() { webViewObject = (new GameObject("WebViewObject")).AddComponent<WebViewObject>(); webViewObject.Init( cb: (msg) => { Debug.Log(string.Format("CallFromJS[{0}]", msg)); status.text = msg; status.GetComponent<Animation>().Play(); }, err: (msg) => { Debug.Log(string.Format("CallOnError[{0}]", msg)); status.text = msg; status.GetComponent<Animation>().Play(); }, ld: (msg) => { Debug.Log(string.Format("CallOnLoaded[{0}]", msg)); #if !UNITY_ANDROID webViewObject.EvaluateJS(@" window.Unity = { call: function(msg) { var iframe = document.createElement('IFRAME'); iframe.setAttribute('src', 'unity:' + msg); document.documentElement.appendChild(iframe); iframe.parentNode.removeChild(iframe); iframe = null; } } "); #endif }, enableWKWebView: true); webViewObject.SetMargins(5, 100, 5, Screen.height / 4); webViewObject.SetVisibility(true); #if !UNITY_WEBPLAYER if (Url.StartsWith("http")) { webViewObject.LoadURL(Url.Replace(" ", "%20")); } else { var exts = new string[]{ ".jpg", ".html" // should be last }; foreach (var ext in exts) { var url = Url.Replace(".html", ext); var src = System.IO.Path.Combine(Application.streamingAssetsPath, url); var dst = System.IO.Path.Combine(Application.persistentDataPath, url); byte[] result = null; if (src.Contains("://")) { // for Android var www = new WWW(src); yield return www; result = www.bytes; } else { result = System.IO.File.ReadAllBytes(src); } System.IO.File.WriteAllBytes(dst, result); if (ext == ".html") { webViewObject.LoadURL("file://" + dst.Replace(" ", "%20")); break; } } } #else if (Url.StartsWith("http")) { webViewObject.LoadURL(Url.Replace(" ", "%20")); } else { webViewObject.LoadURL("StreamingAssets/" + Url.Replace(" ", "%20")); } webViewObject.EvaluateJS( "parent.$(function() {" + " window.Unity = {" + " call:function(msg) {" + " parent.unityWebView.sendMessage('WebViewObject', msg)" + " }" + " };" + "});"); #endif yield break; }