Legacy Documentation: Version 2018.2 (Go to current version)
Compiler options
How IL2CPP works
Other Versions

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
and Xbox OneMicrosoft’s eighth generation video game console.
See in Glossary
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).

To automatically enable Windows Runtime support in IL2CPP, go to PlayerSettings (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
> Player), navigate to the Configuration section, and set the Api Compatibility Level to .NET 4.6.

The Configuration section of the PlayerSettings window. The options shown above change depending on your chosen build platform.
The Configuration section of the PlayerSettings window. 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
}

In addition to being defined when Windows Runtime support is enabled in IL2CPP, it is also defined in .NET when you set Compilation Overrides to Use Net Core.

The Publishing Settings section of the PlayerSettings Inspector window, with Compilation Overrides highlighted in red
The Publishing Settings section of the PlayerSettings Inspector window, with Compilation Overrides highlighted in red

• 2017–05–16 Page amended with no editorial review

Did you find this page useful? Please give it a rating:

Compiler options
How IL2CPP works