riveranb
Topic Author
Posts: 10
Joined: 20 Aug 2019, 05:48

v3.0.3 Unity project setting "Preloaded Assets" for xamls needed?

24 Jul 2020, 13:44

I upgraded my project from v2.2.x to v3.0.3 .
I developed multi-language localization based on official localization.unity sample.
Here is my class to store necessary resource dictionary.
    public class Localization
    {
        public string Name { get; set; }
        public ResourceDictionary Resources { get; set; }
    }
    public class LocalizedResource
    {
        public LocalizedResource()
        {
            Localizations = new ObservableCollection<Localization>()
            {
                new Localization
                {
                    Name = "English",
                    Resources = (ResourceDictionary)GUIUtil.LoadXaml(
                        "Assets/Xamls/Res/Localization-en.xaml")
                },
                new Localization
                {
                    Name = "繁體中文",
                    Resources = (ResourceDictionary)GUIUtil.LoadXaml(
                        "Assets/Xamls/Res/Localization-cht.xaml")
                },
                
                ...
                
            };
       }
LocalizedResource() constructor is triggered at very first timing of application launching, before NoesisView.Awake() .
Originally in v2.2.x, there's no problem here (both in Unity editor and runtime standalone player).
After upgraded to v3.0.3, also no problem in Unity editor play mode.
But when I built standalone player, application crashed in LocalizedResource() constructor at trying to load "Localization-en.xaml".
It complains the following exception.

https://imgur.com/dcNEq10


Is it right in v3.0.x, I have to sets xaml assets as "Preloaded Assets" in project settings to be loaded by code correctly at runtime?
I just tried setting Localization-en.xaml as "Preloaded Assets", and then everything back to normal again.
LocalizedResource() loads xaml assets successfully in standalone player.
 
User avatar
sfernandez
Site Admin
Posts: 2983
Joined: 22 Dec 2011, 19:20

Re: v3.0.3 Unity project setting "Preloaded Assets" for xamls needed?

24 Jul 2020, 17:25

In 3.0 we no longer provide a list of "Preloaded Assets", what we do is rely on asset dependencies to be more Unity friendly.

You can use our <noesis:Xaml.Dependencies> extension to specify in the root xaml runtime dependencies that you will manually load using LoadXaml. This way you will see when inspecting the root xaml asset that it depends also on those extra xamls.
 
riveranb
Topic Author
Posts: 10
Joined: 20 Aug 2019, 05:48

Re: v3.0.3 Unity project setting "Preloaded Assets" for xamls needed?

27 Jul 2020, 05:59

In 3.0 we no longer provide a list of "Preloaded Assets", what we do is rely on asset dependencies to be more Unity friendly.

You can use our <noesis:Xaml.Dependencies> extension to specify in the root xaml runtime dependencies that you will manually load using LoadXaml. This way you will see when inspecting the root xaml asset that it depends also on those extra xamls.

Yes, I had done that since v2.2.x, and it was no problem.
I met this problem in v3.0.3, but I also tried to build standalone player of "Localization" sample, also no problem.
So currently I can't figure out what's wrong.
I will do some more tests/check on this.

And "Preloaded Assets" I mentioned is in "Project settings -> Player -> Preloaded Assets"
 
User avatar
sfernandez
Site Admin
Posts: 2983
Joined: 22 Dec 2011, 19:20

Re: v3.0.3 Unity project setting "Preloaded Assets" for xamls needed?

27 Jul 2020, 11:35

I met this problem in v3.0.3
Can you verify that the xaml where you specify <noesis:Xaml.Dependencies> has all the xamls as dependencies in the inspector?
If you go back to unity package 3.0.2 does the standalone work again?
And "Preloaded Assets" I mentioned is in "Project settings -> Player -> Preloaded Assets"
Ok, I was confused with our old entry in Noesis settings for preloaded xamls.

Who is online

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