User avatar
stonstad
Topic Author
Posts: 241
Joined: 06 Jun 2016, 18:14
Location: Lesser Magellanic Cloud
Contact:

WorldSpaceUI Question - Click Events

05 Dec 2023, 02:25

I am using the WorldSpaceUI element and it nearly completely works... I am seeing MouseOver events fire with accurate cursor precision. However, Click and MouseDown events are not firing. I dissected the WorldSpaceUI example but I'm at a loss for what I might be missing.

- The NoesisView has mouse events enabled.
- There is no occlusion from other UI elements, and I am not seeing other elements grab the event.
- No success with triggers or code behind events, i.e. click or mousedown.
 
User avatar
jsantos
Site Admin
Posts: 3938
Joined: 20 Jan 2012, 17:18
Contact:

Re: WorldSpaceUI Question - Click Events

05 Dec 2023, 10:04

Do you have actions enabled on the view? (and probably the new input system).
 
User avatar
stonstad
Topic Author
Posts: 241
Joined: 06 Jun 2016, 18:14
Location: Lesser Magellanic Cloud
Contact:

Re: WorldSpaceUI Question - Click Events

06 Dec 2023, 21:43

OK, the cause is interesting.

I render camera output to a texture and composite this texture into the Noesis View. Let's call this UI my base layer. The camera depth is 10.
I render world space UI elements using a separate Noesis View. Here the camera depth is 2. This allows UI elements to render over the World Space UI.

When the base layer has Enable Mouse checked, the World Space UI elements receive mouse over events but not click.
When the base layer has Enable Mouse unchecked, the World Space UI elements receive click events.

I would just disable the base layer Enable Mouse property but my game UI resides at this level.

Does this make sense? The base UI is on the right side -- and it works. The world space ui element is the green arrows. Orange indicates a mouse over state. It isn't clickable.

Image
Last edited by stonstad on 08 Dec 2023, 21:06, edited 1 time in total.
 
User avatar
jsantos
Site Admin
Posts: 3938
Joined: 20 Jan 2012, 17:18
Contact:

Re: WorldSpaceUI Question - Click Events

08 Dec 2023, 10:43

It seems your base UI is intercepting the mouse (click) events. A view is "consuming" click events when HitTest returns a non-null instance:
if (HitTest(mouse.x, mouse.y))
{
    ev.Use();
}
To confirm this, you could remove the ev.Use() line and everything should work. But that's not the right solution.

It seems your base UI is taking the whole space and always returning non-null for HitTest. I am not sure why this is happening but anyways we should be able to be smarter and only consume the event if the view really processed the event (not when hit testing returns non-null).

Do you think you could create a small repro case of this scenario?
 
User avatar
stonstad
Topic Author
Posts: 241
Joined: 06 Jun 2016, 18:14
Location: Lesser Magellanic Cloud
Contact:

Re: WorldSpaceUI Question - Click Events

08 Dec 2023, 21:17

I can confirm that commenting out ev.use resolves the issue. I can confirm that all intermediate layers are transparent or disabled for hit test. My current work-around to fix click events is to check for mouse over within the world space UI (which works), and then disable the base view's Enable Mouse property. A click event can then be received, and then I re-enable Mouse Enabled on mouse up. It's a total hack. I'm not sure what a reproduction project looks like -- Stellar is pretty involved at this point.

Camera, Depth 1 -> Cosmos
Camera, Depth 2 -> World Space UI
Camera, Depth 3 -> Player Camera
Camera, Depth 4 -> Base UI
 
User avatar
jsantos
Site Admin
Posts: 3938
Joined: 20 Jan 2012, 17:18
Contact:

Re: WorldSpaceUI Question - Click Events

11 Dec 2023, 15:04

Could you please create a ticket for this? I am not sure right now if we should remove ev.Use() from the code, because there are other parts (Mouse movement as you discovered, or gamepad actions) that totally ignore it.
 
User avatar
stonstad
Topic Author
Posts: 241
Joined: 06 Jun 2016, 18:14
Location: Lesser Magellanic Cloud
Contact:

Re: WorldSpaceUI Question - Click Events

11 Dec 2023, 16:19

Who is online

Users browsing this forum: No registered users and 3 guests