Nir Hasson
Topic Author
Posts: 71
Joined: 10 Nov 2013, 21:20
Contact:

Noesis.GUI.LoadXaml not working on Unity 2021.3 with Version 3.1.5

16 Nov 2022, 16:18

Hi,

After upgrading to Noesis 3.1.5 from Noesis 3.0.1 it seems that Noesis.GUI.LoadXaml no longer works and always returns null.
We used to be able to call it with a partial filename and get a valid object.
I.E A call to Noesis.GUI.LoadXaml("Assets/Spivi/UI/WorkoutGroupParticipants.xaml") used to work but no longer works.
What am I doing wrong?
 
User avatar
jsantos
Site Admin
Posts: 3905
Joined: 20 Jan 2012, 17:18
Contact:

Re: Noesis.GUI.LoadXaml not working on Unity 2021.3 with Version 3.1.5

17 Nov 2022, 09:25

That scenario was dangerous in 3.0 because even though it was working in the Editor, in standalone you will get a null as the XAML is not being referenced anywhere and optimized out by Unity.

So, the recommended approach now is having a strong reference to the XAML you want to load (for example, storing it in a public property of a MonoBehaviour and then using NoesisXaml.Load method.

Note that, if the XAML is a dependency to other XAML, then the function Noesis.GUI.LoadXaml will work correctly because it is already reference by another resource.
 
Nir Hasson
Topic Author
Posts: 71
Joined: 10 Nov 2013, 21:20
Contact:

Re: Noesis.GUI.LoadXaml not working on Unity 2021.3 with Version 3.1.5

17 Nov 2022, 10:04

We do have a strong reference to these xaml files, but still can't load them in runtime.
I did some additional test, after entering play mode when I explicitly reimport the target asset and then try to load it works.
 
Nir Hasson
Topic Author
Posts: 71
Joined: 10 Nov 2013, 21:20
Contact:

Re: Noesis.GUI.LoadXaml not working on Unity 2021.3 with Version 3.1.5

17 Nov 2022, 11:43

I think I found the source of the issue.
In the specific case where the issue happens, the object that holds a reference to the xaml was a prefab.
When I unpacked the prefab the reference kept and everything worked as expected.
 
User avatar
jsantos
Site Admin
Posts: 3905
Joined: 20 Jan 2012, 17:18
Contact:

Re: Noesis.GUI.LoadXaml not working on Unity 2021.3 with Version 3.1.5

17 Nov 2022, 12:04

We do have a strong reference to these xaml files, but still can't load them in runtime.
If you have a strong reference, the recommend way to load its xaml is using Load()
public class NoesisXaml: ScriptableObject
{
    public object Load()
    {
        RegisterDependencies();

        NoesisUnity.Init();
        return Noesis.GUI.LoadXaml(new MemoryStream(content), uri);
    }
Marking this as solved. Thanks for the feedback!

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 56 guests