v3.0.3 Unity project setting "Preloaded Assets" for xamls needed?
Posted: 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.
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.
I developed multi-language localization based on official localization.unity sample.
Here is my class to store necessary resource dictionary.
Code: Select all
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")
},
...
};
}
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.