playMaker

Author Topic: Can't figure out how to "get currently hovered UI canvas game object"?  (Read 2667 times)

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
The closest I can find is "UI Is Pointer Over UI Object", which sends events when I move the cursor around my menu, but I can't find any action for "get hovered game object under mouse". Surely I am missing something simple?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

 if you mean over a 3d or 2d object, you will need to have a collider, and then you can either have an fsm on that object that will respond to mouse enter and mouse exit events. else you will have to raycast.

if you mean a UI object, you currently only have the option to use an fsm on each of your UI element and catch pointer enter and exit. if you need a raycasting, let me know, I'll do the custom action necessary for this ( as the raycast as to come from the event system and not the physics engine)

Bye,

 Jean

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
I mean using the UI event system. A raycasting action would be very useful if you are able to do it. Are you saying I would need to put the raycasting action in a script on every UI element, or would the action you propose circumvent the need to put a script on each element?

Also, playmaker is awesome!

My menu has a grid of 40 icons you can hover over, and I want the description text box to update once you do so.

If I have a raycasting action, I guess it can raycast often since we're in menus and performance is not a problem?

I'm using a screen space menu, but I do eventually want it to work in VR by existing in world space in front of you, depending on if you have a headset connected. Will a raycast action work for both?

PS. What's weird is, the icon boxes already get brighter when I hover over them. So it's already somehow KNOWING what I'm hovering over with the mouse. (using the Hovered/Selected/etc. colors on the Button script.)

I read somewhere about "adding a script to the event system" to detect the mouse over. is that helpful for the action?
« Last Edit: March 11, 2020, 07:49:22 AM by westingtyler »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

 to be honest, you should likely use this instead: https://assetstore.unity.com/packages/tools/gui/gaze-ui-for-canvas-70881

it's free and it will work out of the box.

Bye,

 Jean

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
hey thanks. will this work in non-VR as well? my game is primarily not in VR, but I want to add VR support later, so I need it to work on a normal monitor.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

non VR have touch or mouse so all UI would react normally, otherwise I think if your camera is controlled in a similar way, but unlikely that it is what you want in the end. VR and non VR have a very distinct UX.

Bye,

 Jean

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
If we just ignore VR for now, it would still really help to have an action to make buttons "notice" and save the hovered button object when the mouse is hovering over them. A ray casting action. I don't plan to make VR for a long time, so I can figure that out later.

But Unity UI already seems to "notice" what button is hovered, since it becomes brighter/highlighted, depending on the button's settings. Surely there is a way we can just "grab" that information from the UI system?

(edit) i removed questions related to vr hot swapping, which I'll ask about some other time.

« Last Edit: March 18, 2020, 06:26:53 PM by westingtyler »