Unity includes Windows Runtime (WinRT) support when building for Universal Windows Platform with the IL2CPPA Unity-developed scripting back-end which you can use as an alternative to Mono when building projects for some platforms. More info
See in Glossary scripting backend. Use Windows Runtime support to call into both native system Windows Runtime APIs as well as custom .winmd files directly from managed (C#) scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
See in Glossary and plugins.
Unity automatically references Windows Runtime APIs such as Windows.winmd
on Universal Windows Platform. To use custom .winmd files, import them into your Unity project folder together with any accompanying DLLs and configure them. For more information, refer to Import and configure plug-ins.
To use WinRT API in your Unity scripts:
ENABLE_WINMD_SUPPORT
directive. This is necessary because the Editor uses MonoA scripting backend used in Unity. More infoThe following code example gets an advertising ID using WinRT API directly:
using UnityEngine;
public class WinRTAPI : MonoBehaviour
{
void Update()
{
auto adId = GetAdvertisingId();
// ...
}
string GetAdvertisingId()
{
#if ENABLE_WINMD_SUPPORT
return Windows.System.UserProfile.AdvertisingManager.AdvertisingId;
#else
return "";
#endif
}
}