Techy blog of Kalle


#guide #unity #unity3d #upm #il2cpp

In Unity (the game engine) you can tell the compiler not to strip away certain parts of your code, or to “preserve” it to use the correct term. You do this either with a [Preserve] attribute, or with a link.xml file.

Up until recently, it was unknown how to include such a link.xml file inside your UPM packages, as it had not been documented. Big thanks to maksimbu over at the Unity forums who did the most RnD here.

You have two main options:

  1. Add a section to your telling your users to create a link.xml file themselves in their Assets/ directory and add given content you specify.

  2. Embed your link.xml inside a precompiled assembly (DLL) inside your package.

We will be going through option 2.