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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

hover effects when dragging slider

Discussion in 'UI Toolkit' started by Baste, Jul 31, 2020.

  1. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,201
    If you create a Slider, and drag it, things that have hover effects still get hover effects. The same thing goes for things like float fields. Demonstration:

    1UZZSgfiUG.gif

    That's not what happens if you drag values on built-in components (that probably still use imgui):

    As4m19WIqu.gif

    Is this an intentional change, or a bug? I can work around it on my own components, but that'd require more hacking than I believe is worthwhile (remove all hover effects while dragging)
     
  2. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,203
    Not intentional but just something that's non-trivial to "fix" and we didn't get to it yet. The main reason for hover effects still working is because they don't use events so even if an element has captured the mouse (and gets all events), hover still works.

    The simplest workaround I've found was to temporarily create a single element on top of your entire Inspector, using Absolute position with left/right/top/left set to 0. Then making this "layer" element eat the mouse with
    layerElement.pickingMode = PickingMode.Ignore;

    You're draggable element should still receive mouse events because it captured the mouse, even if it's behind this layer element.
     
    Baste likes this.
  3. crudeMe

    crudeMe

    Joined:
    Jul 8, 2015
    Posts:
    92
    Hey, sorry to revive this thread, but seems like im not the sharpest tool here. How exactly should this workaround be applied?

    I'm using Unity 2021.1.21f1 with UI Toolkit 1.0.0-preview18. I'm having this problem with vertical scroll view, when you're dragging slider.dragElement to the bottom of the scrollbar fast enough and then release mouse button, and this dragElement stuck with mouse y-pos, scrolling up and down whereever mouse goes. And only unstuck when you click on any scrollbar element.

    I'm not sure how to use this workaround. I'm creating new VisualElement with absolute position, 0,0,0,0 coordiantes, pickingMode set to ignore, sending it to back (visualElement.SendToBack())... and? How exactly should it be working? Do I need to do anything else?
     
  4. uMathieu

    uMathieu

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    384
    @crudeMe If the bug happens with the standard ScrollView, please file an issue using Help -> Report a bug.