ProcessKeyboard() public method

Process a Unity keyboard event
public ProcessKeyboard ( Event keyEvent ) : void
keyEvent Event
return void
Beispiel #1
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);
                }
            }
        }
    }
Beispiel #2
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 #3
0
    void OnGUI()
    {
        if (!KeyboardEnabled || !HasFocus)
        {
            return;
        }

        if (Event.current.isKey)
        {
            view.ProcessKeyboard(Event.current);
        }
    }
    void OnGUI()
    {
        GUI.skin = null;

        windowRect = GUILayout.Window(unityWindowId, windowRect, windowFunction, "");

        GUI.skin = null;

        UWKWebView view = tabs[activeTab].View;

        if (view != null)
        {
            if (Event.current.type == EventType.Layout)
            {
                Vector3 mousePos = Input.mousePosition;
                mousePos.y = Screen.height - mousePos.y;

                if (windowRect.Contains(mousePos))
                {
                    mousePos.x -= windowRect.x;
                    mousePos.y -= windowRect.y;

                    if (browserRect.Contains(mousePos))
                    {
                        mousePos.x -= browserRect.x;
                        mousePos.y -= browserRect.y;

                        view.ProcessMouse(mousePos);
                    }
                }
            }

            if (Event.current.isKey)
            {
                view.ProcessKeyboard(Event.current);

                if (Event.current.keyCode == KeyCode.Tab || Event.current.character == '\t')
                {
                    Event.current.Use();
                }
            }
        }
    }
Beispiel #5
0
    void OnGUI()
    {
        if (state == State.LoggedIn)
        {
            return;
        }

        windowRect = GUILayout.Window(unityWindowId, windowRect, windowFunction, "");

        if (state == State.Login)
        {
            if (Event.current.type == EventType.Layout)
            {
                Vector3 mousePos = Input.mousePosition;
                mousePos.y = Screen.height - mousePos.y;

                if (browserRect.Contains(mousePos))
                {
                    mousePos.x -= browserRect.x;
                    mousePos.y -= browserRect.y;

                    mousePos.x *= scale.x;
                    mousePos.y *= scale.y;

                    view.ProcessMouse(mousePos);
                }
            }

            if (Event.current.isKey)
            {
                view.ProcessKeyboard(Event.current);

                if (Event.current.keyCode == KeyCode.Tab || Event.current.character == '\t')
                {
                    Event.current.Use();
                }
            }
        }
    }
Beispiel #6
0
    void OnGUI()
    {
        time += Time.deltaTime;

        if (time > .25)
        {
            time = 0;

            if (direction)
            {
                width  += 16;
                height += 16;

                zoom += 0.05f;

                if (zoom > 3.0f)
                {
                    zoom = 3.0f;
                }

                if (width > MaxWidth || height > MaxHeight)
                {
                    direction = !direction;
                    width     = MaxWidth;
                    height    = MaxHeight;
                }
            }
            else
            {
                width  -= 16;
                height -= 16;

                zoom -= 0.05f;

                if (zoom < 0.25f)
                {
                    zoom = 0.25f;
                }

                if (width < 32 || height < 32)
                {
                    width     = 32;
                    height    = 32;
                    direction = !direction;
                }
            }

            //Debug.Log("" + width + " x " + height + " at zoom " + zoom);

            view.SetCurrentSize(width, height);
            if (TestZoom)
            {
                view.SetZoomFactor(zoom);
            }
        }

        if (view != null && view.Visible() && HasFocus)
        {
            if (Event.current.type == EventType.Layout)
            {
                Vector3 mousePos = Input.mousePosition;
                mousePos.y = Screen.height - mousePos.y;
                view.ProcessMouse(mousePos);
            }

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

        if (view != null && view.Visible())
        {
            if (Event.current.type == EventType.Repaint)
            {
                Rect r = new Rect(Positon.x, Positon.y, view.CurrentWidth, view.CurrentHeight);
                GUI.DrawTexture(r, view.WebTexture);
            }
        }
    }
Beispiel #7
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");
        }
    }