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

Issues with UIElements / UIBuilder. Bugs or failure on my part?

Discussion in 'UI Toolkit' started by JMFrancia, Mar 5, 2020.

  1. JMFrancia

    JMFrancia

    Joined:
    Jan 25, 2018
    Posts:
    2
    Hey All,

    I’ve been charged with checking out the new UIElements system, to see if it would be a good fit for my team’s needs. Results so far have been mixed, but I’m hoping that some of my pain points are just ignorance on my part. Was hoping to get some input on some of the issues I’m seeing.

    1. Cannot get Visual Studio Community 8.4.7 (free version that comes w/ Unity download) to highlight syntax for UXML or USS docs. I know for a fact that VSC comes with .CSS and .XML highlighting, but he moment those extensions change to .USS / .UXML, stops working. I’ve looked around exhaustively on how to do this, because it does seem something easy to do in Visual Studio, but can’t find any options to make it work for VSC that comes with Unity.


    2. Cannot multi-select in UIBuilder Hierarchy.


    3. Can’t use UIBuilder with manually-written USS files in any way. I know that there is currently not an easy solution for loading an existing .USS file, but even when I add the .USS file via a STYLE element, it gets ignored by UIBuilder.


    4. UIBuilder is generating empty .USS files & not saving changes to .UXML files.

    To reproduce:

    Step 1: Create a new UXML document. Open it in UIBuilder.
    Step 2: Make changes to UXML (adding elements) and style those elements.
    Step 3: Save. It prompts me to name the new .USS file and I do.
    Step 4: Close UIBuilder. .USS file that was generated is blank. Re-opening the same .UXML file shows it didn’t save any styling, nor did it save changes I made by adding elements to .UXML file.


    If there is something I'm missing, would be very happy to be corrected. Otherwise if these are known bugs, or issues we can expect to see corrected soon, much more likely to use in the near future.

    Thanks in advance!
     
  2. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,203
    You did not miss it. There is no support currently for UXML and USS in the Visual Studio plugin for Unity. It's in the plans.

    This is a temporary limitation. Multi-selection is planned for the first release of the UI Builder, however, it will likely only allow re-parenting and removing multiple elements from the hierarchy at once. It will not support inline style changes on multiple elements at once, at least not initially. Shared styling should ideally come a StyleSheet and not be duplicated on every element, requiring multi-selection-editing. I'm curious what task did you try to perform that made you realize there was no multi-selection support.

    You should be able to. If you create the new UXML file with the UI Builder first using an empty USS file (generated by the UI Builder), you should be able to replace the path inside the UXML to point to your manually written USS file. The Builder should pick up your other USS file when you load your UXML back up.

    What will not work right now is if you set the <Style> tag right under the <UXML> tag, or inside a child element that is not at the root of the document. So these two <Style> tags will be ignored by the Builder:
    Code (CSharp):
    1. <UXML>
    2.     <Style path="test.uss" />
    3.     <VisualElement>
    4.         <VisualElement name="child">
    5.             <Style path="test.uss" />
    6.         </VisualElement>
    7.     </VisualElement>
    8. </UXML>
    You need at least one <Style> tag under one of the root elements:
    Code (CSharp):
    1. <UXML>
    2.     <Style path="test.uss" />
    3.     <VisualElement name="element1">
    4.         <Style path="test.uss" />
    5.     </VisualElement>
    6.     <VisualElement name="element2" />
    7. </UXML>
    That said, very soon, the UI Builder will learn how to deal with multiple USS files per UXML, including allowing you to add/remove your own USS files. It's a temporary growing pain.

    I cannot reproduce this problem. To be clear, you created the UXML file outside the UI Builder (but otherwise unmodified) and opened it in the UI Builder. What version of Unity/Builder are you using? Was the externally created UXML file manually modified before it was opened in the Builder?
     
  3. JMFrancia

    JMFrancia

    Joined:
    Jan 25, 2018
    Posts:
    2
    Thank you @uDamian for the detailed response!

    You are correct that I created the UXML file outside the UI Builder, and did not modify it. The versions I'm using are 2019.3.3f1 for Unity and UI Builder 0.8.4-Preview. The externally created UXML file was NOT modified before opening the builder.
     
  4. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,203
  5. GrayRabbitGames

    GrayRabbitGames

    Joined:
    Mar 1, 2016
    Posts:
    6
    Hi @uDamian, I wonder if there was any update on syntax highlighting for UXML and USS? Now using Visual Studio Community 8.5, still not seeing it work.