程序Assembly DefinitionFile Format参考
程序Assembly DefinitionFile Format参考。
阅读时间5 分钟最后更新于 6 天前
Assembly Definition 和 Assembly Definition Reference Assets 是 json 文件。可以使用 窗口在 Unity Editor 中编辑资源文件,但也可以使用 External 工具直接修改 json 内容。
Inspector員
?
Assembly Definition json
Assembly Definition 是具有以下字段的 json Object:
密钥 | Type(类型) | 必需 | 描述 |
|---|---|---|---|
| bool | 可选 | 默认情况下为 false。ON 选项含义的更多信息,请参阅 General 选项中的 Allow 'unsafe' 代码。 |
| bool | 可选 | 默认情况下为 true。ON 选项含义的更多信息,请参阅 General 选项中的自动引用。 |
| string[] | 可选 | 可以为空。有关更多信息,请参阅定义约束。 |
| string[] | 可选 | 要排除的平台 Name 字符串或空 Array。如果 |
| string[] | 可选 | 要包含的平台 Name 字符串或空 Array。如果 |
| 字符串 | 必需 | 有关更多信息,请参阅 Name。 |
| bool | 可选 | 默认情况下为 false。ON 选项含义的更多信息,请参阅 General 选项中的 No Engine引用。 |
| bool | 可选 | 默认情况下为 false。如果 |
| string[] | 可选 | 引用的 DLL 库的文件名,包括扩展名,但没有 Other 路径元素。可以为空。除非将 |
| string[] | 可选 | 对使用程序Assembly DefinitionAssets创建的Other程序集的引用。可以使用 Assembly Definition 资源文件的 GUID 或 Assembly Definition 的 您可以使用 请注意,Editor 在 Assembly Definition Inspector 中显示 Use GUIDs 选项。此选项不会在关联的 json 文件中序列化。而是根据文件中的引用形式推断选择。有关更多信息,请参阅引用程序集。 |
| 对象 | 可选 | 包含每个版本定义的 Object。此 Object 有三个字段:
|
包含程序集名称和包含平台的示例
以下程序集定义示例 Json 使用程序集名称来引用 Other 程序集定义,并使用 Key 指定包含的平台数组:
includePlatforms{ "name": “BeeAssembly”, "references": [ "Unity.CollabProxy.Editor", "AssemblyB", "UnityEngine.UI", "UnityEngine.TestRunner", "UnityEditor.TestRunner" ], "includePlatforms": [ "Android", "LinuxStandalone64", "WebGL" ], "excludePlatforms": [], "overrideReferences": true, "precompiledReferences": [ "Newtonsoft.Json.dll", "nunit.framework.dll" ], "autoReferenced": false, "defineConstraints": [ "UNITY_2019", "UNITY_INCLUDE_TESTS" ], "versionDefines": [ { "name": "com.unity.ide.vscode", "expression": "[1.7,2.4.1]", "define":"MY_SYMBOL" }, { "name": "com.unity.test-framework", "expression": "[2.7.2-preview.8]", "define":TESTS(测试) } ], "noEngineReferences": false}
包含 GUID 和排除平台的示例
以下程序集定义示例 json 使用程序集 GUID 引用其他程序集定义,并使用 Key 指定排除平台的 Array:
excludePlatforms{ "name": “BeeAssembly”, "references": [ "GUID:17b36165d09634a48bf5a0e4bb27f4bd", "GUID:b470eee7144904e59a1064b70fa1b086", "GUID:2bafac87e7f4b9b418d9448d219b01ab", "GUID:27619889b8ba8c24980f49ee34dbb44a", "GUID:0acc523941302664db1f4e527237feb3" ], "includePlatforms": [], "excludePlatforms": [ "iOS", "macOSStandalone", "tvOS" ], "allowUnsafeCode": false, "overrideReferences": true, "precompiledReferences": [ "Newtonsoft.Json.dll", "nunit.framework.dll" ], "autoReferenced": false, "defineConstraints": [ "UNITY_2019", "UNITY_INCLUDE_TESTS" ], "versionDefines": [ { "name": "com.unity.ide.vscode", "expression": "[1.7,2.4.1]", "define":"MY_SYMBOL" }, { "name": "com.unity.test-framework", "expression": "[2.7.2-preview.8]", "define":TESTS(测试) } ], "noEngineReferences": false}
程序Assembly Definition参考 json
Assembly Definition 引用是只有一个必需 Field 的 json 对象:名为 的字符串。它通过程序Nameme称或程序Assembly Definition资源 GUID 指定要引用的程序集。您可以使用 函数检索资源的 GUID。GUID 也是与每个资源关联的元数据的一部分。
referenceAssetDatabase.AssetPathToGUID以下 Assembly Definition Reference 示例按 Name 引用其他资源:
{ "reference":"AssemblyA"}
以下 Assembly Definition Reference 示例按资源 GUID 引用其他资源:
{ "reference":"GUID:f4de40948f4904ecb94b59dd38aab8a1"}