Version: 2021.3
Assembly Definition Reference のプロパティ

Assembly Definition のプロパティ

Click on an Assembly Definition Asset to set the properties for an assembly in the Inspector window.

Assembly Definition プロパティは以下のセクションに分かれています。


プロパティ 説明
Name The name for the assembly (without a file extension). Assembly names must be unique across the Project. Consider using a reverse-DNS naming style to reduce the chance of name conflicts, especially if you want to use the assembly in more than one Project.

Note: Unity uses the name you assign to the Assembly Definition asset as the default value of the Name field, but you can change the name as needed. However, if you reference an Assembly Definition by its name rather than its GUID, changing the name will break the reference.
Allow ‘unsafe’ Code アセンブリ内のスクリプトで C# の ‘unsafe’ キーワードを使用している場合は、Allow ‘unsafe’ Code オプションを有効にします。この設定を有効にすると、Unity はアセンブリをコンパイルする際に C# コンパイラーに /unsafe オプションを渡します。
Auto Referenced 定義済みのアセンブリが、このプロジェクトのアセンブリを参照するかどうかを指定します。Auto Reference オプションを無効にすると、Unity はコンパイル時にアセンブリを自動的には参照しません。これは、ビルドに含まれるかどうかには影響しません。
No Engine References これを有効にすると、Unity はアセンブリをコンパイルする際に、UnityEditor や UnityEngine への参照を加えません。
Override References Enable the Override References setting to manually specify which precompiled assemblies this assembly depends upon. When you enable Override References, the Inspector shows the Assembly References section, which you can use to specify the references.

A precompiled assembly is a library compiled outside your Unity Project. By default, assemblies you define in your Project reference all the precompiled assemblies you add to the Project, which matches how the predefined assemblies reference all precompiled assemblies. When you enable Override References, this assembly only references the precompiled assemblies you add under Assembly References.

Note: To prevent Project assemblies from automatically referencing a precompiled assembly, you can disable its Auto Referenced option. See Plugin Inspector for more information.
Root Namespace The default namespace for scripts in this assembly definition. If you use either Rider or Visual Studio as your code editor, they automatically add this namespace to any new scripts you create in this assembly definition.

For more information, see Creating an Assembly Definition asset.

Define Constraints

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. Define all the symbols in the Define Constraints setting for the constraints to be satisfied.

シンボルが未定義であることを指定するには、そのシンボルの前に否定の ! (エクスクラメーション) 記号を付けます。例えば、以下のようなシンボルを Define Constraints に指定した場合です。

  • 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. The result is that 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_2019_3_OR_NEWER

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 operation between the constraints in them. The above example is equivalent to:


Unity のビルトインの #define ディレクティブ、グローバルコンパイラーレスポンス (.rsp) ファイルで定義されているシンボル、プロジェクトの Scripting Define Symbols Player 設定で定義されているシンボルのいずれかを使用できます。ビルトインのシンボルのリストなど、詳細は プラットフォーム依存のコンパイル を参照してください。

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 the relevant platforms.

For more information, see Conditionally including an assembly.


Unity marks each constraint with an indicator based on the currently defined settings (for example, the following set of three constraints indicates that the first symbol is currently defined while the other two are not). Since each individual constraint must be true for the overall constraint to be satisfied, the Editor marks the entire Define Constraints section as currently incompatible or invalid.

Invalid or incompatible constraints are flagged.
Invalid or incompatible constraints are flagged.

To satisfy the constraints in this example, you could change the Scripting Backend to IL2CPP for the second constraint (in Player Settings) and remove the invalid characters from the third constraint. However, what often matters is how the constraints are evaluated when you build the project, not how the constraints appear in the Unity Editor (for example, you might have an assembly that you only want to include in builds that use the IL2CPP backend, but not on other builds that use the Mono backend).

Assembly Definition References

プロパティ 説明
Assembly Definition References Specify references to other assemblies that you have created using Assembly Definition assets. Unity uses these references to compile the assembly and also define the dependencies between assemblies.
Use GUIDs この設定は、Unity が他の Assembly Definition アセットへの参照をどのようにシリアル化するかを制御します。このプロパティを有効にすると、Unity は参照を Assembly Definition 名ではなく、アセットの GUID として保存します。名前ではなく GUID を使用することは、Assembly Definition アセットの名前を変更しても、それを参照する他の Assembly Definition ファイルを更新する必要がないという意味で効率的です。

For more information, see Creating an Assembly Definition asset

Assembly References

The Assembly References section only appears when you enable the Override References property (in the General section). Use this area to specify any references to precompiled assemblies on which this assembly depends.

For more information, see Referencing a precompiled, plugin assembly


アセンブリのプラットフォーム互換性を設定します。Unity は、含まれる (または除外されない) プラットフォーム上でのみ、このアセンブリをコンパイルまたは参照します。

For more information, see Creating a platform-specific assembly

Version Defines


プロパティ 説明
Resource パッケージまたはモジュール
Define 適用可能なバージョンのリソースが、この Unity プロジェクトにも存在する場合に定義するシンボルです。
Expression An expression defining a version or range of versions. See Version Define expressions.
Expression outcome The Expression evaluated as a logical statement, where “x” is the version checked. If the Expression outcome says, Invalid, then the Expression is malformed.

For more information, see Defining symbols based on project packages

Assembly Definition Reference のプロパティ