DrawTexture() public method

public DrawTexture ( Rect position, bool alphaBlend = true ) : void
position Rect
alphaBlend bool
return void
Beispiel #1
0
    void OnGUI()
    {
        // get the attached view component
        UWKWebView view = gameObject.GetComponent <UWKWebView>();

        // if we have a view attached and it is visible
        if (view != null && view.Visible())
        {
            // draw it
            Rect r = new Rect(Position.x, Position.y, view.Width, view.Height);
            view.DrawTexture(r);

            // if we have focus, handle input
            if (HasFocus)
            {
                // get the mouse coordinate
                Vector3 mousePos = Input.mousePosition;
                mousePos.y = Screen.height - mousePos.y;

                // translate based on position
                mousePos.x -= Position.x;
                mousePos.y -= Position.y;

                view.ProcessMouse(mousePos);

                // process keyboard
                if (Event.current.isKey)
                {
                    view.ProcessKeyboard(Event.current);
                }
            }
        }
    }
Beispiel #2
0
    void OnGUI()
    {
        UWKWebView view = gameObject.GetComponent <UWKWebView>();

        if (view != null && view.Visible())
        {
            Rect r = new Rect(Position.x + X, Position.y + Y, view.CurrentWidth, view.CurrentHeight);
            view.DrawTexture(r);

            if (HasFocus)
            {
                Vector3 mousePos = Input.mousePosition;
                mousePos.y = Screen.height - mousePos.y;

                mousePos.x -= Position.x + X;
                mousePos.y -= Position.y + Y;

                view.ProcessMouse(mousePos);

                if (Event.current.isKey)
                {
                    view.ProcessKeyboard(Event.current);
                }
            }
        }
    }
    // Main Window function of browser, used to draw GUI
    void windowFunction(int windowID)
    {
        if (GUI.Button(new Rect(windowRect.width - 28, 4, 24, 24), "X"))
        {
            Close();
            return;
        }

        GUI.DragWindow(new Rect(0, 0, Width, toolbarHeight));

        Rect browserRect = new Rect(4, 4 + toolbarHeight, Width, Height);

        view.DrawTexture(browserRect);
    }
Beispiel #4
0
    // 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);

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

        GUILayout.BeginHorizontal();

        GUI.enabled = view != null && view.CanGoBack;

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

        GUI.enabled = view != null && view.CanGoForward;

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

        GUI.enabled = view != null && !view.Loading;

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

        GUI.enabled = true;


        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)
        {
            view.DrawTexture(browserRect, false);
            //TODO: uWebKit3
            //view.DrawTextIME ((int)browserRect.x, (int)browserRect.y);
        }


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

        GUI.DrawTexture(footerRect, texFooter);
    }
Beispiel #5
0
    void OnGUI()
    {
        int buttonWidth = 180;

        // get the attached view component
        UWKWebView view = gameObject.GetComponent <UWKWebView>();

        int x = Screen.width / 2 - 1024 / 2 + 84;
        int y = Screen.height / 2 - 720 / 2;

        // draw it
        Rect r = new Rect(x, y, view.Width, view.Height);

        view.DrawTexture(r);

        // get the mouse coordinate
        Vector3 mousePos = Input.mousePosition;

        mousePos.y = Screen.height - mousePos.y;

        // translate based on position
        mousePos.x -= x;
        mousePos.y -= y;

        view.ProcessMouse(mousePos);

        // process keyboard
        if (Event.current.isKey)
        {
            view.ProcessKeyboard(Event.current);
        }

        x -= (buttonWidth + 32);
        y  = Screen.height / 2 - 720 / 2;

        if (y < 0)
        {
            y = 0;
        }

        GUI.BeginGroup(new Rect(x, y, buttonWidth, Screen.height));

        Rect brect = new Rect(0, 0, buttonWidth, 60);

        if (GUI.Button(brect, "Example 1 - Web Browser"))
        {
            SceneManager.LoadScene("Example1WebBrowser");
        }

        brect.y += 80;
        if (GUI.Button(brect, "Example 2 - Web GUI"))
        {
            SceneManager.LoadScene("Example2WebGUI");
        }

        brect.y += 80;
        if (GUI.Button(brect, "Example 3 - Web Texture"))
        {
            SceneManager.LoadScene("Example3WebTexture");
        }

        brect.y += 80;
        if (GUI.Button(brect, "Example 4 - Scene"))
        {
            SceneManager.LoadScene("Example4Scene");
        }

        brect.y += 80;
        if (GUI.Button(brect, "Example 5 - Javascript"))
        {
            SceneManager.LoadScene("Example5Javascript");
        }

        brect.y += 80;
        if (GUI.Button(brect, "Example 6 - WebQuery"))
        {
            SceneManager.LoadScene("Example6WebQuery");
        }

        brect.y += 80;
        if (GUI.Button(brect, "Example 7- Alpha Mask"))
        {
            SceneManager.LoadScene("Example7AlphaMask");
        }

        brect.y += 80;
        if (GUI.Button(brect, "Clear Cookies"))
        {
            UWKWebView.ClearCookies();
        }

        brect.y += 80;
        if (GUI.Button(brect, "Quit"))
        {
            Application.Quit();
        }

        GUI.EndGroup();

        if (UWKCore.BetaVersion)
        {
            GUI.Label(new Rect(0, 0, 200, 60), "UWEBKIT BETA VERSION");
        }
    }