Reusing the GUI XML from GUI.XmlLoader.loadLayout()

I am using the GUI XmlLoader to load a large number of gui layouts with identical XML markup (using {{ }} placeholders). How can I make a single HTTP request using loadLayout() and not many requests?
Basically I want to cache the XML and reuse it.
Thanks,
Michael

cc @null

Hey Michael,

If you want to reuse the same layout, you can load the layout once, store the object globally and access it.

The loadLayout method is not meant to cache the GUI even if identical since you may want it to have different values for your UI elements.

The Xml however is needed only to generate the Babylon.js GUI elements so there is no need to cache it at all.

1 Like

Hey @Michael_Scherotter1 just checking in, was your question answered? :smiley:

I need to apply the same xml layout to various objects with different context (as specified in the XmlLoader’s constructor.) How do I reuse it?
I used this method to load the XML into a data URL. It works on Chrome/Edge but fails on Firefox.

Michael

Your PG fails on firefox due to the data media type. It must be: data:text/xml instead of data:text.

If I understand your question correctly, you want to create multiple GUI instances without having to reload the XML over HTTP every time. Each instance with a different context.

Here is an example of what I think would work for you:

In this case, the XML is only ever loaded once. It must be reparsed for every GUI instantiation, but I believe that is fundamental to the design of XmlLoader.

3 Likes