If you ever built a WSA package with Unity for the Microsoft Store on Windows, maybe you have seen that in the MS store dashboard the parameter “Languages supported by your packages” only shows English.
To fix that, after the VS project is generated, you need to edit the manifest and the vcxproj file of the generated project. Here is a post-build script that can do it for you:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
#if UNITY_WSA using System.Linq; using System.Xml.Linq; using System.Collections.Generic; using UnityEngine; using UnityEditor; using UnityEditor.Callbacks; public class WPAManager { private static List<string> languages = { "en", "fr", "es", "it", "de" }; [PostProcessBuildAttribute(1)] private static void OnPostProcessBuild(BuildTarget buildTarget, string pathToBuiltProject) { string projectPath = pathToBuiltProject + "/" + Application.productName; string manifestFile = projectPath + "/Package.appxmanifest"; XDocument manifest = XDocument.Load(manifestFile); XElement rootManifest = manifest.Elements().First(); XNamespace nsManifest = rootManifest.Name.Namespace; XElement resources = rootManifest.Descendants(nsManifest + "Resources").First(); resources.RemoveNodes(); foreach (string l in languages) { resources.Add(new XElement(nsManifest + "Resource", new XAttribute("Language", l))); } manifest.Save(manifestFile); string vcxFile = projectPath + "/" + Application.productName + ".vcxproj"; XDocument vcx = XDocument.Load(vcxFile); XElement rootVcx = vcx.Elements().First(); XNamespace nsVcx = rootVcx.Name.Namespace; XElement qualifiers = rootVcx.Descendants(nsVcx + "AppxBundleAutoResourcePackageQualifiers").First(); qualifiers.Value = "DXFeatureLevel"; qualifiers.AddAfterSelf(new XElement(nsVcx + "AppxDefaultResourceQualifiers", "Language=" + string.Join(';', languages).ToUpperInvariant())); vcx.Save(vcxFile); } } #endif |