GetLoadedAssemblies()
Gets the assemblies Unity has loaded into the current execution context.
Read time 1 minuteLast updated 6 days ago
Definition
- Type: Method
- Namespace: UnityEngine.Assemblies
- Assembly: UnityEngine.CoreModule
public static IReadOnlyList<Assembly> GetLoadedAssemblies()
Returns
Type | Description |
|---|---|
| IReadOnlyList<Assembly> | A collection of assemblies. |
Remarks
Use 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.GetAssemblies in the Unity context. Unity uses the AssemblyLoadContext mechanism for code reload, which means assemblies can be loaded and unloaded at runtime. 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.
CurrentAssemblies.GetLoadedAssembliesAppDomain.CurrentDomain.GetAssembliesExamples
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()); }}