Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Invisible elements and mouse

Discussion in 'UI Toolkit' started by alakoring, Sep 11, 2023.

  1. alakoring

    alakoring

    Joined:
    Mar 11, 2018
    Posts:
    27
    Is it supposed to be the case that invisible VisualElements still interact with the mouse? I have some overlays which I’m setting
    visible = false
    on, but their child elements still seem to be keeping other elements from getting mouse over.

    I’m sure I can resolve this by setting
    style.display = DisplayStyle.None
    but since the overlay should fade out, I’ll have to handle the timing of that.
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,842
  3. alakoring

    alakoring

    Joined:
    Mar 11, 2018
    Posts:
    27
    Right, but that’s a pain since I want to hide the parent (which visually hides the children). I’d like a solution which only involves the container, which contains a mix of pick and non-pick children.
     
  4. C-UITools

    C-UITools

    Unity Technologies

    Joined:
    Jun 23, 2021
    Posts:
    22
    Hi @alakoring,

    If I understand correctly, you want a USS-only solution to make sure that the container's children do not catch mouse events?
     
  5. alakoring

    alakoring

    Joined:
    Mar 11, 2018
    Posts:
    27
    I’d settle for code, but yes. I want to show an entire subtree over other UI, have its elements get mouse events while visible, and then fade it out and no longer block the underlying UI.
     
  6. C-UITools

    C-UITools

    Unity Technologies

    Joined:
    Jun 23, 2021
    Posts:
    22
    Just to make sure that I understand, you're looking to make sure that none of the children react to the mouse when the container's
    visible = false
    ? Regardless of if said children are meant to be picked when the container is visible?
     
  7. alakoring

    alakoring

    Joined:
    Mar 11, 2018
    Posts:
    27
    Right. There’s a popup display, which is positioned by a parent. And the popup should interact with the mouse (actually all it does is block clicks on the popup canceller element). If I turn off parent visibility, the popup no longer shows — but still blocks clicks.
    I’m not a web developer but I think in pretty much every view system I’ve used, hiding a view prevents any UI interaction. So that’s what I’m expecting.
    Actually, I think what I expect is a lot like SetActive(false) on a GameObject. You don’t see it or interact with it.