Exemple #1
0
 public void HandleBackPressed_LeFiere()
 {
     if (leFiereUniwebview.CanGoBack && leFiereUniwebview.urlOnStart != leFiereUniwebview.Url)
     {
         leFiereUniwebview.GoBack();
     }
     else
     {
         leFiereUwv_ShowHide.Hide();
         stateMachine.ChangeState(stateMachine.LastState);
     }
 }
Exemple #2
0
    /// <summary>
    /// WebViewを戻る
    /// </summary>
    void _ReturnWebView()
    {
        SoundUtil.PlaySE(SEID.SE_MENU_RET);
#if UNITY_EDITOR_OSX
        //MacでWebを表示すると固まるのでスキップ
        return;
#elif UNITY_IOS || UNITY_ANDROID || UNITY_WP8
        if (m_WebView.CanGoBack() == true)
        {
            m_WebView.GoBack();
        }
#endif
    }
Exemple #3
0
 /// <summary>
 /// 页面回退
 /// </summary>
 public void WebViewBack()
 {
     if (_curWebView)
     {
         if (_curWebView.CanGoBack())
         {
             _curWebView.GoBack();
         }
         else
         {
             YxDebug.LogError("已经到达最上层了,不能再返回了");
         }
     }
     else
     {
         YxDebug.LogError("CurWebView is null,please try again!");
     }
 }
Exemple #4
0
    void OnGUI()
    {
        int uiFactor = UniWebViewHelper.RunningOnRetinaIOS() ? 2 : 1;

        if (GUI.Button(new Rect(0, Screen.height - uiFactor * 100, uiFactor * 100, uiFactor * 50), "Open"))
        {
            //2. You can add a UniWebView either in Unity Editor or by code.
            //Here we check if there is already a UniWebView component. If not, add one.
            _webView = GetComponent <UniWebView>();
            if (_webView == null)
            {
                _webView = gameObject.AddComponent <UniWebView>();
                _webView.OnReceivedMessage        += OnReceivedMessage;
                _webView.OnLoadComplete           += OnLoadComplete;
                _webView.OnWebViewShouldClose     += OnWebViewShouldClose;
                _webView.OnEvalJavaScriptFinished += OnEvalJavaScriptFinished;
            }

            //3. Set the frame of this webview. Give it a url to load. Add event listener to it.
            int bottomInset = Screen.height / (2 * uiFactor);
            _webView.insets = new UniWebViewEdgeInsets(5, 5, bottomInset, 5);
            _webView.url    = "http://uniwebview.onevcat.com/demo/index1-1.html";

            //You can read a local html file, by putting the file into /Assets/StreamingAssets folder
            //And use the url like these
            //If you are using "Split Application Binary" for Android, see the FAQ section of manual for more.

            /*
             #if UNITY_EDITOR
             * _webView.url = Application.streamingAssetsPath + "/index.html";
             #elif UNITY_IOS
             * _webView.url = Application.streamingAssetsPath + "/index.html";
             #elif UNITY_ANDROID
             * _webView.url = "file:///android_asset/index.html";
             #endif
             */

            // You can set the spinner visibility and text of the webview.
            // This line can change the text of spinner to "Wait..." (default is  "Loading...")
            //_webView.SetSpinnerLabelText("Wait...");
            // This line will tell UniWebView to not show the spinner as well as the text when loading.
            //_webView.SetShowSpinnerWhenLoading(false);

            //4.Now, you can load the webview and waiting for OnLoadComplete event now.
            _webView.Load();

            _errorMessage = null;

            //You can also load some HTML string instead from a url or local file.
            //When loading from the HTML string, the _webView.url will take no effect.
            //_webView.LoadHTMLString("<body>I am a html string</body>",null);

            //If you want the webview show immediately, instead of the OnLoadComplete event, call Show()
            //A blank webview will appear first, then load the web page content in it
            //_webView.Show();
        }

        if (_webView != null && GUI.Button(new Rect(uiFactor * 100,
                                                    Screen.height - uiFactor * 100,
                                                    uiFactor * 100,
                                                    uiFactor * 50), "Back"))
        {
            _webView.GoBack();
        }

        //Tool bar is hidden by default. You can use it to navigate or close the webview.
        //The tool bar is only avaliable in iOS system. You can use "back button" of Android to go back.
        if (_webView != null && GUI.Button(new Rect(uiFactor * 200,
                                                    Screen.height - uiFactor * 100,
                                                    uiFactor * 100,
                                                    uiFactor * 50), "ToolBar"))
        {
            if (_webView.toolBarShow)
            {
                _webView.HideToolBar(true);
            }
            else
            {
                _webView.ShowToolBar(true);
            }
        }

        if (_errorMessage != null)
        {
            GUI.Label(new Rect(0, 0, uiFactor * 300, uiFactor * 50), _errorMessage);
        }
    }
