IReadOnlyList<Assembly> A collection of assemblies.
Gets the assemblies Unity has loaded into the current execution context.
Use CurrentAssemblies.GetLoadedAssemblies
to get a list of currently loaded assemblies that can be used for reflection purposes. This is a safer alternative to .NET's AppDomain.CurrentDomain.GetAssmblies in the Unity context. Unity uses the AssemblyLoadContext mechanism for code reload, which means assemblies can be loaded and unloaded at runtime. AppDomain.CurrentDomain.GetAssemblies
returns a list of all loaded assemblies, which may include assemblies in the unloaded state and lead to exceptions and logical errors in the Editor code.
using System.Text; using UnityEditor; using UnityEngine; using UnityEngine.Assemblies;
public class LoadedAssemblyInfo { [MenuItem("Test/Get Loaded Assembly Info")] static void GetLoadedAssemblyInfo() { var sb = new StringBuilder(); sb.AppendLine("Currently loaded assemblies are:");
foreach (var assembly in CurrentAssemblies.GetLoadedAssemblies()) { sb.AppendLine(assembly.FullName); }
Debug.Log(sb.ToString()); } }