alfiare
Topic Author
Posts: 27
Joined: 30 Nov 2017, 23:47

Whats the right way to handle noesis:Xaml.Dependencies

10 Oct 2026, 22:29

I'm recently upgraded to 4.0 and have moved all my UserControls (200+) to have the AssetDependency attribute and can get everything working.
In our project we do a ton of dynamic loading, models determining what controls get shown, template selectors etc. This all means that there are not direct dependencies in the XAML for them. I've made things work with noesis:Xaml.Dependencies declaring the things that are loading dynamically.

Our project is roughly 3 top level window XAML's that are chosen based on the mode the game is in. At the moment I have many noesis:Xaml.Dependencies in each one based on all the dynamically loaded things, lots of duplication between them, I wish there was a way to not have all the duplication of them, maintaining it sux.

What's the right way to do that?
Should I have one xaml that has all the dependencies that are ever dynamically loaded in it and reference that from top level window xaml's?
Should I put noesis:Xaml.Dependencies in many user controls that have dynamic things they load?
Is there any way that doesn't involve putting these noesis:Xaml.Dependencies in many places?
Is there any better way for a large project I'm not thinking of?
 
User avatar
jsantos
Site Admin
Posts: 4822
Joined: 20 Jan 2012, 17:18
Contact:

Re: Whats the right way to handle noesis:Xaml.Dependencies

13 Oct 2026, 15:28

An alternative is to have a single XAML file containing only noesis:Xaml.Dependencies to every UserControl, then call `NoesisXaml.RegisterDependencies` on that asset during initialization.

Note that you'll need to store a reference to this root XAML asset somewhere, such as in a `ScriptableObject` or Unity's Preloaded Assets list, so you can access it at initialization time.

This will register all your controls, and you won't need extra Xaml.Dependencies in other XAMLs.
 
alfiare
Topic Author
Posts: 27
Joined: 30 Nov 2017, 23:47

Re: Whats the right way to handle noesis:Xaml.Dependencies

13 Oct 2026, 18:10

Is there any significant downside to having additional things listed as dependencies if they don't get used 90% of the time? Is it a significant memory footprint or something?
 
User avatar
jsantos
Site Admin
Posts: 4822
Joined: 20 Jan 2012, 17:18
Contact:

Re: Whats the right way to handle noesis:Xaml.Dependencies

Yesterday, 00:05

No, it is not. The dependency simply keeps a reference to the asset so Unity includes it when building the player.

Memory is allocated when each UserControl is instantiated.

Who is online

Users browsing this forum: No registered users and 12 guests