Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Can uxml loaded dynamically just like webpage?

Discussion in 'UI Toolkit' started by Zarmot, Mar 7, 2019.

  1. Zarmot

    Zarmot

    Joined:
    Mar 2, 2019
    Posts:
    1
    "UXML,USS,UQuery",My first reaction to these names is that they can be loaded dynamically like web pages. Dynamic loading means that users can get the latest UXML layout from the server, which is very useful for online games. I know we can't create new classes with AOT, but what if we only use pre-written Visual Elements?
     
    Vander-Does likes this.
  2. wbahnassi_unity

    wbahnassi_unity

    Unity Technologies

    Joined:
    Mar 12, 2018
    Posts:
    28
    Zarmot, currently this is not supported as the UXML import process doesn't have a runtime API and some of its inner workings does require the asset pipeline context. That being said, I think you can still use AssetBundles for this kind of scenario (less classy, but should work).
     
  3. BradZoob

    BradZoob

    Joined:
    Feb 12, 2014
    Posts:
    66
    Weird, so will UXML be dynamic in the future, or do you just mean it simply lacks a runtime API presently?
     
  4. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    771
    Right now what happens at import time is that XML is serialized into a VisualTreeAsset object and this transformation currently needs a bunch of asset database functionality to work (same for USS -> StyleSheet).

    So to answer this question the API to turn XML/USS into their imported version is lacking and we do not plan to built it because it feels like it would place too many limitations on what could happen at import time (assuming we want to keep the feature set identical). That being said if we see a compelling customer use case for it that might change.

    Dynamically loading content from a server is support by standard Unity Asset bundles : since VisualTreeAsset/StyleSheet are seen as standard assets by Unity they can be packaged into a separate bundle that a Unity game can download on demand, for example to update layout and styles.