MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Init

Method Init

Source/Engine/Scripting/Scripting.cpp:177–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175void onEngineUnloading(MAssembly* assembly);
176
177bool 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();

Callers

nothing calls this directly

Calls 5

LoadFunction · 0.50
EnsureCapacityMethod · 0.45
SetCurrentDomainMethod · 0.45
StopMethod · 0.45

Tested by

no test coverage detected