Unity real machine error Could not produce class with ID xx

When the real machine is running, the following error occurs:

Could not produce class with ID 64.
This could be caused by a class being stripped from the build even though it is needed. Try disabling 'Strip Engine Code' in Player Settings

This is because when Unity clips the engine code, the class code whose ID is 64 is clipped, so that it cannot be found when running. The settings for clipping code are in Build Settings->Player Settings->Player->Managed Stripping Level

The easiest way is to turn this option off. However, this will cause the final package body to become larger, so it is not recommended to close it.

Here we solve this problem by adding link.xml, first find the corresponding class in the table of  this link

 You can see that the corresponding class is MeshCollider. At this time, create a link.xml file in Assets and fill in the following content

<linker>
       <assembly fullname="UnityEngine">
            <type fullname="UnityEngine.MeshCollider" preserve="all"/>
       </assembly>
</linker>

Assembly fullname fills in the naming field where MeshCollider is located, and type fullname fills in the complete class name.

For details on code clipping and link.xml, you can view this document

It should be noted that if the class filled in link.xml only appears in the assetbundle file, and all compiled scenarios and Resouces are not used, the problem of link.xml failure will occur. At this time, you can pull an empty prefab in Resouces, and then drag the missing component to this prefab, which can solve the problem of link.xml failure.

Guess you like

Origin blog.csdn.net/shaobing32/article/details/123120420