Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Resolved Make a visualElement ignore events without any visual changes

Discussion in 'UI Toolkit' started by Zixua, May 6, 2022.

  1. Zixua

    Zixua

    Joined:
    Feb 22, 2018
    Posts:
    5
    I was trying to make some transition animation effect which triggers when the Close button pressed.
    So I need the UI and its child elements ignore all events while the animation is playing.(So that user won't press other buttons and causes undesired result.)

    I tried VisualElement.SetEnabled(false), but this changes the UI opacity. Also tried pickingMode, but that doesn't apply to its children (e.g. other buttons);

    Any Suggestions?
     
  2. griendeau_unity

    griendeau_unity

    Unity Technologies

    Joined:
    Aug 25, 2020
    Posts:
    248
    You could still use SetEnabled(false), but have a selector with the `:disabled` pseudo state
    your-element-class-name:disabled
    that sets opacity to 1. Otherwise have an input blocker on top of everything, that you enable while the transition is happening.
     
    gzeeebra likes this.
  3. activey

    activey

    Joined:
    Aug 31, 2020
    Posts:
    30
    omg, this disabled thing saved my day!!!