Пример #1
0
 void Update()
 {
     // do this for health bars counting down etc, where the tooltip changes
     if (image.enabled && currentHelper != null)
     {
         SetText(currentHelper.getToolTipMessage());
     }
 }
Пример #2
0
    public void OnPointerEnter()
    {
        if (helper != null)
        {
            message = helper.getToolTipMessage();
        }

        Tooltip.instance.Show(transform.position, message, helper);
    }
Пример #3
0
        // Update is called once per frame
        void Update()
        {
            // look under the mouse for a tooltip source
            current = null;
            Vector2    pos = Input.mousePosition;
            GameObject go  = GetObjectUnderPos(pos);

            if (go)
            {
                // found an object...
                current = go.GetComponent <IToolTip>();
                if (current == null && go.transform.parent)
                {
                    current = go.transform.parent.GetComponent <IToolTip>();
                }
                if (current != null)
                {
                    string tip = current.getToolTipMessage();

                    if (tip != "")
                    {
                        tooltipObject.SetActive(true);

                        // we need this to force a recalculation of the text size to propagate up to the parent frame
                        toolTipText.text = "";
                        // set the text to the tooltip one
                        toolTipText.text = tip;

                        // positon at the mouse
                        toolTipTransform.position = pos;

                        // make it point inwards to the centre of the screen
                        bool goLeft = (pos.x > Screen.width / 2);
                        toolTipTransform.pivot = new Vector2(goLeft ? 1 : 0, pos.y > Screen.height / 2 ? 1 : 0);
                    }
                    else
                    {
                        current = null;
                    }
                }
            }


            // turn the tooltip on or off based on whether we have a thing under the mouse
            tooltipObject.SetActive(current != null);
        }