Search Unity

Feature Request Set Picking Mode via USS

Discussion in 'UI Toolkit' started by broots, Apr 27, 2021.

  1. broots

    broots

    Joined:
    Dec 20, 2019
    Posts:
    54
    Heya, something I've been bitten by a few times and was wondering if it's possible to see a feature crop up out of. Very simple, right now as far as I can tell, you can only set picking mode via UXML or code. The problem? You end up with code like this:

    Code (CSharp):
    1.            
    2.             pickingMode = PickingMode.Ignore;
    3.             scrollView.pickingMode = PickingMode.Ignore;
    4.             scrollView.contentContainer.pickingMode = PickingMode.Ignore;
    5.             scrollView.Q("unity-content-and-vertical-scroll-container").pickingMode = PickingMode.Ignore;
    In my case, I'm creating all of these elements dynamically via code. The only way to set the picking mode is this very clunky piece-by-piece mannor which also requires me to go into the debugger for every element and figure out which unity things have picking enabled and find some way to reference them and blah blah. Very tedious!

    Styles would already serve as a mechanism to fix this, but it's not actually something you can do right now. Not sure if this would be a simple thing or not, but it would serve to alleviate some headache for many I think.

    Cheers,
    Z.
     
    beevik_ and Mj-Kkaya like this.
  2. uMathieu

    uMathieu

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    398
    It's something that is definitely on our radar. Css has
    pointer-events: none
    , which is also inherited so its behavior is more in line with that you're trying to achieve.
     
    FaithlessOne and broots like this.
  3. broots

    broots

    Joined:
    Dec 20, 2019
    Posts:
    54
    Based on the CSS docs it sounds like exactly like what I'm looking for, set the elements click events to be ignored but still fall through to underlying elements.

    Cheers.
     
  4. andrew-lukasik

    andrew-lukasik

    Joined:
    Jan 31, 2013
    Posts:
    249
    +1
    USS seemed to let us structure and override all properties. Exceptions to this rule are a surprise.
     
  5. NovaEiz

    NovaEiz

    Joined:
    Sep 6, 2017
    Posts:
    53
    When will pointer-events appear?
     
  6. baroncocktail

    baroncocktail

    Joined:
    Jan 9, 2014
    Posts:
    2
    +1
    Coming from CSS, I use pointer-events: none all the time.
     
  7. achimmihca

    achimmihca

    Joined:
    Feb 13, 2016
    Posts:
    283
  8. ontrigger

    ontrigger

    Joined:
    Oct 31, 2016
    Posts:
    24
    For the love of god, please add pointer-events. The current behavior with uxml picking-mode is absolutely stupid - it works on only one element and one element only. It means that if you want to have an element not be clickable you need to also set all its children to picking-mode=False.
    I do not understand why that is the default behavior. In my 5 years of webdev never have I needed to disable clicks on just one specific element.
     
    VenetianFox and superarchi like this.
  9. ErnestSurys

    ErnestSurys

    Joined:
    Jan 18, 2018
    Posts:
    94
  10. achimmihca

    achimmihca

    Joined:
    Feb 13, 2016
    Posts:
    283
    I think it makes sense to have the option between "no pointer events for this element" and "no pointer events for this element and all its desendants".

    However, the later (with desendants) could be achieved using the first (only this element) and a USS rule that applies it to all desendants.

    Only thing needed really is to expose
    -unity-picking-mode
    in USS
     
  11. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    179
  12. vejab

    vejab

    Joined:
    Dec 21, 2021
    Posts:
    119
  13. chrisjstone

    chrisjstone

    Joined:
    Oct 23, 2014
    Posts:
    1
  14. AltIvan

    AltIvan

    Joined:
    Aug 3, 2013
    Posts:
    14