Search Unity

Bug Split View Not Visible

Discussion in 'UI Toolkit' started by PAU_L, Feb 1, 2023.

  1. PAU_L

    PAU_L

    Joined:
    Feb 19, 2021
    Posts:
    11
    Hi All,

    Have been able to see a Split View in the custom controls by creating a custom class like so:

    Code (CSharp):
    1.     public class SplitView : TwoPaneSplitView {
    2.         public new class UxmlFactory : UxmlFactory<SplitView, TwoPaneSplitView.UxmlTraits> { }
    3.     }
    But when added to the Hierarchy in the UIBuilder the preview looks good but I'm not able to see the split view in the actual Editor Window.

    Unity 2022.1.3f1
     
  2. jonathanma_unity

    jonathanma_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    229
    Hi, the TwoPaneSplitView requires exactly 2 children to be functional so that might be the issue. If not I suggest using the UIToolkit debugger to inspect the split view and try to find out why it's not visible.
     
  3. PAU_L

    PAU_L

    Joined:
    Feb 19, 2021
    Posts:
    11
    As mentioned above the view is there and can be seen in the UIBuilder Preview, the problem is that it's collapsed and not visible in the Editor window to which it belongs, even when the split view contains other elements such as buttons, etc...
     
    Giagobox likes this.
  4. BagelIan

    BagelIan

    Joined:
    May 27, 2020
    Posts:
    1
    Have literally the exact same problem, please tell me it's been resolved?
     
  5. Giagobox

    Giagobox

    Joined:
    Nov 16, 2020
    Posts:
    1
    I had the same problem as you guys: the TwoPaneSplitView was perfect in the preview but the MenuItem rendered nothing (Unity project v2021.3).

    I used the Windows > UI Toolkit > debugger and I noticed that my TwoPaneSplitView had height=0 for some mysterious reasons. So my "fix" is to set a minimum height. For example:
    <ui:TwoPaneSplitView style="min-width: 400px; min-height: 400px;">...</ui:TwoPaneSplitView>


    Hope it helps you.
     
  6. rafacasari

    rafacasari

    Joined:
    Apr 9, 2019
    Posts:
    1
    I had the same issue and I didn't wanted to use fixed height solution, so here is the solution that I've found:

    In the CreateGUI() function, when initializing the treeAsset we can use CloneTree(root) instead of Instantiate() and Add(). Like this example:

    Instead of using:
    Code (CSharp):
    1.  VisualElement labelFromUXML = m_VisualTreeAsset.Instantiate();
    2. rootVisualElement.Add(labelFromUXML);
    I'm using only:
    Code (CSharp):
    1. m_VisualTreeAsset.CloneTree(rootVisualElement);
    Fixed my issue like magic, hope that this can help anyone too! ;)
     
    Brown2Fox likes this.