diff --git a/Source/Editor/Editor.cpp b/Source/Editor/Editor.cpp index ce42154da..a9cecd56a 100644 --- a/Source/Editor/Editor.cpp +++ b/Source/Editor/Editor.cpp @@ -625,6 +625,7 @@ bool Editor::Init() exit(failed ? 1 : 0); return true; } + PROFILE_CPU(); // If during last lightmaps baking engine crashed we could try to restore the progress ShadowsOfMordor::Builder::Instance()->CheckIfRestoreState(); @@ -633,10 +634,13 @@ bool Editor::Init() Managed = New(); // Show splash screen - if (EditorImpl::Splash == nullptr) - EditorImpl::Splash = New(); - EditorImpl::Splash->SetTitle(Project->Name); - EditorImpl::Splash->Show(); + { + PROFILE_CPU_NAMED("Splash"); + if (EditorImpl::Splash == nullptr) + EditorImpl::Splash = New(); + EditorImpl::Splash->SetTitle(Project->Name); + EditorImpl::Splash->Show(); + } // Initialize managed editor Managed->Init(); diff --git a/Source/Editor/Editor.cs b/Source/Editor/Editor.cs index 81d94b6d5..d96f6f55f 100644 --- a/Source/Editor/Editor.cs +++ b/Source/Editor/Editor.cs @@ -84,97 +84,97 @@ namespace FlaxEditor /// /// The windows module. /// - public readonly WindowsModule Windows; + public WindowsModule Windows; /// /// The UI module. /// - public readonly UIModule UI; + public UIModule UI; /// /// The thumbnails module. /// - public readonly ThumbnailsModule Thumbnails; + public ThumbnailsModule Thumbnails; /// /// The simulation module. /// - public readonly SimulationModule Simulation; + public SimulationModule Simulation; /// /// The scene module. /// - public readonly SceneModule Scene; + public SceneModule Scene; /// /// The prefabs module. /// - public readonly PrefabsModule Prefabs; + public PrefabsModule Prefabs; /// /// The scene editing module. /// - public readonly SceneEditingModule SceneEditing; + public SceneEditingModule SceneEditing; /// /// The progress reporting module. /// - public readonly ProgressReportingModule ProgressReporting; + public ProgressReportingModule ProgressReporting; /// /// The content editing module. /// - public readonly ContentEditingModule ContentEditing; + public ContentEditingModule ContentEditing; /// /// The content database module. /// - public readonly ContentDatabaseModule ContentDatabase; + public ContentDatabaseModule ContentDatabase; /// /// The content importing module. /// - public readonly ContentImportingModule ContentImporting; + public ContentImportingModule ContentImporting; /// /// The content finder module. /// - public readonly ContentFindingModule ContentFinding; + public ContentFindingModule ContentFinding; /// /// The scripts editing /// - public readonly CodeEditingModule CodeEditing; + public CodeEditingModule CodeEditing; /// /// The scripts documentation /// - public readonly CodeDocsModule CodeDocs; + public CodeDocsModule CodeDocs; /// /// The editor state machine. /// - public readonly EditorStateMachine StateMachine; + public EditorStateMachine StateMachine; /// /// The editor options manager. /// - public readonly OptionsModule Options; + public OptionsModule Options; /// /// The editor per-project cache manager. /// - public readonly ProjectCacheModule ProjectCache; + public ProjectCacheModule ProjectCache; /// /// The undo/redo /// - public readonly EditorUndo Undo; + public EditorUndo Undo; /// /// The icons container. /// - public readonly EditorIcons Icons; + public EditorIcons Icons; /// /// Gets the main transform gizmo used by the . @@ -209,26 +209,36 @@ namespace FlaxEditor /// /// The game project info. /// - public readonly ProjectInfo GameProject; + public ProjectInfo GameProject; /// /// The engine project info. /// - public readonly ProjectInfo EngineProject; + public ProjectInfo EngineProject; internal Editor() { Instance = this; + } + internal void Init(bool isHeadless, bool skipCompile, bool newProject, Guid startupScene) + { Log("Setting up C# Editor..."); + _isHeadlessMode = isHeadless; + _startupSceneCmdLine = startupScene; + Profiler.BeginEvent("Projects"); EngineProject = ProjectInfo.Load(StringUtils.CombinePaths(Globals.StartupFolder, "Flax.flaxproj")); GameProject = ProjectInfo.Load(Internal_GetProjectPath()); + Profiler.EndEvent(); + Profiler.BeginEvent("Icons"); Icons = new EditorIcons(); Icons.LoadIcons(); + Profiler.EndEvent(); // Create common editor modules + Profiler.BeginEvent("Modules"); RegisterModule(Options = new OptionsModule(this)); RegisterModule(ProjectCache = new ProjectCacheModule(this)); RegisterModule(Scene = new SceneModule(this)); @@ -245,46 +255,15 @@ namespace FlaxEditor RegisterModule(CodeDocs = new CodeDocsModule(this)); RegisterModule(ProgressReporting = new ProgressReportingModule(this)); RegisterModule(ContentFinding = new ContentFindingModule(this)); + Profiler.EndEvent(); StateMachine = new EditorStateMachine(this); Undo = new EditorUndo(this); - UIControl.FallbackParentGetDelegate += OnUIControlFallbackParentGet; - } - private ContainerControl OnUIControlFallbackParentGet(UIControl control) - { - // Check if prefab root control is this UIControl - var loadingPreview = Viewport.Previews.PrefabPreview.LoadingPreview; - if (loadingPreview != null) - { - // Link it to the prefab preview to see it in the editor - loadingPreview.customControlLinked = control; - return loadingPreview; - } - return null; - } - - internal void RegisterModule(EditorModule module) - { - Log("Register Editor module " + module); - - _modules.Add(module); - if (_isAfterInit) - _modules.Sort((a, b) => a.InitOrder - b.InitOrder); - if (_areModulesInited) - module.OnInit(); - if (_areModulesAfterInitEnd) - module.OnEndInit(); - } - - internal void Init(bool isHeadless, bool skipCompile, bool newProject, Guid startupScene) - { if (newProject) InitProject(); EnsureState(); - _isHeadlessMode = isHeadless; - _startupSceneCmdLine = startupScene; Log("Editor init"); if (isHeadless) Log("Running in headless mode"); @@ -333,6 +312,32 @@ namespace FlaxEditor StateMachine.LoadingState.StartInitEnding(skipCompile); } + private ContainerControl OnUIControlFallbackParentGet(UIControl control) + { + // Check if prefab root control is this UIControl + var loadingPreview = Viewport.Previews.PrefabPreview.LoadingPreview; + if (loadingPreview != null) + { + // Link it to the prefab preview to see it in the editor + loadingPreview.customControlLinked = control; + return loadingPreview; + } + return null; + } + + internal void RegisterModule(EditorModule module) + { + Log("Register Editor module " + module); + + _modules.Add(module); + if (_isAfterInit) + _modules.Sort((a, b) => a.InitOrder - b.InitOrder); + if (_areModulesInited) + module.OnInit(); + if (_areModulesAfterInitEnd) + module.OnEndInit(); + } + internal void EndInit() { EnsureState(); diff --git a/Source/Editor/ProjectInfo.cs b/Source/Editor/ProjectInfo.cs index 7534de230..c7b84a560 100644 --- a/Source/Editor/ProjectInfo.cs +++ b/Source/Editor/ProjectInfo.cs @@ -149,6 +149,7 @@ namespace FlaxEditor return _projectsCache[i]; } + Profiler.BeginEvent(path); try { // Load @@ -205,6 +206,10 @@ namespace FlaxEditor Editor.LogError("Failed to load project \"" + path + "\"."); throw; } + finally + { + Profiler.EndEvent(); + } } /// diff --git a/Source/Engine/Engine/Base/GameBase.cpp b/Source/Engine/Engine/Base/GameBase.cpp index a4b10adf9..561485ced 100644 --- a/Source/Engine/Engine/Base/GameBase.cpp +++ b/Source/Engine/Engine/Base/GameBase.cpp @@ -106,6 +106,8 @@ int32 GameBase::LoadProduct() bool GameBase::Init() { + PROFILE_CPU(); + // Preload splash screen texture if (GameBaseImpl::HeaderFlags & GameHeaderFlags::ShowSplashScreen) {