Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Simultaneous Vertical and Horizontal Scrolling

Discussion in 'UIElements' started by MomoRazor, Aug 28, 2019.

  1. MomoRazor

    MomoRazor

    Joined:
    Apr 30, 2016
    Posts:
    5
    Hi, I've started working with UIElements this week, and I think I've stumbled into an issue regarding the ScrollView VisualElement. I'm attempting to achieve a double sided scroll, since internally, the diagram will be potentially be increasing in both dimensions. However, I can't seem to stop the #unity-content-container and #unity-content-viewport dimensions from tracking each other.

    In my investigation, it seems that when I set flex-direction (in uss) to 'row' on the #unity-content-viewport, the horizontal scrolling becomes allowed, as widths of 'viewport' and 'container' stop tracking each other, and similarly if flex-direction is set to 'column', vertical scrolling becomes allowed.

    Any advice on how I can achieve this functionality? Can I set the #unity-content-container to grow according to its content only? Thank you.
     
  2. jonathanma_unity

    jonathanma_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    61
  3. MomoRazor

    MomoRazor

    Joined:
    Apr 30, 2016
    Posts:
    5
    I've instantiated the ScrollView within UXML, not C#, so how do set the ScrollViewMode as such for a UXML ScrollView? I've already set show-horizontal-scroller="true" and show-vertical-scroller="true"
     
  4. jonathanma_unity

    jonathanma_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    61
    From within UXML you can set the "mode" attribute to "VerticalAndHorizontal"
     
    MomoRazor likes this.
  5. MomoRazor

    MomoRazor

    Joined:
    Apr 30, 2016
    Posts:
    5
    Thanks that works perfectly! Could you point to where this is documented in the UIElements documentations? Because I couldn't seem to find it and it's quite an important attribute to know about for the ScrollView VisualElement. Thanks again for the support!
     
    jonathanma_unity likes this.
  6. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    356