Create or edit the assembly definitions
Configure assembly definitions so the Editor compiles package scripts as separate assemblies.
Read time 3 minutesLast updated 20 days ago
When you create a Unity Package Manager (UPM) package that contains code, you must include at least one assembly definition file ().
.asmdefThe Unity Editor relies on the assembly definition file to compile the scripts in your package as a separate unit. Unlike scripts in your project's folder (which the Editor automatically compiles), the Editor ignores scripts inside the folder unless they're part of an assembly definition.
AssetsPackagesFor more information about assembly definitions, refer to organizing scripts into assemblies.
Create an assembly definition
When you start developing your package, you need only one assembly definition per package folder that contains code (, , , ). When you create a package using the Package Manager window, Unity creates the assembly definitions in these folders for you. If you decide to organize your code into more complex folder structures, you might need more assembly definition files:
EditorRuntimeTests/EditorTests/Runtime- If you create folders at the same level as the four basic code folders, the additional folders require files.
.asmdef - If you create subfolders within the four basic code folders, you can optionally create additional files for the code if you want to put that code in separate assemblies.
.asmdef
If you create a more complex folder structure and need to create additional assembly definitions, refer to creating assembly assets.
Edit an assembly definition
When you create a package using the Package Manager window, Unity populates some assembly definition fields for you. Use these steps to review the populated fields, add values to optional fields, and add references to other assemblies.
To edit an assembly definition:
-
Open the Project window and go to the folder for your package.
-
Go to the,
Editor, orRuntimefolder for the assembly definition you want to edit.Test -
Select the assembly definition file.
-
Go to thewindow.Inspector
?
-
Set the fields as necessary. Common fields that might need editing include:
- Name: The name of the assembly. Other scripts can reference this name in their own files.
.asmdef - Assembly Definition References: If your assembly depends on other assemblies, you can add them here. Examples include or an
UnityEngine.UIassembly that depends on a customEditorassembly.Runtime - Platforms: You can limit this assembly to specific platforms.
- Name: The name of the assembly. Other scripts can reference this name in their own
-
Select Apply at the bottom of the Inspector window.