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

Method Release

Source/Engine/Scripting/Scripting.cpp:659–708  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

657}
658
659void Scripting::Release()
660{
661 PROFILE_CPU();
662 PROFILE_MEM(Scripting);
663 // Note: this action can be called from main thread (due to Mono problems with assemblies actions from other threads)
664 ASSERT(IsInMainThread());
665
666 // Fire event
667 ScriptsUnload();
668
669 // Release managed objects instances for persistent objects (assets etc.)
670 ReleaseObjects(false);
671
672 auto* flaxEngineModule = (NativeBinaryModule*)GetBinaryModuleFlaxEngine();
673 onEngineUnloading(flaxEngineModule->Assembly);
674
675 // Unload assemblies (from back to front)
676 {
677 LOG(Info, "Unloading binary modules");
678 auto modules = BinaryModule::GetModules();
679 for (int32 i = modules.Count() - 1; i >= 0; i--)
680 {
681 auto module = modules[i];
682 module->Destroy(false);
683 }
684 _nonNativeModules.ClearDelete();
685 _hasGameModulesLoaded = false;
686 }
687
688 // Cleanup
689 MCore::GC::Collect();
690 MCore::GC::WaitForPendingFinalizers();
691
692 // Flush objects
693 ObjectsRemovalService::Flush();
694
695 // Switch domain
696 auto rootDomain = MCore::GetRootDomain();
697 if (rootDomain)
698 {
699 if (!rootDomain->SetCurrentDomain(false))
700 {
701 LOG(Error, "Failed to set current domain to root");
702 }
703 }
704
705#if !USE_SCRIPTING_SINGLE_DOMAIN
706 MCore::UnloadDomain("Scripts Domain");
707#endif
708}
709
710#if USE_EDITOR
711

Callers 1

ToArrayFunction · 0.45

Calls 9

IsInMainThreadFunction · 0.85
ReleaseObjectsFunction · 0.85
onEngineUnloadingFunction · 0.85
CollectFunction · 0.85
FlushFunction · 0.50
CountMethod · 0.45
DestroyMethod · 0.45
ClearDeleteMethod · 0.45
SetCurrentDomainMethod · 0.45

Tested by

no test coverage detected