Click or drag to resize

ScriptDomain Class

A ScriptDomain acts as a container for all code that is loaded dynamically at runtime. Despite the name, the code is not actually loaded into an isolated domain but is instead loaded into the main application domain. This is due to unity restrictions. The main responsiblility of the domin is to separate pre-compiled game code from runtime-loaded code. As a result, you will only be able to access types from the domain that were loaded at runtime. Any pre-compiled game code will be ignored. Any assemblies or scripts that are loaded into the domain at runtime will remain until the application exits so you should be careful to avoid loading too many assemblies. You would typically load user code at statup in a 'Load' method which would then exist and execute until the game exits. Multiple domain instances may be created but you should note that all runtime code will be loaded into the current application domain. The ScriptDomain simply masks the types that are visible.
Inheritance Hierarchy
SystemObject
  UMod.ScriptingScriptDomain

Namespace:  UMod.Scripting
Assembly:  UMod (in UMod.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class ScriptDomain

The ScriptDomain type exposes the following members.

Properties
  NameDescription
Public propertyAssemblies
Get all assemblies loaded into this domain.
Public propertyEnumerateAssemblies
Enumerate all assemblies loaded into this domain.
Public propertyExecutionContext
Get the ScriptExecutionContext for this domain.
Public propertyIsDisposed
Has this domain been disposed.
Top
Methods
  NameDescription
Public methodKill
Destroy the script domain and any mod code that is currently executing. If you just want to stop running mod scripts then use Kill.
Public methodLoadAndActivateAssembly(Byte, Byte)
Attempts to load and activate a managed assembly for the specified raw bytes. The assembly will also be activated using meaning that all mod script types will be created and will start receiving events.
Public methodLoadAndActivateAssembly(AssemblyName, Byte)
Attempts to load and activate a managed assembly with the specified AssemblyName. The assembly will also be activated using meaning that all mod script types will be created and will start receiving events. Note that security checks cannot be performed when using this load method. If security checks are required then use one of the other overloads.
Public methodLoadAndActivateAssembly(String, Byte)
Attempts to load and activate a managed assembly from the specified path. The assembly will also be activated using meaning that all mod script types will be created and will start receiving events.
Public methodLoadAndActivateAssemblyFromResources
Attempts to load and activate a managed assembly from the resources folder. The resource asset must be a TextAsset in order to be loaded successfully. The assembly will also be activated using meaning that all mod script types will be created and will start receiving events.
Public methodLoadAndActivateAssemblyWithSymbols
Attempts to load and activate a managed assembly from the specified raw bytes along with the debugging symbols. The assembly will also be activated using meaning that all mod script types will be created and will start receiving events.
Public methodLoadAssembly(Byte, Byte)
Attempts to load a managed assembly from the specified raw bytes.
Public methodLoadAssembly(AssemblyName, Byte)
Attempts to load the specified managed assembly into the sandbox app domain.
Public methodLoadAssembly(String, Byte)
Attempts to load the specified managed assembly into the sandbox app domain.
Public methodLoadAssemblyFromResources
Attempts to load a managed assembly from the specified resources path into the sandbox app domain. The target asset must be a TextAsset in order to be loaded successfully.
Public methodLoadAssemblyWithSymbols
Attempts to load a managed assembly from the specified raw bytes. The debug symbols for the assembly will also be loaded from the specified symbol data.
Public methodResolveType
Public methodSecurityCheckAssembly(Byte, Assembly, CodeSecurityEngine, CodeSecurityReport, Boolean, Byte)
Attempts to perform security validation on the specified assembly data. Failure to load the data will result in a fail result.
Public methodSecurityCheckAssembly(AssemblyName, Assembly, CodeSecurityEngine, CodeSecurityReport, Boolean, Byte)
Attempts to perform security validation on the specified assembly name. Failure to load the data will result in a fail result.
Public methodSecurityCheckAssembly(String, Assembly, CodeSecurityEngine, CodeSecurityReport, Boolean, Byte)
Attempts to perform security validation on the assembly at the specified location. Failure to load the data will result in a fail result.
Public methodTryLoadAndActivateAssembly(Byte, ScriptAssembly, Byte)
Attempts to load and activate a managed assembly with the specified raw bytes. The assembly will also be activated using meaning that all mod script types will be created and will start receiving events. Note that security checks cannot be performed when using this load method. If security checks are required then use one of the other overloads. Any exceptions that are thrown during loading will be caught and cause a load failure.
Public methodTryLoadAndActivateAssembly(AssemblyName, ScriptAssembly, Byte)
Attempts to load and activate a managed assembly with the specified AssemblyName. The assembly will also be activated using meaning that all mod script types will be created and will start receiving events. Note that security checks cannot be performed when using this load method. If security checks are required then use one of the other overloads. Any exceptions that are thrown during loading will be caught and cause a load failure.
Public methodTryLoadAndActivateAssembly(String, ScriptAssembly, Byte)
Attempts to load and activate a managed assembly from the specified path. The assembly will also be activated using meaning that all mod script types will be created and will start receiving events. Any exceptions that are thrown during loading will be caught and cause a load failure.
Public methodTryLoadAndActivateAssemblyWithSymbols
Attempts to load and activate managed assembly from the specified raw bytes. The debug symbols for the assembly will also be loaded from the specified symbol data. Any exceptions that are thrown during loading will be caught and cause a load failure.
Public methodTryLoadAssembly(Byte, ScriptAssembly, Byte)
Attempts to load a managed assembly from the raw assembly data. Any exceptions thrown while loading will be caught.
Public methodTryLoadAssembly(AssemblyName, ScriptAssembly, Byte)
Attempts to load a managed assembly with the specified name. Any exceptions thrown while loading will be caught.
Public methodTryLoadAssembly(String, ScriptAssembly, Byte)
Attempts to load the managed assembly at the specified location. Any exceptions throw while loading will be caught.
Public methodTryLoadAssemblyWithSymbols
Attempts to load a managed assembly from the raw assembly data. The debug symbols for the assembly will also be loaded from the specified symbol data. Any exceptions thrown while loading will be caught.
Top
See Also