hybridclr的HybridCLR/Generate/LinkXml命令虽然可以智能地扫描出你当前引用的AOT类型,却不能预知你未来将来使用的 类型。因此你仍然需要有规划地提前在 Assets/link.xml,通用的link.xml需要哪些类,有没有博主根据经验收集这个文件?
时间: 2024-03-19 14:43:20 浏览: 160
是的,您需要有规划地提前在Assets/link.xml中声明您的项目所需的AOT类型以确保它们在编译时不被删除。
对于通用的link.xml文件,不同的项目可能需要保留的类型有所不同。但是,以下是一个可能有用的参考列表,其中包含了常见的Unity和.NET类型:
```xml
<linker>
<assembly fullname="mscorlib">
<type fullname="System.Object" preserve="all"/>
<type fullname="System.String" preserve="all"/>
<type fullname="System.Boolean" preserve="all"/>
<type fullname="System.Char" preserve="all"/>
<type fullname="System.Int32" preserve="all"/>
<type fullname="System.Single" preserve="all"/>
<type fullname="System.Double" preserve="all"/>
<type fullname="System.Decimal" preserve="all"/>
<type fullname="System.Collections.Generic.List`1" preserve="all"/>
<type fullname="System.Collections.Generic.Dictionary`2" preserve="all"/>
<!-- 其他您所需的类型 -->
</assembly>
<assembly fullname="System.Core">
<type fullname="System.Linq.Expressions.Expression" preserve="all"/>
<type fullname="System.Linq.Expressions.MemberExpression" preserve="all"/>
<type fullname="System.Linq.Expressions.ConstantExpression" preserve="all"/>
<type fullname="System.Linq.Expressions.UnaryExpression" preserve="all"/>
<type fullname="System.Linq.Expressions.BinaryExpression" preserve="all"/>
<type fullname="System.Linq.Expressions.MethodCallExpression" preserve="all"/>
<type fullname="System.Linq.Expressions.ParameterExpression" preserve="all"/>
<type fullname="System.Linq.Expressions.NewArrayExpression" preserve="all"/>
<type fullname="System.Linq.Expressions.NewExpression" preserve="all"/>
<type fullname="System.Linq.Expressions.MemberInitExpression" preserve="all"/>
<type fullname="System.Linq.Expressions.ConditionalExpression" preserve="all"/>
<type fullname="System.Func`1" preserve="all"/>
<type fullname="System.Func`2" preserve="all"/>
<type fullname="System.Action`1" preserve="all"/>
<type fullname="System.Action`2" preserve="all"/>
<type fullname="System.Action`3" preserve="all"/>
<type fullname="System.Action`4" preserve="all"/>
<type fullname="System.Action`5" preserve="all"/>
<type fullname="System.Action`6" preserve="all"/>
<type fullname="System.Action`7" preserve="all"/>
<type fullname="System.Action`8" preserve="all"/>
<type fullname="System.Action`9" preserve="all"/>
<type fullname="System.Action`10" preserve="all"/>
<type fullname="System.Action`11" preserve="all"/>
<type fullname="System.Action`12" preserve="all"/>
<type fullname="System.Action`13" preserve="all"/>
<type fullname="System.Action`14" preserve="all"/>
<type fullname="System.Action`15" preserve="all"/>
<type fullname="System.Action`16" preserve="all"/>
<!-- 其他您所需的类型 -->
</assembly>
<assembly fullname="UnityEngine">
<type fullname="UnityEngine.Vector2" preserve="all"/>
<type fullname="UnityEngine.Vector3" preserve="all"/>
<type fullname="UnityEngine.Vector4" preserve="all"/>
<type fullname="UnityEngine.Quaternion" preserve="all"/>
<type fullname="UnityEngine.Color" preserve="all"/>
<type fullname="UnityEngine.Bounds" preserve="all"/>
<type fullname="UnityEngine.Matrix4x4" preserve="all"/>
<type fullname="UnityEngine.Transform" preserve="all"/>
<type fullname="UnityEngine.GameObject" preserve="all"/>
<type fullname="UnityEngine.Component" preserve="all"/>
<type fullname="UnityEngine.MonoBehaviour" preserve="all"/>
<type fullname="UnityEngine.Object" preserve="all"/>
<type fullname="UnityEngine.AnimationCurve" preserve="all"/>
<type fullname="UnityEngine.AnimationClip" preserve="all"/>
<type fullname="UnityEngine.AnimationState" preserve="all"/>
<type fullname="UnityEngine.Animation" preserve="all"/>
<type fullname="UnityEngine.Animator" preserve="all"/>
<type fullname="UnityEngine.Physics" preserve="all"/>
<type fullname="UnityEngine.Rigidbody" preserve="all"/>
<type fullname="UnityEngine.Collider" preserve="all"/>
<type fullname="UnityEngine.MeshRenderer" preserve="all"/>
<type fullname="UnityEngine.SkinnedMeshRenderer" preserve="all"/>
<type fullname="UnityEngine.Renderer" preserve="all"/>
<type fullname="UnityEngine.Material" preserve="all"/>
<type fullname="UnityEngine.Mesh" preserve="all"/>
<type fullname="UnityEngine.Camera" preserve="all"/>
<type fullname="UnityEngine.RectTransform" preserve="all"/>
<type fullname="UnityEngine.CanvasGroup" preserve="all"/>
<type fullname="UnityEngine.UI.Graphic" preserve="all"/>
<type fullname="UnityEngine.UI.Image" preserve="all"/>
<type fullname="UnityEngine.UI.Text" preserve="all"/>
<type fullname="UnityEngine.UI.Button" preserve="all"/>
<type fullname="UnityEngine.UI.Toggle" preserve="all"/>
<type fullname="UnityEngine.UI.Slider" preserve="all"/>
<type fullname="UnityEngine.UI.Scrollbar" preserve="all"/>
<type fullname="UnityEngine.UI.InputField" preserve="all"/>
<type fullname="UnityEngine.UI.Selectable" preserve="all"/>
<!-- 其他您所需的类型 -->
</assembly>
<!-- 其他您所需的程序集 -->
</linker>
```
请注意,这只是一个建议的模板,您需要根据您的项目需求进行相应的修改。如果您使用了第三方库或插件,您可能需要添加它们的程序集和类型到link.xml中以确保它们不被删除。
阅读全文