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. Dismiss Notice

How do I make elements resizable within an EditorWindow?

Discussion in 'UI Toolkit' started by LaneFox, Aug 14, 2020.

  1. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,381
    I can't seem to find a feature to make elements resizable. For example is there a simple way to make 3 VisualElement columns horizontally resizable so that their width's can be adjusted individually with a context sensitive mouse hover action and the neighbor flex elements resize to fit everything?

    From rummaging around this seems to be something called SplitView or TwoPaneSplitView. If so, is this N/A via UI Builder? How does it work via inline?
     
    dbdenny likes this.
  2. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,203
    Yes, there is a TwoPaneSplitView control for this. It was added very recently to core Unity so it's only available in 2020.2. As such, it was not yet added in UI Builder. You'll need to add it yourself in UXML via text editor. Once you do, you can edit its UXML attributes in the UI Builder.

    Note that TwoPaneSplitView needs _exactly_ two child VisualElements to work. It will throw otherwise.

    If you're not on 2020.2, and you need it for a very specific use case, you can implement something yourself using a simple MouseManipulator as shown here:
    https://github.com/Unity-Technologi...ssets/QuickIntro/Editor/FloatingDemoWindow.cs
     
    dbdenny likes this.
  3. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,381
    Thanks for the clarification! Considering the options I may wait have to wait on this feature.
     
  4. javierfed

    javierfed

    Joined:
    Apr 10, 2015
    Posts:
    50
    is there an ECD on adding it to the UI Builder? I would really like to use it, and am currently on unity v2021.3.5f1.
     
  5. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,203
    No ETA right now on this. But as I mentioned above, you can still use it in the UI Builder. You just need the initial insertion done in a text editor and make sure it has the two child containers. TwoPaneSplitView does support UXML instantiation, it's just hard to make a good workflow for it in the UI Builder due to its validation logic.