Version: 2023.1
Language : English
Linux IL2CPP cross-compiler
Managed stack traces with IL2CPP

Windows Runtime support

Unity includes Windows Runtime support for 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
on Universal Windows PlatformAn IAP feature that supports Microsoft’s In App Purchase simulator, which allows you to test IAP purchase flows on devices before publishing your application. More info
See in Glossary
platform. 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).

To automatically enable Windows Runtime support in IL2CPP, go to the Player settings (Edit > Project SettingsA broad collection of settings which allow you to configure how Physics, Audio, Networking, Graphics, Input and many other areas of your project behave. More info
See in Glossary
, then select the Player category), navigate to the Configuration section, and set the Api Compatibility Level to .NET 4.6 or .NET Standard 2.0.

The Configuration section of the Player settings. The options shown above change depending on your chosen build platform.
The Configuration section of the Player settings. The options shown above change depending on your chosen build platform.

Unity automatically references Windows Runtime APIs (such as Windows.winmd on Universal Windows Platform) 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.

Use the Plugin Inspector to configure custom .winmd files for specific platforms
Use the Plugin Inspector to configure custom .winmd files for specific platforms

In your Unity project’s 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
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. Note, this is only supported in C# scripts. See the examples below.

Examples

C#

void Start() {
  #if ENABLE_WINMD_SUPPORT
    Debug.Log("Windows Runtime Support enabled");
    // Put calls to your custom .winmd API here
  #endif
}

• 2017–05–16 Page amended

Linux IL2CPP cross-compiler
Managed stack traces with IL2CPP