Example #1
0
    private IntVector2 GetDragCoords()
    {
        //takes into account the position of the inventory window, and
        //its things, to find which icon coordinate the mouse is on.

        Vector2 mousePoint = GUIFunctions.GetGUIMousePositionFromInputMousePosition();

        Vector2 point = new Vector2(mousePoint.x - windowRect.x - iconSize,
                                    mousePoint.y - windowRect.y - iconSize);

        return(new IntVector2(Mathf.FloorToInt(point.x / iconSize),
                              Mathf.FloorToInt(point.y / iconSize)));
    }
Example #2
0
    void Update()
    {
        Vector3 mousePosition = GUIFunctions.GetGUIMousePositionFromInputMousePosition();

        if (currentTooltip == null)
        {
            //no tooltip was hovered over recently.
            //check all tooltips if we're hovering over them
            foreach (Tooltip tooltip in tooltips.Values)
            {
                if (tooltip.mouseRect.Contains(mousePosition))
                {
                    currentTooltip = tooltip;
                    break;
                }
            }
        }
        else if (currentTooltip.lastFrameCount < Time.frameCount - 1)
        { //this means SetTooltip wasn't called recently and the tooltip shouldn't display anymore.
            RemoveTooltip(currentTooltip.tooltipID);
            currentTooltip = null;
        }
        else
        {
            //we were just hovering over a tooltip that is still active.
            //are we still hovering?
            if (currentTooltip.mouseRect.Contains(mousePosition))
            {
                timeCount += Time.deltaTime;
            }
            else
            {
                timeCount      = 0;
                currentTooltip = null;
            }
        }
    }