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

Method LoadEngine

Source/Engine/Scripting/Runtime/DotNet.cpp:282–323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282bool MCore::LoadEngine()
283{
284 PROFILE_CPU();
285 PROFILE_MEM(ScriptingCSharp);
286
287 // Initialize hostfxr
288 if (InitHostfxr())
289 return true;
290
291 // Prepare managed side
292 CallStaticMethod<void>(GetStaticMethodPointer(TEXT("Init")));
293#ifdef MCORE_MAIN_MODULE_NAME
294 // MCORE_MAIN_MODULE_NAME define is injected by Scripting.Build.cs on platforms that use separate shared library for engine symbols
295 ::String flaxLibraryPath(Platform::GetMainDirectory() / TEXT(MACRO_TO_STR(MCORE_MAIN_MODULE_NAME)));
296#else
297 ::String flaxLibraryPath(Platform::GetExecutableFilePath());
298#endif
299#if PLATFORM_MAC
300 // On some platforms all native binaries are side-by-side with the app in a different folder
301 if (!FileSystem::FileExists(flaxLibraryPath))
302 {
303 flaxLibraryPath = ::String(StringUtils::GetDirectoryName(Platform::GetExecutableFilePath())) / StringUtils::GetFileName(flaxLibraryPath);
304 }
305#endif
306#if !PLATFORM_SWITCH
307 if (!FileSystem::FileExists(flaxLibraryPath))
308 {
309 LOG(Error, "Flax Engine native library file is missing ({0})", flaxLibraryPath);
310 }
311#endif
312 RegisterNativeLibrary("FlaxEngine", flaxLibraryPath.Get());
313
314 MRootDomain = New<MDomain>("Root");
315 MDomains.Add(MRootDomain);
316
317 char* buildInfo = CallStaticMethod<char*>(GetStaticMethodPointer(TEXT("GetRuntimeInformation")));
318 LOG(Info, ".NET runtime version: {0}", ::String(buildInfo));
319 GC::FreeMemory(buildInfo);
320 Ready = true;
321
322 return false;
323}
324
325void MCore::UnloadEngine()
326{

Callers

nothing calls this directly

Calls 6

InitHostfxrFunction · 0.85
GetStaticMethodPointerFunction · 0.85
RegisterNativeLibraryFunction · 0.85
StringFunction · 0.50
GetMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected