-
- KeldorKatarn
- Posts: 243
- Joined:
Xaml not found - unclear about how to preload XAML assets
So I have a hard time understanding how to make sure that XAML assets are found.
In earlier documentation it was stated that some scene object needs to reference the asset. I've done that and that doesn't seem to do the trick.
Then I actively called xaml.Load(); on the asset that I have referenced in Start(). That works.
However now I have made my code a package, so the asset and the scene and the gameobject referencing it live in a package.
If I now import that package into a new project, open the scene and run it... it no longer works. I get "xaml not found", even though the same code works in the project where the package is created.
I'm confused on how to assure xamls are loadable at this point?
In earlier documentation it was stated that some scene object needs to reference the asset. I've done that and that doesn't seem to do the trick.
Then I actively called xaml.Load(); on the asset that I have referenced in Start(). That works.
However now I have made my code a package, so the asset and the scene and the gameobject referencing it live in a package.
If I now import that package into a new project, open the scene and run it... it no longer works. I get "xaml not found", even though the same code works in the project where the package is created.
I'm confused on how to assure xamls are loadable at this point?
Re: Xaml not found - unclear about how to preload XAML assets
Your scene should contain a game object (camera for example) with a NoesisView where your root XAML is set. The view will load the XAML for you. If you don't have a NoesisView for your XAML then you need to manually load the XAML doing xaml.Load();.
This is only for the root documents, dependencies (like UserControl or Dictionaries) are injected as dependencies (hard-references) and automatically loaded.
This is only for the root documents, dependencies (like UserControl or Dictionaries) are injected as dependencies (hard-references) and automatically loaded.
-
- KeldorKatarn
- Posts: 243
- Joined:
Re: Xaml not found - unclear about how to preload XAML assets
Nevermind, just figured out there's a special way to include samples in a package. Noesis had no chance to find the path the way I was doing it.. sorry I'll fix that
-
- BrandonReinhart
- Posts: 29
- Joined:
Re: Xaml not found - unclear about how to preload XAML assets
For future discoverers of this thread.
Internally, Noesis Unity keeps a Dictionary of some string (key) to a loaded xaml asset. By default that key is the path to the asset as if it were a static ref (ex: "Assets/Data/UI/MainMenu"). This code is in the NoesisXamlProvider.
If you want to load your asset using your own subsystem (for mods, async addressables, etc) you can register the asset after you've loaded it:
And later, when you want to load a given component, you can use this key to associate the C# class with the correct xaml:
You will need to also register any images with the NoesisTextureProvider.
Those providers may overwrite your entries if you use disk paths like "Assets/UI/MainMenu" when they try to register static asset references, so use something else.
Internally, Noesis Unity keeps a Dictionary of some string (key) to a loaded xaml asset. By default that key is the path to the asset as if it were a static ref (ex: "Assets/Data/UI/MainMenu"). This code is in the NoesisXamlProvider.
If you want to load your asset using your own subsystem (for mods, async addressables, etc) you can register the asset after you've loaded it:
Code: Select all
NoesisXamlProvider.instance.Register(my_key, noesisXaml);
Code: Select all
NoesisUnity.LoadComponent(this, my_key);
Those providers may overwrite your entries if you use disk paths like "Assets/UI/MainMenu" when they try to register static asset references, so use something else.
-
- KeldorKatarn
- Posts: 243
- Joined:
Re: Xaml not found - unclear about how to preload XAML assets
Thanks, that's very usefulFor future discoverers of this thread.
[...]
Who is online
Users browsing this forum: jinfox and 2 guests