Unity includes Windows Runtime support for IL2CPP on Windows Store and Xbox One platforms. Use Windows Runtime support to call into both native system Windows Runtime APIs as well as custom .winmd files directly from managed code (scripts and DLLs).
Para activar automáticamente el soporte de Windows Runtime en IL2CPP, vaya a PlayerSettings (Edit > Project Settings > Player),, navegue a la sección Configuration, y establezca el Api Compatibility Level a .NET 4.6.
Unity automatically references Windows Runtime APIs (such as Windows.winmd on Windows Store) when it has Windows Runtime support enabled. To use custom .winmd files, import them (together with any accompanying DLLs) into your Unity project folder. Then use the Plugin Inspector to configure the files for your target platform.
In your Unity project’s scripts you can use the ENABLE_WINMD_SUPPORT
#define directive to check that your project has Windows Runtime support enabled. Use this before a call to .winmd Windows APIs or custom .winmd scripts to ensure they can run and to ensure any scripts not relevant to Windows ignore them. See the examples below.
Ejemplos
C#
void Start() {
#if ENABLE_WINMD_SUPPORT
Debug.Log("Windows Runtime Support enabled");
// Put calls to your custom .winmd API here
#endif
}
JS
function Awake() {
#if ENABLE_WINMD_SUPPORT
Debug.Log("Windows Runtime Support enabled");
// Put calls to your custom .winmd API here
#endif
}
Además de definirse cuando la compatibilidad con Windows Runtime está habilitada en IL2CPP, también se define en .NET cuando establece Compilation Overrides a Use Net Core.
! La sección de Publishing Settings de la ventana del inspector PlayerSettings, con Compilation Overrides resaltado en rojo](../uploads/Main/IL2CPP–6.png)