Search Unity

Bug Path reference to assets

Discussion in 'UI Toolkit' started by Loden_Heathen, Apr 24, 2021.

  1. Loden_Heathen

    Loden_Heathen

    Joined:
    Sep 1, 2012
    Posts:
    480
    your UXML system uses string path references to images and similar for example

    Code (CSharp):
    1. <ui:VisualElement style="width: 16px; height: 16px; background-image: url(&apos;/Assets/_Heathen Engineering/BGSDK/Framework/Foundation/Runtime/Images/Token.png&apos;); margin-left: 2px;" />
    This means it will break on any change to the folder structure at all including using it in a package manager custom package.

    This makes UIElements uslesslesly fragile. It cannot be used reliably in anything other than your own custom code if this is the way your going to reference other assets as users will move things around.
    Second when this happens for example if it doesn't find the "Token.png" it throws a null reference exception wich crashes out the inspect display so the user sees nothing just a random null ref called on the OnGui no clue why unless they poke at it.

    What you should be doing IMO is
    1) Reference via asset GUID not string path
    2) If reference doesn't resolve dont crash out just use default for that expected data type and move on with life thus the worst case should be default image is loaded in its place not the icon it should have been.

    This issue makes UI Elements not fit for purpose.
     
  2. etienne_unity

    etienne_unity

    Unity Technologies

    Joined:
    Aug 31, 2017
    Posts:
    102
    Hi @lodendsg

    As of Unity version 2021.2.0a14 (latest Alpha build from the Hub at time of writing), the Builder will save asset references in a location-agnostic way (GUID and File ID added to the asset URL), while keeping the UXML and USS files human-readable (we keep the file path and asset name in the URL as a hint).
     
    Timboc likes this.
  3. Loden_Heathen

    Loden_Heathen

    Joined:
    Sep 1, 2012
    Posts:
    480
    Will that be backported I hope to 2019 LTS

    As I have noted in the past as an Asset developer I really want to use UI Elements for our editor extensions as my god its so much nicer than IMGUI :D

    But at the moment its just not fit for purpose; our couple little experaments with it have realyl taken a lot of support because it is so easy to break.

    Note asset developers target your oldest LTS version so if you want us to use it in assets it has to work there. I know 2018 LTS is still kicking around we are looking forward to that dropping off.
     
  4. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    780
  5. Kazko

    Kazko

    Joined:
    Apr 2, 2014
    Posts:
    82
    After updating, all my ui documents are broken, mainly fonts. The system warned me that without a theme file, panels will not render correctly. After creating default unity theme file, none of my fonts are respected. The font field in UI Builder does absolutely nothing, in no combination of setup (using selectors or direct). The sizing, color, etc. work, but the actual font cannot be changed :/

    Also, how do you change properties of the theme file???

    I am so frustrated at this point :(
    (yes I have a backup and can go to previous version, but guys .... really??)