Version: 2018.2
Clase AppCallbacks
Universal Windows Platform 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#
  • Los scripts deben estar compilados utilizando el compilador de Microsoft, no Mono. Esto requiere que se configure anulaciones de compilación para Utilizar .NET Core o Utilizar .NET Core parcialmente, en el caso último los scripts deben no estar debajo de la carpeta Plugins o Standard Assets
  • 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
    }
}

Note: when using IL2CPP scripting backend, this is only supported when using .NET 4.6 compatiblity profile.

Clase AppCallbacks
Universal Windows Platform Player Settings
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961