程序集定义文件格式

您所在的位置:网站首页 esf文件编辑器怎么用 程序集定义文件格式

程序集定义文件格式

2023-06-26 03:12| 来源: 网络整理| 查看: 265

Unity User Manual 2022.3 (LTS) 脚本 Unity 架构 脚本编译 程序集定义 程序集定义文件格式 程序集定义引用属性 Plug-ins 程序集定义文件格式

程序集定义和程序集定义引用资源是 JSON 文件。可以使用 Inspector 窗口在 Unity 编辑器中编辑资源文件,不过也可以使用外部工具修改 JSON 内容。

程序集定义 JSON

程序集定义是具有以下字段的一种 JSON 对象:

allowUnsafeCode bool

可选。默认为 false。请参阅 Allow ‘unsafe’ Code。

"allowUnsafeCode" : true autoReferenced bool

可选。默认为 true。请参阅 Auto Referenced。

"autoReferenced": false defineConstraints string[]

可选。用作约束的符号。可以为空。请参阅 Define Constraints。

"defineConstraints": [ "UNITY_2019", "UNITY_INCLUDE_TESTS" ]

excludePlatforms string[]

可选。要排除的平台名称字符串或空数组。如果 includePlatforms 包含值,则 excludePlatforms 数组必须为空。可以使用 CompilationPipeline.GetAssemblyDefinitionPlatforms 函数检索平台名称字符串(调用此函数时,必须为当前编辑器安装对平台的支持。)请参阅 Platforms。

"includePlatforms": [], "excludePlatforms": [ "iOS", "macOSStandalone", "tvOS" ]

includePlatforms string[]

可选。要包含的平台名称字符串或空数组。如果 excludePlatforms 包含值,则 includePlatforms 数组必须为空。可以使用 CompilationPipeline.GetAssemblyDefinitionPlatforms 函数检索平台名称字符串(调用此函数时,必须为当前编辑器安装对平台的支持。)请参阅 Platforms。

"includePlatforms": [ "Android", "LinuxStandalone64", "WebGL" ], "excludePlatforms": [] name string

必需。任何合法程序集名称。

"name" : "MyAssemblyName" noEngineReferences bool

可选。默认为 false。请参阅 No Engine References。

"noEngineReferences": false optionalUnityReferences string[]

可选。在较早版本的 Unity 中,此字段对用于将程序集指定为测试程序集的 Unity References : Test Assemblies 选项进行序列化。从 Unity 2019.3 开始,不再显示该选项。该字段仍受支持,但如果在较新版本的 Unity 编辑器中重新序列化资源,则该字段会替换为等效的程序集引用。

请参阅创建测试程序集以了解有关测试程序集的更多信息。

"optionalUnityReferences": [ "TestAssemblies" ]

overrideReferences bool

可选。如果 precompiledReferences 包含值,则设置为 true。默认为 false。

请参阅 [Override References]。

"overrideReferences": true

precompiledReferences string[]

可选。引用的 DLL 库的文件名,包括扩展名,但没有其他路径元素。可以为空。除非将 overrideReferences 设置为 true,否则会忽略此数组。

请参阅 Assembly References。

"overrideReferences": true, "precompiledReferences": [ "Newtonsoft.Json.dll", "nunit.framework.dll" ] references string[]

可选。对使用程序集定义资源创建的其他程序集的引用。可以使用程序集定义资源文件的 GUID 或程序集的名称(由程序集定义的 name 字段定义)。必须对列表中的所有引用使用相同格式。可以为空。

可以使用 AssetDatabase.AssetPathToGUID 函数检索资源的 GUID。(GUID 也是与每个资源关联的元数据的一部分。)

请注意,编辑器在 Assembly Definition Inspector 中显示一个 Use GUIDs 选项。此选项不在关联 JSON 文件中进行序列化。而是从文件中找到的引用格式推断选择。

请参阅引用另一个程序集。

使用 GUID:

"references": [ "GUID:17b36165d09634a48bf5a0e4bb27f4bd", "GUID:b470eee7144904e59a1064b70fa1b086", "GUID:2bafac87e7f4b9b418d9448d219b01ab", "GUID:27619889b8ba8c24980f49ee34dbb44a", "GUID:0acc523941302664db1f4e527237feb3" ]

使用程序集名称:

"references": [ "Unity.CollabProxy.Editor", "AssemblyB", "UnityEngine.UI", "UnityEngine.TestRunner", "UnityEditor.TestRunner" ] versionDefines object[]

可选。包含每个版本定义的对象。此对象具有三个字段:

name:string – 资源的名称 *expression:string – 定义资源的版本或版本范围的表达式 define:string – 要定义的符号

请参阅 Version Defines。

"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" } ] 示例程序集定义 JSON 字符串

使用对其他程序集定义的引用的程序集名称和 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 和 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 } 程序集定义引用 JSON

程序集定义引用是具有以下字段的一种 JSON 对象:

reference string

必需。要引用的程序集定义。请参阅程序集定义引用。

可以使用程序集的名称或资源的 GUID 引用程序集定义资源。可以使用 AssetDatabase.AssetPathToGUID 函数检索资源的 GUID。(GUID 也是与每个资源关联的元数据的一部分。)

使用程序集名称:

{ "reference": "AssemblyA" }

使用程序集定义资源 GUID

{ "reference": "GUID:f4de40948f4904ecb94b59dd38aab8a1" }

请参阅创建程序集定义引用资源。

程序集定义引用属性 Plug-ins


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3