#UI

1 messages · Page 1 of 1 (latest)

astral gyro
#

so you want to make something like a tool tip?

maiden sapphire
astral gyro
#

alright, I'm sure we can figure this out

maiden sapphire
#

When i dont hover over it:

#

When i hover over it

compact ibex
#

rect.Contains stays false probably due to "Input.mousePosition" having absolute screen values, and the rect coordinates are local values
So it's trying to check if (710, 320) is contained in (0, 0, 1, 1)

astral gyro
#

Oke so you want a side bar that when you hover your mouse over the side the 2 buttons show up

astral gyro
#

Let me quickly hop in unity and see if I can recreate the problem

compact ibex
astral gyro
#
private void Update()
    {
        if (HoverRect.rect.Contains(Input.mousePosition))
        {
            if (open == false)
            {
                open = true;
                LeanTween.cancel(ButtonsPanel);
                LeanTween.moveLocal(ButtonsPanel.gameObject, ShowPos, TweenTime).setEaseInOutCubic();
            }
        }
        else
        {
            if (open == true)
            {
                open = false;
                LeanTween.cancel(ButtonsPanel);
                LeanTween.moveLocal(ButtonsPanel.gameObject, HidePos, TweenTime).setEaseInOutCubic();
            }
        }
    }
#

quickly post for reference

compact ibex
#

Better yet

#

Try this:
HoverRect.rect.Contains(Input.mousePosition - HoverRect.rect.transform.position)

maiden sapphire
compact ibex
#

Not sure if you can do rect.position directly, but something like that

maiden sapphire
maiden sapphire
#

Thanks you so much

compact ibex
#

Good (:

astral gyro
#

nice

compact ibex
#

Just to make sure, did you understand why it works?

maiden sapphire
compact ibex
#

Sure

maiden sapphire
compact ibex
#

As I said, the Input.mousePosition is getting the mouse position on the screen, and the contains method is trying to check for local coordinates

#

When you subtract the rectangle position from the mouse position, you're looking for the mouse position relative to the rect position

#

This is harder to explain than I expected :P

maiden sapphire
compact ibex
#

Exactly

maiden sapphire
#

ahhh, i see. Thanks! I learned somthing new today :D

compact ibex
#

Glad to help (: