LoadHTML() public method

Loads the specified HTML string directly in the view, can be used for generating web content on the fly
public LoadHTML ( string HTML, string baseURL = "" ) : void
HTML string
baseURL string
return void
Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        webGUI = gameObject.GetComponent <WebGUI>();
        view   = gameObject.GetComponent <UWKWebView>();

        view.LoadFinished += onLoadFinished;
        view.WebQuery     += onWebQuery;

        view.LoadHTML(HTML);

        webGUI.Position.x = Screen.width / 2 - view.MaxWidth / 2;
        webGUI.Position.y = 0;
    }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        // Set a global variable, accessible in the webview as 'UWKExample.UnityVersion'
        UWKWebView.SetGlobalProperty("UWKExample", "unityVersion", Application.unityVersion);

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

        view.LoadFinished += onLoadFinished;
        view.LoadHTML(HTML);

        webGUI.Position.x = Screen.width / 2 - view.MaxWidth / 2;
        webGUI.Position.y = 0;
    }
    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();
    }