单击程序集定义资源 (Assembly Definition Asset) 可以在 Inspector 窗口中设置程序集的属性。
属性 | 描述 | |
---|---|---|
Name | 程序集的名称(不含文件扩展名)。程序集名称在整个项目中必须唯一。请考虑使用 reverse-DNS 命名样式,尤其是希望在多个项目中使用该程序集的情况下。注意:Unity 会将您分配给程序集定义资源 (Assembly Definition Asset) 的名称用作 Name 字段的默认值,但您可以根据需要更改此名称。 | |
General | ||
Allow ‘unsafe’ code | 如果在程序集内的脚本中使用了 C# /unsafe 关键字,请启用 Allow ‘unsafe’ Code 选项。启用此设置后,Unity 在编译程序集时会将 /unsafe 选项传递到 C# 编译器。 |
|
Auto Referenced | 指定是否所有预定义的程序集都应引用此项目程序集。启用此属性后,预定义的程序集将会引用项目中定义的所有程序集,这一点与预定义程序集引用预编译程序集(插件)的方式一致。 对文件禁用 Auto Reference 设置后,Unity 不会在编译过程中自动引用该文件。这不会影响 Unity 是否将文件包含在构建中。可以在平台设置 (Platform Settings) 中控制插件的构建设置 (Build Settings)。 |
|
Override References | 启用 Override References 设置可以手动指定此程序集依赖哪些预编译的程序集。启用 Override References 后,Inspector 会显示 Assembly References 部分,在此部分中可以指定引用。 预编译的程序集是在 Unity 项目外编译的库。默认情况下,在项目中定义的程序集将会引用添加到项目中的所有预编译程序集,这一点与预定义程序集引用所有预编译程序集的方式一致。启用 Override References 后,此程序集仅引用您在 Assembly References 下添加的预编译程序集。 注意:为了防止项目程序集自动引用预编译程序集,可以禁用 Auto Referenced 选项。请参阅 Plugin Inspector 以了解更多信息。 |
|
No Engine References | 启用此属性后,Unity 在编译程序集时不会添加对 UnityEditor 或 UnityEngine 的引用。 | |
Define Constraints | Specify the compiler #define directives that must be defined for Unity to compile or reference an assembly. Unity only compiles and references a Project assembly if all of the Define Constraints are satisfied. Constraints work like the #if preprocessor directive in C#, but on the assembly level instead of the script level. You must define all the symbols in the Define Constraints setting for the constraints to be satisfied. To specify that a symbol must be undefined, prefix it with a negating ! (bang) symbol. For example, if you specify the following symbols as the Define Constraints:!ENABLE_IL2CPP UNITY_2018_3_OR_NEWER The constraints are satisfied when the symbol ENABLE_IL2CPP is not defined and the symbol UNITY_2018_3_OR_NEWER is defined. In other words, Unity only compiles and references this assembly on non-IL2CPP scripting runtimes for Unity 2018.3 or newer.You can use the || (OR) operator to specify that at least one of the constraints must be present in order for the constraints to be satisfied. For example:UNITY_IOS || UNITY_EDITOR_OSX UNITY_2019_3_OR_NEWER !UNITY_ANDROID The constraints are satisfied when either UNITY_IOS or UNITY_EDITOR_OSX and UNITY_2019_3_OR_NEWER are defined and UNITY_ANDROID is not defined. Individual lines are analogous to performing a logical AND between the constraints in them. The above example is eequivalent to (UNITY_IOS OR UNITY_EDITOR_OSX ) AND (UNITY_2019_3_OR_NEWER ) AND (NOT UNITY_ANDROID ). You can use any of Unity’s built-in #define directives or any symbols defined in the Project’s Scripting Define Symbols Player setting. See Platform dependent compilation for more information, including a list of the built-in symbols. Note" The Scripting Define Symbols settings are platform-specific. If you use this setting to define whether Unity should use an assembly, make sure that you define the necessary symbols on all of the relevant platforms. |
|
Assembly Definition References | 指定对使用程序集定义资源 (Assembly Definition Assets) 创建的其他程序集的引用。 Unity 使用这些引用来编译程序集,还定义程序集之间的依赖关系。 |
|
Use GUIDs | 此设置控制 Unity 如何序列化对其他程序集定义资源 (Assembly Definition Assets) 的引用。启用此属性后,Unity 将这些引用另存为资源的 GUID,而不是程序集定义 (Assembly Definition) 名称。最好是使用 GUID 而不是名称,因为这意味着可以更改程序集定义资源 (Assembly Definition Asset) 的名称,而不必更新引用该程序集的其他程序集定义文件。 | |
Assembly References | 仅在启用 Override References 属性后才显示。使用这一区域可以指定对此程序集依赖的预编译程序集的任何引用。 | |
Platforms | 设置程序集的平台兼容性。Unity 仅在包含(或不排除)的平台上编译或引用此程序集。 | |
Version Defines | 指定要包含在编译中的资源包和模块的版本。 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.