| Parameter | Description |
|---|---|
| rawAssembly | A byte array that is a COFF-based image containing an assembly. |
Assembly The loaded assembly.
Loads an assembly from a byte array that is a Common Object File Format (COFF)-based image.
Unity automatically loads script assemblies and managed plug-ins. To load any other assemblies from memory, use this API. This is a safer alternative to .NET's Assembly.Load(byte[]) in the Unity context. Unlike Assembly.Load, assemblies loaded with this API are guaranteed to work correctly with code reload. Also unlike Assembly.Load, this API prevents assemblies with the same AssemblyName from being loaded.
Additional resources: CurrentAssemblies.LoadFromPath
using System.IO; using UnityEditor; using UnityEngine; using UnityEngine.Assemblies;
public class AssemblyLoadingFromBytes { [MenuItem("Test/Load Assembly From Bytes")] static void LoadAssemblyFromBytes() { var assemblyBytes = File.ReadAllBytes(@"C:\Some\Path\To\TheAssembly.dll"); var assembly = CurrentAssemblies.LoadFromBytes(assemblyBytes); Debug.Log(assembly.FullName); } }
| Parameter | Description |
|---|---|
| rawAssembly | A byte array that is a COFF-based image containing an assembly. |
| rawSymbolStore | A byte array that contains the symbols for the assembly. |
Assembly The loaded assembly.
Loads an assembly from a byte array that is a Common Object File Format (COFF)-based image, including symbols for the assembly.
Unity automatically loads script assemblies and managed plug-ins. To load any other assemblies from memory, use this API. This is a safer alternative to .NET's Assembly.Load(byte[],byte[]) in the Unity context. Unlike Assembly.Load, assemblies loaded with this API are guaranteed to work correctly with code reload. Also unlike Assembly.Load, this API prevents assemblies with the same AssemblyName from being loaded.
This overload lets you supply symbols for the assembly, to enable a better debugging experience.
Additional resources: CurrentAssemblies.LoadFromPath
using System.IO; using UnityEditor; using UnityEngine; using UnityEngine.Assemblies;
public class AssemblyLoadingFromBytes { [MenuItem("Test/Load Assembly From Bytes")] static void LoadAssemblyFromBytes() { var assemblyBytes = File.ReadAllBytes(@"C:\Some\Path\To\TheAssembly.dll"); var symbolBytes = File.ReadAllBytes(@"C:\Some\Path\To\TheAssembly.pdb"); var assembly = CurrentAssemblies.LoadFromBytes(assemblyBytes, symbolBytes); Debug.Log(assembly.FullName); } }