Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started 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?
-
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
-
Will it work if the mouse is already over the UI object when this FSM is called?
-
Hi,
I don't know actually, have you tried? It seems to be a lacking feature in Unity UI for sure.
Bye,
Jean
-
I'll give a try as soon as I can and I'll post the results. Thanks Jean. :)
-
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
-
Hi,
that won't tell you enough you won't know which one you are over with.
Bye,
Jean
-
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.
-
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
-
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)
-
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