Exemple #5
0
 public void OnGoBack()
 {
     _webView.GoBack();
 }
Exemple #6
0
    public void GoBack()
    {
#if UNITY_IOS || UNITY_ANDROID || UNITY_EDITOR
        uniWebView.GoBack();
#endif
    }
Exemple #7
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(0, Screen.height - 150, 150, 80), "Open"))
        {
            //2. You can add a UniWebView either in Unity Editor or by code.
            //Here we check if there is already a UniWebView component. If not, add one.
            _webView = GetComponent <UniWebView>();
            if (_webView == null)
            {
                _webView = gameObject.AddComponent <UniWebView>();
                _webView.OnReceivedMessage        += OnReceivedMessage;
                _webView.OnLoadComplete           += OnLoadComplete;
                _webView.OnWebViewShouldClose     += OnWebViewShouldClose;
                _webView.OnEvalJavaScriptFinished += OnEvalJavaScriptFinished;

                _webView.InsetsForScreenOreitation += InsetsForScreenOreitation;
            }

            //3. You can set the insets of this webview by assigning an insets value simply
            //   like this:

            /*
             *              int bottomInset = (int)(UniWebViewHelper.screenHeight * 0.5f);
             *              _webView.insets = new UniWebViewEdgeInsets(5,5,bottomInset,5);
             */

            // Or you can also use the `InsetsForScreenOreitation` delegate to specify different
            // insets for portrait or landscape screen. If your webpage should resize on both portrait
            // and landscape, please use the delegate way. See the `InsetsForScreenOreitation` method
            // in this file for more.

            // Now, set the url you want to load.
            _webView.url = "http://uniwebview.onevcat.com/demo/index1-1.html";

            //You can read a local html file, by putting the file into /Assets/StreamingAssets folder
            //And use the url like these
            //If you are using "Split Application Binary" for Android, see the FAQ section of manual for more.

            /*
             #if UNITY_EDITOR
             * _webView.url = Application.streamingAssetsPath + "/index.html";
             #elif UNITY_IOS
             * _webView.url = Application.streamingAssetsPath + "/index.html";
             #elif UNITY_ANDROID
             * _webView.url = "file:///android_asset/index.html";
             #elif UNITY_WP8
             * _webView.url = "Data/StreamingAssets/index.html";
             #endif
             */

            // You can set the spinner visibility and text of the webview.
            // This line can change the text of spinner to "Wait..." (default is  "Loading...")
            //_webView.SetSpinnerLabelText("Wait...");
            // This line will tell UniWebView to not show the spinner as well as the text when loading.
            //_webView.SetShowSpinnerWhenLoading(false);

            //4.Now, you can load the webview and waiting for OnLoadComplete event now.
            _webView.Load();

            _errorMessage = null;

            //You can also load some HTML string instead from a url or local file.
            //When loading from the HTML string, the _webView.url will take no effect.
            //_webView.LoadHTMLString("<body>I am a html string</body>",null);

            //If you want the webview show immediately, instead of the OnLoadComplete event, call Show()
            //A blank webview will appear first, then load the web page content in it
            //_webView.Show();
        }

        if (_webView != null && GUI.Button(new Rect(150,
                                                    Screen.height - 150,
                                                    150,
                                                    80), "Back"))
        {
            _webView.GoBack();
        }

        //Tool bar is hidden by default. You can use it to navigate or close the webview.
        //The tool bar is only avaliable in iOS system. You can use "back button" of Android to go back.
        if (_webView != null && GUI.Button(new Rect(300,
                                                    Screen.height - 150,
                                                    150,
                                                    80), "ToolBar"))
        {
            if (_webView.toolBarShow)
            {
                _webView.HideToolBar(true);
            }
            else
            {
                _webView.ShowToolBar(true);
            }
        }

        if (_errorMessage != null)
        {
            GUI.Label(new Rect(0, 0, Screen.width, 80), _errorMessage);
        }
    }
Exemple #8
0
 public void GoBack()
 {
     uniWebView.GoBack();
 }