Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Event passthrough

Discussion in 'UI Toolkit' started by vertxxyz, Sep 15, 2019.

  1. vertxxyz

    vertxxyz

    Joined:
    Oct 29, 2014
    Posts:
    109
    Hi,
    I'm trying to make an element that receives drag events but can be clicked through (passes every other event).

    If I add this element to the hierarchy it blocks all mouse events if it's set to the default PickingMode, but if it's set to ignore it doesn't receive the drag events.

    Is there a way to selectively capture these events and pass through others?
    Do I have to re-synthesize all other types of events and send them again?

    If it makes any difference, the element that I'd like to have see the events mine doesn't use is an IMGUIContainer.

    I'm not sure if I have a fundamental misunderstanding of how the event propagation works or whether this is not straight forward. Thanks!
     
  2. CraigGraff

    CraigGraff

    Joined:
    May 7, 2013
    Posts:
    44
  3. vertxxyz

    vertxxyz

    Joined:
    Oct 29, 2014
    Posts:
    109
    Yes, of course.
    It seems like the UIElement Debugger breaks my events, if it's been launched once when my custom VisualElement will absorb all events and would need to implement synthesis for everything.
    But if it's not yet been launched then it passes events properly except for a ContextClickEvent, which I have to re-synthesise.

    I can't manage to make it work without solving for one or the other. Seeing as the debugger is quite important, I can't really merge this without it working with it.

    The code in question is here. I've added a large comment for some context.
    This is what I'm making it do:

    There's a UIElement that I've injected into the DockArea to make this happen.

    Any help sorting this out so it's bug free would be great, then everyone can have this basic feature :p

    ----

    So basically it actually works fine now, except if you launch the UIElement Debugger and inspect, Unity becomes unusable. If I try to counter that effect I can't seem to only generate one event for the IMGUIContainer I'm targetting.

    An easy way of telling whether you've doubled up on events is to make a layout with many windows together in a tab, and use middle-mouse to close one of them. If two close then you know you've got doubles.
     
    Last edited: Sep 16, 2019
    ErnestSurys likes this.
  4. vertxxyz

    vertxxyz

    Joined:
    Oct 29, 2014
    Posts:
    109
    Okay, I've got no clue what's wrong with the debugger and what I had, but I've fixed it by avoiding having my own visual element sitting where I want it, and instead have just registered my events directly to the IMGUIContainer.

    Have fun dragging between inspector tabs! (and easily selecting through other objects)