Пример #1
0
    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);
                }
            }
        }
    }
Пример #2
0
        public override void initState()
        {
            base.initState();
            if (!Application.isEditor)
            {
                this._webViewObject = WebViewManager.instance.getWebView();
                this._webViewObject.Init(
                    ua: "",
                    enableWKWebView: true,
                    transparent: true,
                    started: start => {
                    using (WindowProvider.of(this.context).getScope()) {
                        this.startProgress();
                    }
                },
                    ld: ld => {
                    using (WindowProvider.of(this.context).getScope()) {
                        this.stopProgress();
                    }
                }
                    );
                this._webViewObject.ClearCookies();
                if (HttpManager.getCookie().isNotEmpty())
                {
                    this._webViewObject.AddCustomHeader("Cookie", HttpManager.getCookie());
                }

                this._webViewObject.LoadURL(this.widget.url);
                this._webViewObject.SetVisibility(true);
            }

            this._progress = 0;
            this._onClose  = false;
        }
Пример #3
0
    private void Initialize()
    {
        if (webViewObject != null)
        {
            webViewObject.SetVisibility(true);
        }
        else
        {
            webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>();

            webViewObject.Init(ld: (msg) =>
            {
                Debug.Log(string.Format("CallOnLoaded[{0}]", msg));
                URL = msg;
            });

            webViewObject.SetCenterPositionWithScale(Vector2.zero + Vector2.up * Screen.height * 0.1f, new Vector2(Screen.width, Screen.height * 0.8f));

            webViewObject.SetVisibility(true);

            webViewObject.AddCustomHeader("QWE", "!");

            webViewObject.LoadURL(URL);

            UIInstance.instance.StartTutorial();
        }

        Time.timeScale = 0;
    }
Пример #4
0
        private IEnumerator InitWeb(string _url)
        {
            webViewGameObject = new GameObject("WebViewObject");
            webViewObject     = webViewGameObject.AddComponent <WebViewObject>();
            webViewObject.Init(
                cb: (msg) => {
                Debug.Log(string.Format("CallFromJS[{0}]", msg));
            },
                err: (msg) => {
                Debug.Log(string.Format("CallOnError[{0}]", msg));
            },
                ld: (msg) => {
                Debug.Log(string.Format("CallOnLoaded[{0}]", msg));
                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

            webViewObject.SetMargins(marginLeft, marginTop, marginRight, marginBottom);
            webViewObject.SetVisibility(true);

            webViewObject.LoadURL(_url);

            yield break;
        }
    public void Open(string url, Action <string> _onClose = null)
    {
        //IL_0009: Unknown result type (might be due to invalid IL or missing references)
        onClose       = _onClose;
        webViewObject = this.get_gameObject().AddComponent <WebViewObject>();
        webViewObject.Init(string.Empty, string.Empty, string.Empty);
        webViewObject.EvaluateJS("var appVersion='" + NetworkNative.getNativeVersionName() + "';");
        webViewObject.SetCookie(NetworkManager.APP_HOST, "apv", NetworkNative.getNativeVersionName());
        if (MonoBehaviourSingleton <AccountManager> .I.account.token != string.Empty)
        {
            string[] array = MonoBehaviourSingleton <AccountManager> .I.account.token.Split('=');

            webViewObject.SetCookie(NetworkManager.APP_HOST, array[0], array[1]);
        }
        webViewObject.LoadURL(url);
        webViewObject.SetVisibility(true);
        int num  = Screen.get_width();
        int num2 = Screen.get_height();

        if (MonoBehaviourSingleton <AppMain> .IsValid())
        {
            num  = MonoBehaviourSingleton <AppMain> .I.defaultScreenWidth;
            num2 = MonoBehaviourSingleton <AppMain> .I.defaultScreenHeight;
        }
        int left   = (int)((float)num * m_Margine.get_xMin());
        int top    = (int)((float)num2 * m_Margine.get_yMin());
        int right  = (int)((float)num * m_Margine.get_width());
        int bottom = (int)((float)num2 * m_Margine.get_height());

        webViewObject.SetMargins(left, top, right, bottom);
    }
Пример #6
0
    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();
    }
 static int QPYX_SetMargins_YXQP(IntPtr L_YXQP)
 {
     try
     {
         int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP);
         if (QPYX_count_YXQP == 4)
         {
             WebViewObject          QPYX_obj_YXQP  = (WebViewObject)ToLua.CheckObject <WebViewObject>(L_YXQP, 1);
             UnityEngine.Camera     QPYX_arg0_YXQP = (UnityEngine.Camera)ToLua.CheckObject(L_YXQP, 2, typeof(UnityEngine.Camera));
             UnityEngine.GameObject QPYX_arg1_YXQP = (UnityEngine.GameObject)ToLua.CheckObject(L_YXQP, 3, typeof(UnityEngine.GameObject));
             UnityEngine.GameObject QPYX_arg2_YXQP = (UnityEngine.GameObject)ToLua.CheckObject(L_YXQP, 4, typeof(UnityEngine.GameObject));
             QPYX_obj_YXQP.SetMargins(QPYX_arg0_YXQP, QPYX_arg1_YXQP, QPYX_arg2_YXQP);
             return(0);
         }
         else if (QPYX_count_YXQP == 5)
         {
             WebViewObject QPYX_obj_YXQP  = (WebViewObject)ToLua.CheckObject <WebViewObject>(L_YXQP, 1);
             int           QPYX_arg0_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 2);
             int           QPYX_arg1_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 3);
             int           QPYX_arg2_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 4);
             int           QPYX_arg3_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 5);
             QPYX_obj_YXQP.SetMargins(QPYX_arg0_YXQP, QPYX_arg1_YXQP, QPYX_arg2_YXQP, QPYX_arg3_YXQP);
             return(0);
         }
         else
         {
             return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: WebViewObject.SetMargins"));
         }
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
Пример #8
0
    void OnDestroy()
    {
#if UNITY_EDITOR && (UNITY_STANDALONE_OSX)
        if (webView == IntPtr.Zero)
        {
            return;
        }
        _WebViewPlugin_Destroy(webView);
#elif UNITY_IPHONE && ENABLE_WEBVIEW
        if (webView == IntPtr.Zero)
        {
            return;
        }
        _WebViewPlugin_Destroy(webView);
#elif UNITY_ANDROID
        if (webView == null)
        {
            return;
        }
        webView.Call("Destroy");
#elif UNITY_WEBPLAYER
        Application.ExternalCall("unityWebView.destroy", name);
#endif
        s_mInstance = null;
    }
