You'd create a new instance of the domain, and when using it, you'd access it as such:
// get ref to the current domain before we create a new one
const original_domain = Il2cpp::get_domain();
// initialize our custom domain
const domain = Il2cpp:init("Aetherim/CustomDomain");
if ( domain != original_domain )
{
// mono_thread_push_appdomain_ref / is there an il2cpp equivalent?
mono_thread_push_appdomain_ref(domain);
const auto custom_domain = Il2cpp::set_domain(domain, false);
if ( custom_domain ) {
// attach the thread to the new domain
Il2cpp::thread_attach( domain );
// perform w/e custom domain logic here
// ...
// reattach to the main thread
Il2cpp::set_domain(original_domain, true);
}
}
It should be possible to allow the creation and loading of custom domains from custom
.cs
files.I don't know if this would be useful, but it's likely possible and it extends the usability of Aetherim, so it's worth checking out.
I could also be overthinking this when there's much simpler ways of going about custom C# script execution.
The implementation details for this is rough and incomplete, and comments regarding the issue as a whole would be gratefully appreciated.
Implementation Details
We would use IL2CPP's
il2cpp_init()
andil2cpp_domain_set()
export to initialize a new domain.Aetherim doesn't currently expose these for use, but can be added pretty easily. A rough example can be seen here, though may not be 100% correct.
You'd create a new instance of the domain, and when using it, you'd access it as such: