Version: 2019.1
Clase AppCallbacks
Universal Windows Player settings

Universal Windows Platform: WinRT API in C# scripts

Es posible utilizar la WinRT API directamente en los scripts de Unity. Sin embargo, hay algunas limitaciones y requerimientos para esto:

  • 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

Debajo hay un ejemplo para obtener publicidad utilizando WinRT API directamente:

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
    }
}
Clase AppCallbacks
Universal Windows Player settings