Version: 2020.3
言語: 日本語
Assembly Definition Reference のプロパティ
プラグイン

Assembly Definition ファイル形式

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[]

任意。除外するプラットフォーム名の文字列の配列、または空の配列です。excludePlatforms に値が含まれている場合、excludePlatforms の配列は空でなければなりません。プラットフォーム名の文字列は、CompilationPipeline.GetAssemblyDefinitionPlatforms 関数で取得できます (この関数を呼び出す際には、現在のエディターにプラットフォームのサポートがインストールされている必要があります)。プラットフォーム を参照してください。

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

includePlatforms string[]

任意。加えるプラットフォーム名の文字列の配列、または空の配列です。includePlatforms に値が含まれている場合、includePlatforms の配列は空でなければなりません。プラットフォーム名の文字列は、CompilationPipeline.GetAssemblyDefinitionPlatforms 関数で取得できます (この関数を呼び出す際には、現在のエディターにプラットフォームのサポートがインストールされている必要があります)。プラットフォーム を参照してください。

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

名前の文字列

必須。任意の [規則にかなったアセンブリ名](https://docs.microsoft.com/en-us/dotnet/standard/assembly/names)(https://docs.microsoft.com/ja-jp/dotnet/standard/assembly/names)。

"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 アセットで作成された他のアセンブリへの参照。アセンブリ定義アセットファイルの 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[]

任意。各バージョン定義のオブジェクトを含みます。このオブジェクトには 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

他のアセンブリ定義への参照のためのアセンブリ名と 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
}

Assembly Definition Reference JSON

Assembly Definition Reference は、以下のフィールドを持つ JSON オブジェクトです。

reference string

必須。参照するアセンブリ定義です。Assembly Definition References を参照してください。

アセンブリの名前またはアセットの GUID のいずれかを使用して、アセンブリ定義アセットを参照できます。AssetDatabase.AssetPathToGUID 関数を使用して、アセットの GUID を取得することができます。(GUID は、すべてのアセットに関連付けられたメタデータの一部でもあります。)

アセンブリ名の使用

{
    "reference": "AssemblyA"
}

Using Assembly Definition アセット GUID

{
    "reference": "GUID:f4de40948f4904ecb94b59dd38aab8a1"
}

Assembly Definition Reference アセットの作成 を参照してください。

Assembly Definition Reference のプロパティ
プラグイン