NoesisView for Unity on macOS
My main UI is a NoesisView component on the main Camera GameObject.
At the start, I have a StartMPGame xaml.
I'd like to switch that xaml out with the game HUD xaml at runtime.
I'm trying all this stuff but it's not working. I'm new to Noesis.
Qs) Is this even possible to do at runtime? If so, how do I do this properly?
Thank you.
Unity 2022.3.12f1
Noesis 3.2.2
At the start, I have a StartMPGame xaml.
I'd like to switch that xaml out with the game HUD xaml at runtime.
I'm trying all this stuff but it's not working. I'm new to Noesis.
Code: Select all
noesisView.enabled = false;
noesisView.Xaml.UnregisterDependencies();
noesisView.Content.DataContext = hudViewModel;
noesisView.Xaml = hudXaml;
noesisView.LoadXaml(true);
noesisView.enabled = true;
Thank you.
Unity 2022.3.12f1
Noesis 3.2.2
Re: NoesisView for Unity on macOS
I figured it out. It's an order of operations issue
Not sure if any of these are unnecessary?
Code: Select all
noesisView.enabled = false;
noesisView.Xaml.UnregisterDependencies();
noesisView.Xaml = hudXaml;
noesisView.LoadXaml(true);
noesisView.Content.DataContext = hudViewModel;
noesisView.enabled = true;
-
-
sfernandez
Site Admin
- Posts: 2908
- Joined:
Re: NoesisView for Unity on macOS
Hi,
It is better if you use a root xaml where you dynamically add or remove UI elements instead of changing the NoesisView component itself.
So you will have a xaml like this set in the NoesisView component:
And then you can just load any xaml asset and add it to the root grid:
To unload that content you can just remove it from the root panel:
Is this what you are looking for?
It is better if you use a root xaml where you dynamically add or remove UI elements instead of changing the NoesisView component itself.
So you will have a xaml like this set in the NoesisView component:
Code: Select all
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</Grid>
Code: Select all
FrameworkElement LoadContent(NoesisView view, NoesisXaml xaml, object vm)
{
FrameworkElement content = xaml.Load() as FrameworkElement;
if (content != null)
{
content.DataContext = vm;
((Grid)view.Content).Children.Add(content);
}
return content;
}
Code: Select all
void RemoveContent(NoesisView view, FrameworkElement content)
{
((Grid)view.Content).Children.Remove(content);
}
Who is online
Users browsing this forum: Ahrefs [Bot] and 1 guest