Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Alatriste on January 08, 2017, 12:44:40 PM

Title: uGUI Pointer Event - Mouse Over
Post by: Alatriste on January 08, 2017, 12:44:40 PM
Hi,

I'm having some difficulties here. I'm trying to trigger some events based on the mouse over a button, but when I look at the uGUI Pointer Event Proxy I cannot see any "On Over" Event.

If I try to use the action "Is Pointer Over Ui Object" then it gets activated in any UI object, which is not what I want. I need a specific UI button.

What other options do I have?
Title: Re: uGUI Pointer Event - Mouse Over
Post by: jeanfabre on January 09, 2017, 02:21:47 AM
Hi,

 you need to compose "OnEnter" and "OnExit", there is no "OnOver" built in Unity UI.

 so catch the OnEnter, and turn on a boolean variables for example, and turn it off when you get OnExit?

 Bye,

 Jean
Title: Re: uGUI Pointer Event - Mouse Over
Post by: Alatriste on January 09, 2017, 03:06:48 AM
Will it work if the mouse is already over the UI object when this FSM is called?
Title: Re: uGUI Pointer Event - Mouse Over
Post by: jeanfabre on January 09, 2017, 03:16:37 AM
Hi,

I don't know actually, have you tried? It seems to be a lacking feature in Unity UI for sure.

 Bye,

 Jean
Title: Re: uGUI Pointer Event - Mouse Over
Post by: Alatriste on January 09, 2017, 03:26:49 AM
I'll give a try as soon as I can and I'll post the results. Thanks Jean. :)
Title: Re: uGUI Pointer Event - Mouse Over
Post by: Alatriste on January 09, 2017, 04:45:59 AM
I'm not in my computer at the moment, so I cannot try yet the solution, but it seems that Unity does support the behaviour.

https://docs.unity3d.com/ScriptReference/EventSystems.EventSystem.IsPointerOverGameObject.html
Title: Re: uGUI Pointer Event - Mouse Over
Post by: jeanfabre on January 10, 2017, 02:24:15 AM
Hi,

 that won't tell you enough you won't know which one you are over with.

Bye,

 Jean
Title: Re: uGUI Pointer Event - Mouse Over
Post by: Alatriste on January 27, 2017, 01:14:10 PM
An update on this:

The bool condition made the trick. The only issue is that if at the start of the game the mouse happens to be over one of the buttons, it won't work, as is still waiting for the uGUI/On Pointer Enter to set the bool value.

Not sure if there is work around this.
Title: Re: uGUI Pointer Event - Mouse Over
Post by: jeanfabre on February 08, 2017, 01:31:52 AM
Hi,

 what do you want to achieve with the mouse over event? Maybe you could bring that button at runtime so that it catches the mouse over event,

Bye,

 Jean
Title: Re: uGUI Pointer Event - Mouse Over
Post by: Alatriste on February 08, 2017, 03:32:15 AM
Not sure if I understand what do you mean by "bring that button at runtime so that it catches the mouse over event".  :-\

Basically the scenario is the following: I have 2 buttons. When the mouse is over any of the buttons I display some visual feedback. Then the player click on the buttons and I refresh the buttons again, so the feedback is different every time a click is done. (like question/answer game)

With the bool condition I can now track mouse enter/exit but the very first time, if it happens that the player has already the mouse over one of the buttons, no event gets activated (as the mouse doesn't enter, it was already there)
Title: Re: uGUI Pointer Event - Mouse Over
Post by: jeanfabre on February 08, 2017, 02:45:14 PM
Hi,

 turn your button into a prefab and instanciate it at runtime, you'll get the over event this way is the mouse happens to be over the spot you instanciate it.

 Bye,

Jean