Skip to main content

Fix missing fields or properties

In deployed Unity builds —  especially with IL2CPP — you may find that some fields, methods, or properties are missing or don't work. This usually happens because Unity strips unused code during compilation to reduce build size.

Why It Happens

Unity’s code stripping system analyzes your code and removes anything it thinks isn’t used. IL2CPP is especially aggressive because it converts C# to C++, and then to native code, losing much of the reflection metadata in the process.

How to Fix

The most effective solution is adding a link.xml file in your project Assets directory to tells unity to preserve entire types or only certain fields or methods.
For your convenience, a example.link.xml is provided for you to preserve common types. Rename the file to link.xml to make it effective. 

You can also use the '[Preserve]' attribute. Please refer to the official unity documentation for a more detailed explanation 'https://docs.unity3d.com/6000.0/Documentation/Manual/managed-code-stripping.html'