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

Question ScrollView questions

Discussion in 'UI Toolkit' started by Onigiri, Aug 13, 2020.

  1. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    469
    Hi! I have a couple of questions about scrollview. How can i force scrollers to never draw? How to make scroll wheel events work with horizontal scrollview?
     
  2. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    469
    I was able to hide scrollers by doing this
    Code (CSharp):
    1. root.Q<Scroller>().style.display = DisplayStyle.None;
     
  3. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    469
    Horizontal scrolling is working
    Code (CSharp):
    1. scrollView.RegisterCallback<WheelEvent>(ev => OnScroll(ev));
    2. private void OnScroll(WheelEvent ev)
    3. {
    4.     scrollView.scrollOffset = new Vector2(scrollView.scrollOffset.x + 10 * ev.delta.y, scrollView.scrollOffset.y);
    5. }
     
  4. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    469
    Also i had to divide ev.delta.y by 3 because its scrolls wrongly for some reason

    This will not work
    Code (CSharp):
    1. //scroll by 100 pixels on each event fire
    2. 100 * ev.delta.y
    This is working
    Code (CSharp):
    1. //scroll by 100 pixels on each event fire
    2. 100 * (ev.delta.y / 3)