| 175 | void onEngineUnloading(MAssembly* assembly); |
| 176 | |
| 177 | bool ScriptingService::Init() |
| 178 | { |
| 179 | PROFILE_MEM(Scripting); |
| 180 | Stopwatch stopwatch; |
| 181 | |
| 182 | _objectsDictionary.EnsureCapacity(16 * 1024); |
| 183 | |
| 184 | // Initialize managed runtime |
| 185 | if (MCore::LoadEngine()) |
| 186 | { |
| 187 | LOG(Fatal, "C# runtime initialization failed."); |
| 188 | return true; |
| 189 | } |
| 190 | |
| 191 | MCore::CreateScriptingAssemblyLoadContext(); |
| 192 | |
| 193 | // Cache root domain |
| 194 | _rootDomain = MCore::GetRootDomain(); |
| 195 | |
| 196 | #if USE_SCRIPTING_SINGLE_DOMAIN |
| 197 | // Use single root domain |
| 198 | auto domain = _rootDomain; |
| 199 | #else |
| 200 | // Create Mono domain for scripts |
| 201 | auto domain = MCore::CreateDomain("Scripts Domain"); |
| 202 | #endif |
| 203 | domain->SetCurrentDomain(true); |
| 204 | _scriptsDomain = domain; |
| 205 | |
| 206 | // Add internal calls |
| 207 | registerFlaxEngineInternalCalls(); |
| 208 | |
| 209 | // Load assemblies |
| 210 | if (Scripting::Load()) |
| 211 | { |
| 212 | LOG(Fatal, "Scripting initialization failed."); |
| 213 | return true; |
| 214 | } |
| 215 | |
| 216 | stopwatch.Stop(); |
| 217 | LOG(Info, "Scripting initializated! (time: {0}ms)", stopwatch.GetMilliseconds()); |
| 218 | return false; |
| 219 | } |
| 220 | |
| 221 | #if COMPILE_WITHOUT_CSHARP |
| 222 | #define INVOKE_EVENT(name) Scripting::name(); |
nothing calls this directly
no test coverage detected