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 to load uxml from StreamingAssets

Discussion in 'UI Toolkit' started by guodan, Sep 9, 2020.

  1. guodan

    guodan

    Joined:
    Dec 22, 2016
    Posts:
    29
    Hi,
    I want to load .uxml from SteamingAssets.

    Code (CSharp):
    1. AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(path)
    but this function can't to do this.


    Thanks,
    -Dan
     
  2. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    Hello,

    Streaming Assets will probably not work with UXML or USS because they need to be imported first.

    StreamingAssets is a just way to tell Unity to include something in a build without doing anything to the files. Sources:
    https://forum.unity.com/threads/wor...e-streamingassets-folder.438990/#post-2837925
    https://docs.unity3d.com/Manual/StreamingAssets.html

    We would recommend you use Resources folder or Asset Bundles since we don’t support loading raw UXML at runtime (from file or even server).
     
    guodan likes this.
  3. tylerw-savatronix

    tylerw-savatronix

    Joined:
    Nov 10, 2013
    Posts:
    90
    You guys really should support loading UXML at runtime.

    From a workflow perspective it would mean UI artists don't need to rebuild to see UI changes in game, which would be a huge win in and of itself (imagine trying to do webdev and needing to do a build change every time you made small tweaks to the styling). Yes, I know there's a WYSIWYG in the editor, but let's be honest - WYSIWYG is never a good substitute for how things will actually be in game, especially at differing resolutions and such.

    The other big win is for those of us who make our games moddable (and who build the content of the game using the same process we expect modders to use). With a text file modders can modify and merge UI easily. Requiring it to be an asset means it can only ever be replaced, making every mod that would want to add or modify a layout inherently incompatible with each other.

    The current way to overcome this is to essentially wrap the entire UI Toolkit's script access in code and load in text files, which is a lot of work that'll be reproduced by lots of developers, and really should just be part of the toolkit to begin with.
     
    Korindian and Exanite like this.
  4. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    733
    Hello,

    Surely support from parsing UXML at runtime would be useful, we can't disagree with that.

    In the meantime though, one may consider using AssetBundles to load assets from some folder or server without re-building the game.
     
  5. Digika

    Digika

    Joined:
    Jan 7, 2018
    Posts:
    225
    Really guys? It's been almost 2 years and you still dont have support for loading UXML and USS assets raw? Wasnt this supposed to be one of the lucrative implied advantages of UIEelements to begin with?
     
    Last edited: Feb 23, 2021
  6. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    733
    Hello,
    What are you referring to ?
     
  7. Digika

    Digika

    Joined:
    Jan 7, 2018
    Posts:
    225
    The talk and hinted implications from early 2019 when it was bravado'ed how modular UIElements could be in terms of asset modularity, however, 2 years later and we are still stuck with ancient and rigid assetbundless. Ability to load flexible load resources like you load document frames and CSS is now a pipe dream.
     
  8. jiak1

    jiak1

    Joined:
    Feb 3, 2017
    Posts:
    4

    I was just wondering if there was an estimate on when this feature is coming out? I too require my modders to be able to load UXML and UCSS at runtime.
     
    JefferyZhu and RKar like this.
  9. JefferyZhu

    JefferyZhu

    Joined:
    Sep 11, 2017
    Posts:
    1
    I'd like to expose my UI system to modders by:

    Creating a layout UXML template that has various containers (top bar, right bar, left bar, left panel, right panel, etc), and let modders define a mapping:

    1. The container name ("TopBar") to say where they want their custom UI to go.
    2. The UXML file to load.
    3. The C# script implementation controlling the UI (instantiated via reflection in my UI manager class)

    This way the UI could be completely modder specifiable, but it breaks down if UXML cannot be loaded at runtime.

    My release horizon is many years off so I can put this off for awhile, but it would be nice to have this functionality provided by the library instead of me having implement a custom parser to build VisualElement trees.

    Also hot reloading of UXML at runtime would be very nice so modders can change their mod's UXML while the game is running and see updates without restarting the game.
     
    Last edited: Mar 30, 2021
    Vander-Does, tehb0x and jiak1 like this.
  10. Oneiros90

    Oneiros90

    Joined:
    Apr 29, 2014
    Posts:
    77
    This feature would be a game changer for the current UI system
     
    Vander-Does, tehb0x and jiak1 like this.
  11. tehb0x

    tehb0x

    Joined:
    Feb 2, 2014
    Posts:
    11
    I agree with this.
    I'm considering mod support too in my design and being able to load those files from StreamingAssets is essential for it.
    It is the main reason why I prefer the UI Toolkit over the old Unity UI for this.

    One other issue I have is I want modders to be able to change the assets that are used on a UI scene. Because Unity UI uses GameObjects it links every asset with the built-in GUID. UI Toolkit uses the path, but I don't think we have access to the path resolving. I would be great if we could implement custom path resolvers so we can search an asset in every possible source (Resource, Asset bundles and StreamingAssets).
     
    jiak1 likes this.
  12. jiak1

    jiak1

    Joined:
    Feb 3, 2017
    Posts:
    4
    I haven't seen any mention of this feature being worked on since this post was started, would you be able to provide an update if it is planned? If not, where is the best place to request it?
     
  13. marcgagnon2112

    marcgagnon2112

    Joined:
    Dec 19, 2018
    Posts:
    1
    Any news on this? I have a LOT of data from different sources and it would be fantastic to transform it dynamically and import it into the UI
     
  14. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    Unfortunately this is not coming soon. It's on our backlog, but not the highest priority for now.
     
  15. jiak1

    jiak1

    Joined:
    Feb 3, 2017
    Posts:
    4
    Thanks for the update Julia! Do you see it being worked on this year or can we expect it to keep getting pushed down the todo list? Just to clarify, would this fall under 'Addressable Asset System support' in the roadmap or would a new card be better?
     
    Last edited: Feb 6, 2022
  16. Neiyra

    Neiyra

    Joined:
    Apr 19, 2016
    Posts:
    28
  17. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
  18. jiak1

    jiak1

    Joined:
    Feb 3, 2017
    Posts:
    4
    Just following this up now it has been close to a year since I submitted feedback & over 2 years since this was first raised. It doesn't appear to be on your roadmap at all, are there any plans to support this?
     
  19. dlorre

    dlorre

    Joined:
    Apr 12, 2020
    Posts:
    700
    Not even gamepad support is on this roadmap, I think these 2 topics are much higher priority than what is listed.
     
  20. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    Heads up that the UI roadmap moved to have its own page now: https://unity.com/roadmap/unity-platform/ui

    I don't have information about when anything is coming at this point, but I can assure you that the submissions done on the roadmap are taken into account by our Product Management team when decisions are made so that's the best way to manifest your interest as it reaches that team directly :)
     
  21. dlorre

    dlorre

    Joined:
    Apr 12, 2020
    Posts:
    700
    Yes, I see a list of features but I don't see any way to send a submission? Also gamepad is now supported by most PC games, by Steam Deck and by all the consoles, do I really have to send a suggestion about supporting it? When I say supporting it I mean for example make Dragon Crashers work with the gamepad.
     
  22. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    There was supposed to be one, I'm flagging it to the people that can have it fixed :oops:

    I know I've seen it, but for sure the most people suggest the same things (or up vote the ones that are already there), the more it flags to our products team that this is high priority to users!
     
    dlorre likes this.
  23. JuliaP_Unity

    JuliaP_Unity

    Unity Technologies

    Joined:
    Mar 26, 2020
    Posts:
    666
    It's fixed! It's the first card inside "Under Consideration" :cool:
     
    dlorre likes this.