playMaker

Author Topic: uGUI Pointer Event - Mouse Over  (Read 6434 times)

Alatriste

  • Full Member
  • ***
  • Posts: 195
uGUI Pointer Event - Mouse Over
« 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?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: uGUI Pointer Event - Mouse Over
« Reply #1 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

Alatriste

  • Full Member
  • ***
  • Posts: 195
Re: uGUI Pointer Event - Mouse Over
« Reply #2 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?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: uGUI Pointer Event - Mouse Over
« Reply #3 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

Alatriste

  • Full Member
  • ***
  • Posts: 195
Re: uGUI Pointer Event - Mouse Over
« Reply #4 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. :)

Alatriste

  • Full Member
  • ***
  • Posts: 195
Re: uGUI Pointer Event - Mouse Over
« Reply #5 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

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: uGUI Pointer Event - Mouse Over
« Reply #6 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

Alatriste

  • Full Member
  • ***
  • Posts: 195
Re: uGUI Pointer Event - Mouse Over
« Reply #7 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.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: uGUI Pointer Event - Mouse Over
« Reply #8 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

Alatriste

  • Full Member
  • ***
  • Posts: 195
Re: uGUI Pointer Event - Mouse Over
« Reply #9 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)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: uGUI Pointer Event - Mouse Over
« Reply #10 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