"Xaml not found" for every file when Unity recomplies.
I only have two XAML files in my project now, but every time Unity complies and the Xaml is used I get "Xaml not found '...'". To fix this, I have to change reimport each xaml file. They then work again until Unity recompiles again. This happens in a blank Xaml file:
I am on Unity 6000.0.26f1.
Code: Select all
using Noesis;
namespace Survival.Views
{
public partial class GameHUD : UserControl
{
public GameHUD()
{
InitializeComponent();
}
private void InitializeComponent()
{
NoesisUnity.LoadComponent(this);
}
};
}
Re: "Xaml not found" for every file when Unity recomplies.
This issue occurs because there are no strong references to these XAML files. I assume your file is named GameHUD.xaml.cs and the corresponding XAML file is GameHUD.xaml, correct?
If you’re following this naming pattern, any XAML file where GameHUD is used should include a dependency on GameHUD.xaml. You can verify this in the Dependencies section displayed in the inspector for each XAML file.
If you’re following this naming pattern, any XAML file where GameHUD is used should include a dependency on GameHUD.xaml. You can verify this in the Dependencies section displayed in the inspector for each XAML file.
Re: "Xaml not found" for every file when Unity recomplies.
I don't know if this is possible because all of my usercontrols are used with my navigation system. I load XAML files using Addressables and then push them onto the stack. Because of this, none of the controls reference each other in the editor.
Is this a new limitation? I never had this issue in the past.
Is this a new limitation? I never had this issue in the past.
Re: "Xaml not found" for every file when Unity recomplies.
This is not something new. It has been always like this, if you don't have a hard-reference to an asset (xaml, font, image) Unity won't package it in the player build.
We automatically detect the usage of UserControls (if you follow our conventions).
Are you sure this was working before?
We automatically detect the usage of UserControls (if you follow our conventions).
Are you sure this was working before?
Re: "Xaml not found" for every file when Unity recomplies.
Just to be clear, this happens in the editor. I can change a single line of code and it then gives me this error until I reimport.
Yes, I've never had to reference anything manually. I have a Root UserControl which handles scaling and a NavFrame UserControl inside of that which you push elements into. I am creating UserControls by right clicking -> create. The only difference in this project is that I am using VS Code instead of Blend, so I haven't created the Blend project. Everything else is exactly the same.
Yes, I've never had to reference anything manually. I have a Root UserControl which handles scaling and a NavFrame UserControl inside of that which you push elements into. I am creating UserControls by right clicking -> create. The only difference in this project is that I am using VS Code instead of Blend, so I haven't created the Blend project. Everything else is exactly the same.
Re: "Xaml not found" for every file when Unity recomplies.
Yes, I understand that you are working in the Editor, but this behavior will be the same in a standalone build.
By default, if you follow the conventions mentioned above (which you haven't explicitly confirmed), any XAML that uses a UserControl will automatically include that UserControl in its list of dependencies. You can inspect these dependencies by clicking on the XAML in question.
Could you please provide the XAML that is causing the issue, along with the list of dependencies that we automatically generated?
By default, if you follow the conventions mentioned above (which you haven't explicitly confirmed), any XAML that uses a UserControl will automatically include that UserControl in its list of dependencies. You can inspect these dependencies by clicking on the XAML in question.
Could you please provide the XAML that is causing the issue, along with the list of dependencies that we automatically generated?
Re: "Xaml not found" for every file when Unity recomplies.
So I forgot to mention something important (and we should document this properly) that was discussed in this thread
viewtopic.php?t=3552
You can use the Load() method of NoesisXAML to load the root document. This should work and dependencies should automatically load.
viewtopic.php?t=3552
You can use the Load() method of NoesisXAML to load the root document. This should work and dependencies should automatically load.
-
- BrandonReinhart
- Posts: 10
- Joined:
Re: "Xaml not found" for every file when Unity recomplies.
I ran into this as well, but I found a solution.
1. I use addressables for all of my assets. There are no static asset links in the project and no scene. This ensures we are 100% mod compatible, forced to dog food our asset loading pipeline. I create my main camera and NoesisView in a bootstrapper at game start.
(The Noesis inspector can't find dependencies for the preview view if the referenced assets are addressables. I don't have a solution for that yet, but that is a source of console spew. I suspect an editor plugin that is aware of addressables and can load them into the NoesisXamlProvider instance during an editor session is all that's needed.)
2. I have a manifest system that allows me to associate a key with an asset url. This url can be an Address or it can be a file path to the mod directory. A loader is responsible for loading the asset from the correct location.
Example:
All of these panels would be loaded at game start, along with any references by other mod <UIs> manifests.
3. Noesis cannot handle links to assets via address, natively. But it does have the provider API.
When I load each of these assets, I register them upon load:
This associates the id (key) with the actual asset.
4. During runtime, I can use the path argument on LoadComponent to find my xaml:
This works and everything runs fine.
1. I use addressables for all of my assets. There are no static asset links in the project and no scene. This ensures we are 100% mod compatible, forced to dog food our asset loading pipeline. I create my main camera and NoesisView in a bootstrapper at game start.
(The Noesis inspector can't find dependencies for the preview view if the referenced assets are addressables. I don't have a solution for that yet, but that is a source of console spew. I suspect an editor plugin that is aware of addressables and can load them into the NoesisXamlProvider instance during an editor session is all that's needed.)
2. I have a manifest system that allows me to associate a key with an asset url. This url can be an Address or it can be a file path to the mod directory. A loader is responsible for loading the asset from the correct location.
Example:
Code: Select all
<UIs>
<UI id="main_window" url="AOR/UI/MainWindow"/> // This is an address to an Addressable.
<UI id="main_menu_panel" url="AOR/UI/MainMenu/MainMenuPanel"/>
<UI id="hud_panel" url="AOR/UI/HUD/HudPanel"/>
<UI id="modded_panel" url="mod://MyBigMod/MainPanel"/> // This is a path to a file on disk in the Mod directory.
</UIs>
3. Noesis cannot handle links to assets via address, natively. But it does have the provider API.
When I load each of these assets, I register them upon load:
Code: Select all
private LoadedAsset<NoesisXaml> _noesisXaml;
public NoesisXaml noesisXaml => _noesisXaml.asset;
public async Task LoadAsync(UIData data)
{
// I write loaders for all asset types in my game which are aware of addressables and disk files (for mods).
var noesisXamlLoader = new NoesisXamlLoader();
_noesisXaml = await noesisXamlLoader.LoadAsync(data.url);
NoesisXamlProvider.instance.Register(data.id, noesisXaml);
}
4. During runtime, I can use the path argument on LoadComponent to find my xaml:
Code: Select all
public class MainMenuPanel : UserControl
{
public MainMenuPanel()
{
InitializeComponent();
}
private void InitializeComponent()
{
NoesisUnity.LoadComponent(this, "main_menu_panel");
}
}
Last edited by BrandonReinhart on 19 Jan 2025, 23:43, edited 9 times in total.
-
- BrandonReinhart
- Posts: 10
- Joined:
Re: "Xaml not found" for every file when Unity recomplies.
Images work the same way. I author a texture loader that understands Addressables and disk (mod) folders. Then I register the loaded images with the NoesisTextureProvider by key:
And in Xaml I can just use the keys:
So this pretty easily makes for mod driven UI content for Noesis and Unity. I'll probably write up a blog post and then I can provide the loader code.
I haven't experimented with mod driven code behind yet, but I assume that works given other projects doing the same thing.
Code: Select all
NoesisTextureProvider.instance.Register(data.id, texture);
And in Xaml I can just use the keys:
Code: Select all
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Text="Main Menu - TEST"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="48"
Foreground="White" />
<Image Source="goblin_test"
Width="200"
Height="200" />
</StackPanel>
I haven't experimented with mod driven code behind yet, but I assume that works given other projects doing the same thing.
-
- BrandonReinhart
- Posts: 10
- Joined:
Re: "Xaml not found" for every file when Unity recomplies.
I've been pleased to see Noesis C# code is very clean, simple, and easy to work with. Thank you.
Who is online
Users browsing this forum: MarioBarbero and 2 guests