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

Method Init

Source/Editor/Scripting/ScriptsBuilder.cpp:568–667  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

566}
567
568bool ScriptsBuilderService::Init()
569{
570 // Check flag
571 if (_isInited)
572 return false;
573 PROFILE_MEM(Editor);
574 _isInited = true;
575
576 // Link for Editor assembly unload event to clear cached Internal_OnCompilationEnd to prevent errors
577 auto editorAssembly = ((NativeBinaryModule*)GetBinaryModuleFlaxEngine())->Assembly;
578 editorAssembly->Unloading.Bind(onEditorAssemblyUnloading);
579
580 // Listen to scripts reloading events and forward them to c#
581 Level::ScriptsReloadStart.Bind(onScriptsReloadStart);
582 Level::ScriptsReload.Bind(onScriptsReload);
583 Level::ScriptsReloadEnd.Bind(onScriptsReloadEnd);
584 Scripting::ScriptsLoaded.Bind(onScriptsLoaded);
585
586 // Listen to code editors manager events
587 CodeEditingManager::AsyncOpenBegin.Bind(onCodeEditorAsyncOpenBegin);
588 CodeEditingManager::AsyncOpenEnd.Bind(onCodeEditorAsyncOpenEnd);
589
590 // Create source folder watcher to handle scripts modification events (create/delete scripts events are handled by the editor itself)
591 auto project = Editor::Project;
592 HashSet<ProjectInfo*> projects;
593 project->GetAllProjects(projects);
594 for (const auto& e : projects)
595 {
596 ProjectInfo* project = e.Item;
597 if (project->Name == TEXT("Flax"))
598 continue;
599 auto watcher = New<FileSystemWatcher>(project->ProjectFolderPath / TEXT("Source"), true);
600 watcher->OnEvent.Bind(sourceDirEvent);
601 SourceFoldersWatchers.Add(watcher);
602 }
603
604 // Verify project
605 if (project->EditorTarget.IsEmpty())
606 {
607 LOG(Warning, "Missing {0} property in opened project", TEXT("EditorTarget"));
608 }
609 if (project->GameTarget.IsEmpty())
610 {
611 LOG(Warning, "Missing {0} property in opened project", TEXT("GameTarget"));
612 }
613
614 // Remove any remaining files from previous Editor run hot-reloads
615 const Char *target, *platform, *architecture, *configuration;
616 ScriptsBuilder::GetBinariesConfiguration(target, platform, architecture, configuration);
617 if (StringUtils::Length(target) != 0)
618 {
619 const String targetOutput = Globals::ProjectFolder / TEXT("Binaries") / target / platform / architecture / configuration;
620 Array<String> files;
621 FileSystem::DirectoryGetFiles(files, targetOutput, TEXT("*.HotReload.*"), DirectorySearchOption::TopDirectoryOnly);
622
623 for (const auto& reference : Editor::Project->References)
624 {
625 if (reference.Project->Name == TEXT("Flax"))

Callers 1

Calls 9

LengthFunction · 0.50
BindMethod · 0.45
GetAllProjectsMethod · 0.45
AddMethod · 0.45
IsEmptyMethod · 0.45
HasCharsMethod · 0.45
GetMethod · 0.45
HasItemsMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected