Page 1 of 1

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

Posted: 16 Nov 2022, 16:18
by Nir Hasson
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?

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

Posted: 17 Nov 2022, 09:25
by jsantos
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.

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

Posted: 17 Nov 2022, 10:04
by Nir Hasson
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.

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

Posted: 17 Nov 2022, 11:43
by Nir Hasson
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.

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

Posted: 17 Nov 2022, 12:04
by jsantos
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!