Assembly Definition ファイル形式リファレンス
Assembly definition file format reference.
読み終わるまでの所要時間 9 分最終更新 1ヶ月前
Assembly Definition と Assembly Definition Reference のアセットは、JSON ファイルです。アセットファイルは Unity エディター内で Inspector ウィンドウを使って編集できますが、外部ツールを使って JSON コンテンツを修正することもできます。
Assembly Definition JSON
Assembly Definition は、以下のフィールドを持つ 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" : "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[]
オプション。Assembly Definition アセットで作成された他のアセンブリへの参照。Assembly Definition アセットファイルの GUID、またはアセンブリ名 (Assembly Definition の 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[]
オプション。各バージョン定義のオブジェクトを含みます。このオブジェクトには 3 つのフィールドがあります。
- 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" }]
Example Assembly Definition JSON strings
他の Assembly Definition への参照のためのアセンブリ名と 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}
他の Assembly Definition への参照のための 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}
Assembly Definition Reference JSON
Assembly Definition Reference は、以下のフィールドを持つ JSON オブジェクトです。
reference string
必須。参照するアセンブリ定義です。Assembly Definition References を参照してください。
アセンブリ名またはアセットの GUID のいずれかを使用して、Assembly Definition アセットを参照できます。AssetDatabase.AssetPathToGUID 関数を使用して、アセットの GUID を取得することができます (GUID は、すべてのアセットに関連するメタデータの一部でもあります)。
アセンブリ名の使用
{ "reference": "AssemblyA"}
Using Assembly Definition アセット GUID
{ "reference": "GUID:f4de40948f4904ecb94b59dd38aab8a1"}
Assembly Definition Reference アセットの作成 を参照してください。