示例#1
0
    void OnGUI()
    {
        if (debugZones && EventType.Repaint == Event.current.type)
        {
            // NOTE: use this with no aspect ratio modification. Set it as false in LevelManager
            for (int i = 0; i < arrowRects.Length; ++i)
            {
                Rect r       = arrowRects[i];
                Rect rTarget = new Rect(r.x, Screen.height - r.y - r.height, r.width, r.height);
                GUI.Box(rTarget, GUIContent.none);
            }
        }

        // since this game object has a GUICustomElement script attached to it, for strange a reason no mouse event
        // is caught, so we need to manually check for the event and fire it here
        Event e = Event.current;

        if (e != null && e.isMouse && e.button == 0 && e.type == EventType.MouseDown)
        {
            if (GameObjectTools.testHitFromMousePos(transform, e.mousePosition))
            {
                Vector2 mousePosInverted;
                mousePosInverted.x = e.mousePosition.x;
                // mouse position is in GUI space which has inverted Y axis
                mousePosInverted.y = Screen.height - e.mousePosition.y;
                optionSelected(mousePosInverted);
            }
        }
    }
示例#2
0
    void OnGUI()
    {
        // since this game object has a GUICustomElement script attached to it, for strange a reason no mouse event
        // is caught, so we need to manually check for the event and fire it here
        Event e = Event.current;

        if (e != null && e.isMouse && e.button == 0 && e.type == EventType.mouseDown)
        {
            if (GameObjectTools.testHitFromMousePos(transform, e.mousePosition))
            {
                optionSelected();
            }
        }
    }
示例#3
0
    void OnGUI()
    {
#if UNITY_STANDALONE || UNITY_EDITOR || UNITY_WEBPLAYER
        // since this game object has a GUICustomElement script attached to it, for strange a reason no mouse event
        // is caught, so we need to manually check for the event and fire it here
        Event e = Event.current;
        if (e != null && e.isMouse && e.button == 0 && e.type == EventType.MouseUp)
        {
            if (GameObjectTools.testHitFromMousePos(transform, e.mousePosition))
            {
                optionSelected();
            }
        }
#endif
        if (!showOptions)
        {
            return;
        }

        // update Unity GUI matrix to allow automatic resizing (only works for Unity GUI elems)
        // NOTE: this transformation has effect per game loop
        GUI.matrix = GUIScreenLayoutManager.unityGUIMatrix;

        if (GUI.Button(rectQuit, "Quit"))
        {
            quit();
        }
        if (GUI.Button(rectBack, "Back"))
        {
            back();
        }
        if (GUI.Button(rectLevelSel, "Levels"))
        {
            levelSelection();
        }
    }