Unity + UWP – How to open the Rate Now Screen

There is a trick here, you need a different conditional define for Mono Builds and another for IL2CPP builds!

Mono Builds

#if NETFX_CORE
            string productID =  Windows.ApplicationModel.Package.Current.Id.FamilyName;
            Application.OpenURL("ms-windows-store://pdp/?ProductId=" + productID);
#endif

IL2CPP Builds

#if ENABLE_WINMD_SUPPORT
            string productID =  Windows.ApplicationModel.Package.Current.Id.FamilyName;
            Application.OpenURL("ms-windows-store://pdp/?ProductId=" + productID);
endif

The real trick is to use the #ENABLE_WINMD_SUPPORT conditional define for IL2CPP builds or #NETFX_CORE for Mono Builds.

References :

https://docs.unity3d.com/Manual/windowsstore-code-snippets.html

https://docs.microsoft.com/en-us/windows/uwp/gaming/missing-dot-net-apis-in-unity-and-uwp#feedback

Deixe um comentário

O seu endereço de e-mail não será publicado.