Пример #9
0
 private void OnDisable()
 {
     Debug.Log("webview destroy");
     Destroy(_object);
     _object  = null;
     _webview = null;
 }
    public void OnClick()
    {
        // すでに開かれている場合は閉じる
        if (_view != null && _view.GetVisibility())
        {
            _view.SetVisibility(false);
        }

        // URL取得
        string url = GetURL();

        // Webページに飛ぶ
        if (_isJumpPage)
        {
            Application.OpenURL(url);
            return;
        }

        // WebViewで表示
        if (_webViewObj == null)
        {
            Debug.LogError("WebViewObjectがアタッチされていません。");
            return;
        }
        _view = Instantiate(_webViewObj);
        _view.Init(null);
        _view.LoadURL(url);
        _view.SetMargins(Screen.width / WEB_PAGE_MARGIN, Screen.height / WEB_PAGE_MARGIN, Screen.width / WEB_PAGE_MARGIN, Screen.height / WEB_PAGE_MARGIN);
        _view.SetVisibility(true);
    }
Пример #11
0
        public static void SetRectTransformMargin(this WebViewObject webViewObject, RectTransform rectTransform)
        {
            var canvas  = rectTransform.GetComponentInParent <Canvas>();
            var camera  = canvas.worldCamera;
            var corners = new Vector3[4];

            rectTransform.GetWorldCorners(corners);

            var screenCorner1 = RectTransformUtility.WorldToScreenPoint(camera, corners[1]);
            var screenCorner3 = RectTransformUtility.WorldToScreenPoint(camera, corners[3]);

            var rect = new Rect();

            rect.x      = screenCorner1.x;
            rect.width  = screenCorner3.x - rect.x;
            rect.y      = screenCorner3.y;
            rect.height = screenCorner1.y - rect.y;

            webViewObject.SetMargins
            (
                (int)rect.xMin,
                Screen.height - (int)rect.yMax,
                Screen.width - (int)rect.xMax,
                (int)rect.yMin
            );
        }
 private static void InitializeWebView()
 {
     mWebView = new GameObject("WebView").AddComponent <WebViewObject>();
     mWebView.Init(cb: OnWebCallback, ld: OnWebLoaded, started: OnWebStarted, enableWKWebView: true,
                   err: (x) => WebLog("err", x),
                   httpErr: (x) => WebLog("httpErr", x));
 }
