This would be relatively trivial to perform from the mono runtime. The unity scripts are bundled into the Assembly-UnityScript.dll .NET assembly. When this is loaded by the mono runtime, options are available.
mono_set_dirs( "/Library/Frameworks/Mono.framework/Home/lib", "/Library/Frameworks/Mono.framework/Home/etc" );
mono_config_parse( nullptr );
const char* managedbinarypath = "C:/Assembly-UnityScript.dll";
MonoDomain* domain = mono_jit_init(managedbinarypath)
MonoAssembly* assembly = mono_domain_assembly_open (domain, managedbinarypath);
MonoImage* image = mono_assembly_get_image (assembly);
//you could add some internal call bindings and field bindings
mono_add_internal_call( "Namespace.Class::Method", reinterpret_cast<void*>(InternalFunction));
class = mono_class_from_name( image, "Namespace", "Class" );
native_handle_field = mono_class_get_field_from_name(class, "FieldInClass" );
//you could invoke the Main method of the Main class if it exists
MonoClass* main_class = mono_class_from_name( image, "Namespace", "MainClass" );
const bool include_namespace = true;
MonoMethodDesc* entry_point_method_desc = mono_method_desc_new("Namespace.MainClass:EntryPointMethod()", include_namespace );
MonoMethod* entry_point_method = mono_method_desc_search_in_class( entry_point_method_desc, main_class );
mono_method_desc_free( entry_point_method_desc );
mono_runtime_invoke( entry_point_method, nullptr, nullptr, nullptr );
//alternatively, you could invoke an Update method
void* iter = NULL;
MonoClass* class;
MonoMethodDesc* desc;
MonoMethod* method;
while(class = mono_image_get_classes(image, &iter))
{
//if the class has an Update method
desc = mono_method_desc_new("*:Update()", false);
method = mono_method_desc_search_in_class(desc, class);
if (method != NULL){
//store MonoMethod* method in array somewhere
}
mono_method_desc_free(desc);
}
//traverse array of update methods sometime and invoke them
mono_runtime_invoke(array[0], nullptr, nullptr, nullptr);
//finish
mono_jit_cleanup( domain );
Where mono_image_get_classes
is defined:
MonoClass*
mono_image_get_classes (MonoImage *image, gpointer *iter)
{
int num_types;
int *index;
if (!iter)
return NULL;
index = (int *) iter;
/* skip the <Module> */
if (!*index)
*index = 1;
num_types = mono_image_get_table_rows (image, MONO_TABLE_TYPEDEF);
if (*index < num_types) {
(*index)++;
return mono_class_get (image, *index | MONO_TOKEN_TYPE_DEF);
} else {
*index = 0;
return NULL;
}
}
```