LoadURL() public method

Navigate the view to the specified URL (http://, file://, etc)
public LoadURL ( string url ) : void
url string
return void
Beispiel #1
0
    void Start()
    {
        webTexture = GameObject.FindObjectOfType(typeof(WebTexture)) as WebTexture;

        UWKWebView view = gameObject.GetComponent <UWKWebView>();

        view.LoadURL(UWKWebView.GetApplicationDataURL() + "/StreamingAssets/uWebKit/Examples/AlphaMaskExample.html");
    }
    // Use this for initialization
    void Start()
    {
        JSObject.SetProperty("MyJSObject", "unityVersion", Application.unityVersion);

        webGUI = gameObject.GetComponent <WebGUI>();
        view   = gameObject.GetComponent <UWKWebView>();
        view.JSMessageReceived += onJSMessage;

        view.LoadURL(UWKWebView.GetApplicationDataURL() + "/StreamingAssets/uWebKit/Examples/JavascriptExample.html");

        webGUI.Position.x = Screen.width / 2 - view.MaxWidth / 2;
        webGUI.Position.y = 0;
    }
Beispiel #3
0
    // Use this for initialization
    void Start ()
    {       

        JSObject.SetProperty ("MyJSObject", "unityVersion", Application.unityVersion);

        webGUI = gameObject.GetComponent<WebGUI>();
        view = gameObject.GetComponent<UWKWebView>();
        view.JSMessageReceived += onJSMessage;
       
        view.LoadURL(UWKWebView.GetApplicationDataURL() + "/StreamingAssets/uWebKit/Examples/JavascriptExample.html");
        
        webGUI.Position.x = Screen.width / 2 - view.MaxWidth / 2;
        webGUI.Position.y = 0;

    }
    void newViewRequested(UWKWebView view, string url)
    {
        int i = findTab(view);

        if (i >= 0)
        {
            if (numTabs >= maxTabs)
            {
                // load into current view
                view.LoadURL(url);
            }
            else
            {
                createTab(url);
                setActiveTab(numTabs - 1);
            }
        }
    }
    // Main Window function of browser, used to draw GUI
    void windowFunction(int windowID)
    {
        GUI.skin = Skin;

        UWKWebView view = null;

        if (numTabs != 0)
        {
            view = tabs[activeTab].View;
        }

        GUIStyle buttonStyle = new GUIStyle(GUI.skin.button);

        buttonStyle.padding = new RectOffset(2, 2, 2, 2);

        GUI.color   = new Color(1.0f, 1.0f, 1.0f, transparency);
        browserRect = new Rect(4, 118 + 8, Width, Height);

        Rect headerRect = new Rect(4, 4, Width, 118 + 4);

        GUI.DrawTexture(headerRect, texHeader);

        int  titleHeight = 24;
        Rect titleRect   = new Rect(0, 0, Width, titleHeight);

        GUI.DragWindow(titleRect);

        GUILayout.BeginVertical();
        // Main Vertical
        GUILayout.BeginArea(new Rect(8, 4, Width, 118));

        GUILayout.BeginHorizontal();

        GUILayout.BeginVertical();

        // title
        Texture2D bxTex = GUI.skin.box.normal.background;

        GUI.skin.box.normal.background = null;
        GUI.skin.box.normal.textColor  = new Color(.25f, .25f, .25f, 1.0f);

        GUILayout.Box(view == null ? "" : view.Title);
        GUI.skin.box.normal.background = bxTex;

        GUILayout.BeginHorizontal();

        if (GUILayout.Button(texBack, buttonStyle, GUILayout.Width(texBack.width), GUILayout.Height(texBack.height)))
        {
            if (view != null)
            {
                view.Back();
            }
        }

        if (GUILayout.Button(texForward, buttonStyle, GUILayout.Width(texForward.width), GUILayout.Height(texForward.height)))
        {
            if (view != null)
            {
                view.Forward();
            }
        }

        if (GUILayout.Button(texReload, buttonStyle, GUILayout.Width(texReload.width), GUILayout.Height(texReload.height)))
        {
            if (view != null)
            {
                view.LoadURL(currentURL);
            }
        }


        bool nav = false;

        if (Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter))
        {
            nav = true;
        }

        GUI.SetNextControlName("BrowserURL");

        currentURL = GUILayout.TextField(currentURL, GUILayout.MaxWidth(Width - 196));

        // this is grey for some reason
        if (pageLoadProgress != 100)
        {
            Rect urlRect = GUILayoutUtility.GetLastRect();
            urlRect.width *= (float)pageLoadProgress / 100.0f;
            GUI.DrawTexture(urlRect, texProgress);
        }

        if (nav && GUI.GetNameOfFocusedControl() == "BrowserURL")
        {
            GUIUtility.keyboardControl = 0;
            if (view != null)
            {
                string URL = currentURL.Replace(" ", "%20");

                if (!URL.Contains("."))
                {
                    URL = "http://www.google.com/search?q=" + URL;
                }

                if (!URL.Contains("://"))
                {
                    URL = "http://" + URL;
                }

                currentURL = URL;
                view.LoadURL(URL);
            }
        }

        GUILayout.EndHorizontal();

        guiTabs(ref buttonStyle);

        GUILayout.EndVertical();
        buttonStyle.normal.background = null;

        buttonStyle.normal.background = null;
        buttonStyle.hover.background  = null;
        buttonStyle.active.background = null;
        buttonStyle.padding           = new RectOffset(0, 0, 0, 0);

        if (GUILayout.Button(texLogo, buttonStyle, GUILayout.Width(84), GUILayout.Height(100)))
        {
        }

        GUILayout.EndHorizontal();

        GUILayout.EndArea();

        GUILayout.EndVertical();

        // End Main Vertical

        if (view != null)
        {
            GUI.DrawTexture(browserRect, view.WebTexture);
            view.DrawTextIME((int)browserRect.x, (int)browserRect.y);
        }


        Rect footerRect = new Rect(4, browserRect.yMax, Width, 8);

        GUI.DrawTexture(footerRect, texFooter);
    }
    void guiTabs(ref GUIStyle buttonStyle)
    {
        UWKWebView view = null;

        if (numTabs != 0)
        {
            view = tabs[activeTab].View;
        }

        GUILayout.BeginHorizontal();

        buttonStyle.normal.background = null;
        buttonStyle.active.background = null;
        buttonStyle.normal.textColor  = new Color(.65f, .65f, .65f, 1.0f);
        buttonStyle.hover.textColor   = new Color(.35f, .35f, .35f, 1.0f);

        GUILayoutOption width = GUILayout.MaxWidth(128);

        // Bookmark Buttons

        if (GUILayout.Button("uWebKit", buttonStyle, width))
        {
            checkTabs();
            view = tabs[activeTab].View;
            view.LoadURL("http://www.uwebkit.com");
        }

        if (GUILayout.Button("uWebKit GitHub", buttonStyle, width))
        {
            checkTabs();
            view = tabs[activeTab].View;
            view.LoadURL("https://github.com/uWebKit/uWebKit");
        }

        if (GUILayout.Button("Google", buttonStyle, width))
        {
            checkTabs();
            view = tabs[activeTab].View;
            view.LoadURL("https://www.google.com");
        }


        if (GUILayout.Button("YouTube", buttonStyle, width))
        {
            checkTabs();
            view = tabs[activeTab].View;
            view.LoadURL("https://www.youtube.com/embed/lXfOqY0JMng");
        }

        if (GUILayout.Button("Unity3D", buttonStyle, width))
        {
            checkTabs();
            view = tabs[activeTab].View;
            view.LoadURL("https://www.unity3d.com");
        }


        if (GUILayout.Button("Facebook", buttonStyle, width))
        {
            checkTabs();
            view = tabs[activeTab].View;
            view.LoadURL("https://www.facebook.com");
        }

        if (GUILayout.Button("Twitter", buttonStyle, width))
        {
            checkTabs();
            view = tabs[activeTab].View;
            view.LoadURL("https://www.twitter.com");
        }

        if (UWKCore.IMEEnabled)
        {
            if (GUILayout.Button("WoW China", buttonStyle, width))
            {
                checkTabs();
                view = tabs[activeTab].View;
                view.LoadURL("http://www.battlenet.com.cn/wow/zh");
            }
        }
        else
        {
            if (GUILayout.Button("Penny Arcade", buttonStyle, width))
            {
                checkTabs();
                view = tabs[activeTab].View;
                view.LoadURL("http://www.penny-arcade.com");
            }
        }

        if (GUILayout.Button("Unity Info", buttonStyle, width))
        {
            checkTabs();
            view = tabs[activeTab].View;
            UnityInfoPage.SetProperties();
            view.LoadHTML(UnityInfoPage.GetHTML(view));
        }

        GUILayout.EndHorizontal();

        // tabs
        GUILayout.BeginHorizontal();


        // setup style for close widget
        GUIStyle closeStyle = new GUIStyle(buttonStyle);

        closeStyle.hover.background  = texCloseTabHover;
        closeStyle.normal.background = texCloseTab;
        closeStyle.fontSize          = 8;
        closeStyle.fixedWidth        = 12;
        closeStyle.fixedHeight       = 12;
        closeStyle.stretchWidth      = false;
        closeStyle.stretchHeight     = false;

        for (int i = 0; i < 4; i++)
        {
            if (i < numTabs)
            {
                string title = tabs[i].Title;

                if (title == null)
                {
                    title = "";
                }

                if (title.Length > 24)
                {
                    title  = title.Substring(0, 24);
                    title += "...";
                }

                UWKWebView v = tabs[i].View;

                if (GUILayout.Button(title, GUILayout.MaxWidth(256)))
                {
                    setActiveTab(i);
                }

                Rect br = GUILayoutUtility.GetLastRect();

                br.x += 8;
                br.y += 4;

                br.height = 16;
                br.width  = 16;

                if (v.WebIcon != null)
                {
                    GUI.DrawTexture(br, v.WebIcon);
                }

                br = GUILayoutUtility.GetLastRect();

                br.x     += br.width;
                br.y     += 4;
                br.height = 14;
                br.width  = 14;

                if (GUI.Button(br, "x", closeStyle))
                {
                    closeTab(i);
                }

                GUILayout.Space(14);
            }
        }

        if (numTabs < maxTabs)
        {
            if (GUILayout.Button("New Tab", GUILayout.MaxWidth(72)))
            {
                createTab();
                setActiveTab(numTabs - 1);
            }
        }

        GUILayout.EndHorizontal();
    }
Beispiel #7
0
 void popupRequested(UWKWebView view, string url)
 {
     // Default handler loads in view
     view.LoadURL(url);
 }
Beispiel #8
0
    void newViewRequested(UWKWebView view, string url)
    {
        int i = findTab (view);
        
        if (i >= 0)
        {       
            if (numTabs >= maxTabs)
            {
                // load into current view
                view.LoadURL(url);
            }
            else
            {
                createTab(url);
                setActiveTab(numTabs - 1);
            }
        }

    }