Version: 2019.2
AppCallbacks class
Universal Windows Player settings

Universal Windows Platform: WinRT API in C# scripts

It is possible to use WinRT API directly in Unity 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
. However there are limitations and requirements for this:

  • Scripts must be written in C#
  • API compatibility level must be set to .NET 4.6 or .NET Standard 2.0 in the player settings
  • Because the same script code is also used by Unity Editor (which always uses Mono), all code that uses WinRT API must be under ENABLE_WINMD_SUPPORT define

Below is an example for getting advertising 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
    }
}
AppCallbacks class
Universal Windows Player settings