Пример #13
0
    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;
        }
    }
Пример #14
0
    IEnumerator Start()
    {
        yield return(new WaitForSeconds(0.1f));

        webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>();

        Init();
    }
Пример #15
0
 public void initWebView()
 {
     webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>();
     webViewObject.Init((msg) => {
         Debug.Log(string.Format("CallFromJS[{0}]", msg));
     });
     webViewObject.SetVisibility(true);
 }
Пример #16
0
    private void Awake()
    {
        web = gameObject.GetComponent <WebViewObject>();

        if (web == null)
        {
            web = gameObject.AddComponent <WebViewObject>();
        }
    }
Пример #17
0
        public IEnumerator StartWebView(string s)
        {
            yield return(new WaitForSeconds(3));

            webViewObject = (new GameObject(this.GetType().Name)).AddComponent <WebViewObject>();

            webViewObject.Init(transparent: true,
                               cb: (msg) =>
            {
                Debug.Log($"message from WV: {msg}");
            },

                               err: msg =>
            {
                Debug.LogError($"webView error: {msg}");
            },
                               // err: msg =>
                               // {
                               //     Debug.LogError($"webView error: {msg}");
                               // },

                               // ld: (msg) =>
                               // {
                               //     Debug.Log(string.Format("CallOnLoaded[{0}]", msg));
                               //     // NOTE: depending on the situation, you might prefer
                               //     // the 'iframe' approach.
                               //     // cf. https://github.com/gree/unity-webview/issues/189
                               //
                               //     //webViewObject.EvaluateJS($"UnityIncoming({dataJson})");
                               //
                               //     //webViewObject.SetVisibility(true);
                               // },
                               // //ua: "custom user agent string",
#if UNITY_EDITOR
                               separated: false,
#endif
                               enableWKWebView: true);
#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(0, 0, 0, 0);
            webViewObject.SetVisibility(true);

            webViewObject.LoadURL(s.Replace(" ", "%20"));
        }
Пример #18
0
 static public void Init(WebViewObject webObj)
 {
     if (instance == null)
     {
         instance = new WebViewManager();
         instance.webViewObject = webObj;
         instance.InitWebView();
     }
 }
Пример #19
0
    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;
        }
    }
Пример #20
0
 void Init()
 {
     _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) => { _webViewObject.SetVisibility(true); }, enableWKWebView: true,
         transparent: true);
 }
 // 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);
 }
Пример #22
0
 // 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);
 }
Пример #23
0
    public void WebButton()
    {
        string strUrl = "https://greenapple16.tistory.com/79?category=811357";

        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);
    }
Пример #24
0
 void Start()
 {
     webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>();
     webViewObject.Init((msg) => {
         Debug.Log(msg);
     });
     webViewObject.LoadURL(url);
     // 中央に配置
     webViewObject.SetMargins(Screen.width / 4, Screen.height / 4, Screen.width / 4, Screen.height / 4);
     webViewObject.SetVisibility(true);
 }
Пример #25
0
    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;
        }
    }
Пример #26
0
    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);
    }
Пример #27
0
    // 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);
    }
Пример #28
0
    public void StartWebView()
    {
        string strUrl = "http://52.79.169.121/%ea%b5%90%ec%9c%a1%ec%98%81%ec%83%81/%ec%bb%b4%ed%94%8c%eb%a0%88%ec%9d%b8-%ec%9e%85%eb%a7%9b/";

        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);
    }
Пример #29
0
 void OnDestroy()
 {
     if (Application.platform != RuntimePlatform.OSXEditor)
     {
         return;
     }
     if (webView == IntPtr.Zero)
     {
         return;
     }
     _instance = null;
     _WebViewPlugin_Destroy(webView);
 }
Пример #30
0
 public void OpenWindow(string url)
 {
             #if UNITY_ANDROID
     unityActivityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic <AndroidJavaObject>("currentActivity");
     unityActivityClass.Call("openBrowser", url, _ua, "Logins.html#");
             #else
     if (!webObj)
     {
         webObj = GetComponent <WebViewObject>();
     }
     webObj.LoadURL(url);
             #endif
 }
 /// <summary>
 /// WebViewを閉じる。
 /// </summary>
 public void CloseWebView()
 {
     if (webView != null)
     {
         webView.SetVisibility(false);
         Destroy(webView.gameObject);
         webView = null;
         if (OnClosedWebView != null)
         {
             OnClosedWebView();
         }
     }
 }
 static int QPYX_ClearCookies_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 1);
         WebViewObject QPYX_obj_YXQP = (WebViewObject)ToLua.CheckObject <WebViewObject>(L_YXQP, 1);
         QPYX_obj_YXQP.ClearCookies();
         return(0);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
        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.");
                }
            }
        }
 static int QPYX_RemoveCustomHeader_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 2);
         WebViewObject QPYX_obj_YXQP  = (WebViewObject)ToLua.CheckObject <WebViewObject>(L_YXQP, 1);
         string        QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 2);
         QPYX_obj_YXQP.RemoveCustomHeader(QPYX_arg0_YXQP);
         return(0);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
