Delight
Delight copied to clipboard
Localization Does Not Parse Properly When Used Within A List Item
I have this code in xml, which is a list item within a list:
<ListItem Style="NoAnimListItemStyle">
<Label Style="CardListHeaderStyle" Text="{@Loc[h_other]}" />
</ListItem>
Code generation does not parse it correctly and throws an error in UnityEditor:
Assets\Content\Views\SettingsView_g.cs(284,267): error CS0103: The name 'h_other' does not exist in the current context
What is generated is this line:
// binding <Label Text="{@Loc[h_other]}">
listItem9.Bindings.Add(new Binding(new List<BindingPath> { new BindingPath(new List<string> { }, new List<Func<object>> { }) }, new BindingPath(new List<string> { "Text" }, new List<Func<object>> { () => label11 }), () => label11.Text = Models.Loc[h_other], () => { }, false));
What it should look like is this:
// binding <Label Text="{@Loc[h_other]}">
listItem9.Bindings.Add(new Binding(new List<BindingPath> { new BindingPath(new List<string> { "[h_other]", "Label" }, new List<Func<object>> { () => Models.Loc, () => Models.Loc["[h_other]"] }) }, new BindingPath(new List<string> { "Text" }, new List<Func<object>> { () => label11 }), () => label11.Text = Models.Loc["[h_other]"], () => { }, false));
Seen on Unity 2020.3.15f2, Windows 11. This is especially frustrating because even if I manually fix them, when there is a change in the parent UI the generation also resets and throws these errors again.