Version: Unity 6 (6000.0)
Language : English
Conditionally including assemblies
Assembly Definition properties reference

Assembly metadata and compilation details

You can define additional metadata for your assemblies and retrieve information on the assemblies included in a project build.

Setting assembly attributes

You can use assembly attributes to set metadata properties for your assemblies. By convention, assembly attribute statements are typically put in a file named AssemblyInfo.cs.

For example, the following assembly attributes specify a few [.NET assembly metadata values], an [InternalsVisibleTo] attribute, which can be useful for testing, and the Unity-defined Preserve attribute that affects how unused code is removed from an assembly when you build your project:

[assembly: System.Reflection.AssemblyCompany("Bee Corp.")]
[assembly: System.Reflection.AssemblyTitle("Bee's Assembly")]
[assembly: System.Reflection.AssemblyCopyright("Copyright 2020.")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("UnitTestAssembly")]
[assembly: UnityEngine.Scripting.Preserve]

Getting assembly information in build scripts

Use the CompilationPipeline class to retrieve information about all assemblies built by Unity for a project, including those created based on Assembly Definition assets.

For example, the following script uses the CompilationPipeline class to list all the current Player assemblies in a project:

using UnityEditor;
using UnityEditor.Compilation;
public static class AssemblyLister
{
    [MenuItem("Tools/List Player Assemblies in Console")]
    public static void PrintAssemblyNames()
    {
        UnityEngine.Debug.Log("== Player Assemblies ==");
        Assembly[] playerAssemblies =
            CompilationPipeline.GetAssemblies(AssembliesType.Player);

        foreach (var assembly in playerAssemblies)
        {
            UnityEngine.Debug.Log(assembly.name);
        }
    }
}

Additional resources

Conditionally including assemblies
Assembly Definition properties reference