Пример #35
0
    // Start is called before the first frame update
    void Start()
    {
        webViewObject = (new GameObject("WebViewObject")).AddComponent <WebViewObject>();
        webViewObject.Init(
            // Id: (msg) => Debug.Log(string.Format("CallOnLoaded[{0}]", msg)),
            enableWKWebView: true);

#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
        webViewObject.bitmapRefreshCycle = 1;
#endif

//今回は実験としてGoogleを入れてます。
        webViewObject.LoadURL("https://www.google.co.jp");
    }
Пример #36
0
    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();
    }
Пример #37
0
 void Start()
 {
     webViewObject = (new GameObject ("WebViewObject")).AddComponent<WebViewObject>();
     webViewObject.Init((msg) => {
         //Application.LoadLevel(msg);//Open on this WebView
         Application.OpenURL(msg);// Open external Brawser with return Message(URL)
     });
     if(num == 1.0f){
     webViewObject.LoadURL(url1); //Load URL
     }else if(num == 2.0f){
         webViewObject.LoadURL(url2);
     }else if(num == 3.0f){
         webViewObject.LoadURL(url3);
     }
     webViewObject.SetVisibility(true); // Show on
     //webViewObject.SetMargins(0,0,Screen.width/2,Screen.height - Screen.height/3);//HTML AD size setting
 }
Пример #38
0
    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();
    }
Пример #39
0
    void Start()
    {
        webViewObject =
            (new GameObject("WebViewObject")).AddComponent<WebViewObject>();
        webViewObject.Init((msg)=>{
            Debug.Log(string.Format("CallFromJS[{0}]", msg));
        });

        webViewObject.LoadURL(Url);
        webViewObject.SetVisibility(true);

        switch (Application.platform) {
            case RuntimePlatform.OSXEditor:
            case RuntimePlatform.OSXPlayer:
            case RuntimePlatform.IPhonePlayer:
                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;
            }

        webViewObject.EvaluateJS(
            "window.addEventListener('load', function() {" +
            " window.addEventListener('click', function() {" +
            " Unity.call('clicked');" +
            " }, false);" +
            "}, false);");
    }
        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.");
                }
            }
        }
Пример #41
0
 void OnDestroy()
 {
     if (Application.platform != RuntimePlatform.OSXEditor) {
         return;
     }
     if (webView == IntPtr.Zero)
         return;
     _instance = null;
     _WebViewPlugin_Destroy(webView);
 }
Пример #42
0
    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;
    }
Пример #43
0
    public static void InitWebview()
    {
        bool isMobile = Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer;
        Debug.Log ("isMobile: " + isMobile);

        if (isMobile) {

            _webViewObject =
            (new GameObject ("WebViewObject")).AddComponent<WebViewObject> ();

            _webViewObject.Init ((token) => {
                Debug.Log ("AccessToken " + token);
        //				_webViewObject.SetVisibility (false);
                Destroy (_webViewObject);
                _vk.AccessToken = token;
                if (OAuthEvent != null) {
                    OAuthEvent (true);
                }
            });

            var oauth_url = OAUTH_URL.Replace ("CLIENT_ID", _vk.ClientID);
            oauth_url = oauth_url.Replace ("SCOPE", _vk.Scope);

            Debug.Log ("oauth_url: " + oauth_url);

            _webViewObject.LoadURL (oauth_url);
            _webViewObject.SetVisibility (true);
        } else {
            Debug.Log ("AccessToken " + _vk.AccessToken);
            if (OAuthEvent != null) {
                OAuthEvent (true);
            }
            //StartCoroutine ("GetWallUploadServer");
        }
    }
Пример #44
0
    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);
                }
            }
        }
    }
 public WebsocketListener(WebViewObject webViewObject) {
     base.IgnoreExtensions = true;
     this.webViewObject = webViewObject;
 }