diff --git a/Source/Editor/Editor.Build.cs b/Source/Editor/Editor.Build.cs index e76cb5dfe..d757c13a3 100644 --- a/Source/Editor/Editor.Build.cs +++ b/Source/Editor/Editor.Build.cs @@ -41,6 +41,8 @@ public class Editor : EditorModule options.ScriptingAPI.SystemReferences.Add("System.Xml.ReaderWriter"); options.ScriptingAPI.SystemReferences.Add("System.Text.RegularExpressions"); options.ScriptingAPI.SystemReferences.Add("System.IO.Compression.ZipFile"); + if (Profiler.Use(options)) + options.ScriptingAPI.Defines.Add("USE_PROFILER"); // Enable optimizations for Editor, disable this for debugging the editor if (options.Configuration == TargetConfiguration.Development) diff --git a/Source/Editor/Utilities/Utils.cs b/Source/Editor/Utilities/Utils.cs index 1487f1a59..147bd71b7 100644 --- a/Source/Editor/Utilities/Utils.cs +++ b/Source/Editor/Utilities/Utils.cs @@ -1452,6 +1452,7 @@ namespace FlaxEditor.Utilities inputActions.Add(options => options.BuildSDF, Editor.Instance.BuildAllMeshesSDF); inputActions.Add(options => options.TakeScreenshot, Editor.Instance.Windows.TakeScreenshot); inputActions.Add(options => options.ProfilerWindow, () => Editor.Instance.Windows.ProfilerWin.FocusOrShow()); +#if USE_PROFILER inputActions.Add(options => options.ProfilerStartStop, () => { bool recording = !Editor.Instance.Windows.ProfilerWin.LiveRecording; @@ -1461,8 +1462,9 @@ namespace FlaxEditor.Utilities inputActions.Add(options => options.ProfilerClear, () => { Editor.Instance.Windows.ProfilerWin.Clear(); - Editor.Instance.UI.AddStatusMessage($"Profiling results cleared."); + Editor.Instance.UI.AddStatusMessage("Profiling results cleared."); }); +#endif inputActions.Add(options => options.SaveScenes, () => Editor.Instance.Scene.SaveScenes()); inputActions.Add(options => options.CloseScenes, () => Editor.Instance.Scene.CloseAllScenes()); inputActions.Add(options => options.OpenScriptsProject, () => Editor.Instance.CodeEditing.OpenSolution()); diff --git a/Source/Editor/Windows/GameWindow.cs b/Source/Editor/Windows/GameWindow.cs index 56e4c4380..edcff9b98 100644 --- a/Source/Editor/Windows/GameWindow.cs +++ b/Source/Editor/Windows/GameWindow.cs @@ -249,6 +249,7 @@ namespace FlaxEditor.Windows InputActions.Add(options => options.Play, Editor.Instance.Simulation.DelegatePlayOrStopPlayInEditor); InputActions.Add(options => options.Pause, Editor.Instance.Simulation.RequestResumeOrPause); InputActions.Add(options => options.StepFrame, Editor.Instance.Simulation.RequestPlayOneFrame); +#if USE_PROFILER InputActions.Add(options => options.ProfilerStartStop, () => { bool recording = !Editor.Instance.Windows.ProfilerWin.LiveRecording; @@ -258,8 +259,9 @@ namespace FlaxEditor.Windows InputActions.Add(options => options.ProfilerClear, () => { Editor.Instance.Windows.ProfilerWin.Clear(); - Editor.Instance.UI.AddStatusMessage($"Profiling results cleared."); + Editor.Instance.UI.AddStatusMessage("Profiling results cleared."); }); +#endif InputActions.Add(options => options.Save, () => { if (Editor.IsPlayMode) diff --git a/Source/Editor/Windows/Profiler/Assets.cs b/Source/Editor/Windows/Profiler/Assets.cs index 3b408587a..bfd14a8ac 100644 --- a/Source/Editor/Windows/Profiler/Assets.cs +++ b/Source/Editor/Windows/Profiler/Assets.cs @@ -1,5 +1,6 @@ // Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. +#if USE_PROFILER using System; using System.Collections.Generic; using System.Text; @@ -301,3 +302,4 @@ namespace FlaxEditor.Windows.Profiler } } } +#endif diff --git a/Source/Editor/Windows/Profiler/CPU.cs b/Source/Editor/Windows/Profiler/CPU.cs index ab25532d4..4dd1b8eac 100644 --- a/Source/Editor/Windows/Profiler/CPU.cs +++ b/Source/Editor/Windows/Profiler/CPU.cs @@ -1,5 +1,6 @@ // Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. +#if USE_PROFILER using System; using System.Collections.Generic; using FlaxEditor.GUI; @@ -545,3 +546,4 @@ namespace FlaxEditor.Windows.Profiler } } } +#endif diff --git a/Source/Editor/Windows/Profiler/GPU.cs b/Source/Editor/Windows/Profiler/GPU.cs index b1203787e..58fbc043c 100644 --- a/Source/Editor/Windows/Profiler/GPU.cs +++ b/Source/Editor/Windows/Profiler/GPU.cs @@ -1,5 +1,6 @@ // Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. +#if USE_PROFILER using System.Collections.Generic; using FlaxEditor.GUI; using FlaxEngine; @@ -390,3 +391,4 @@ namespace FlaxEditor.Windows.Profiler } } } +#endif diff --git a/Source/Editor/Windows/Profiler/Memory.cs b/Source/Editor/Windows/Profiler/Memory.cs index 8ab279fb8..5b026fa20 100644 --- a/Source/Editor/Windows/Profiler/Memory.cs +++ b/Source/Editor/Windows/Profiler/Memory.cs @@ -1,5 +1,6 @@ // Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. +#if USE_PROFILER using System; using FlaxEngine.GUI; @@ -91,3 +92,4 @@ namespace FlaxEditor.Windows.Profiler } } } +#endif diff --git a/Source/Editor/Windows/Profiler/MemoryGPU.cs b/Source/Editor/Windows/Profiler/MemoryGPU.cs index 84853b275..205af8f58 100644 --- a/Source/Editor/Windows/Profiler/MemoryGPU.cs +++ b/Source/Editor/Windows/Profiler/MemoryGPU.cs @@ -1,5 +1,6 @@ // Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. +#if USE_PROFILER using System; using System.Collections.Generic; using System.Linq; @@ -340,3 +341,4 @@ namespace FlaxEditor.Windows.Profiler } } } +#endif diff --git a/Source/Editor/Windows/Profiler/Network.cs b/Source/Editor/Windows/Profiler/Network.cs index 6e99d6338..68c94186b 100644 --- a/Source/Editor/Windows/Profiler/Network.cs +++ b/Source/Editor/Windows/Profiler/Network.cs @@ -1,5 +1,6 @@ // Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. +#if USE_PROFILER using System; using System.Collections.Generic; using FlaxEditor.GUI; @@ -341,3 +342,4 @@ namespace FlaxEditor.Windows.Profiler } } } +#endif diff --git a/Source/Editor/Windows/Profiler/Overall.cs b/Source/Editor/Windows/Profiler/Overall.cs index e2db8f584..e70c01a54 100644 --- a/Source/Editor/Windows/Profiler/Overall.cs +++ b/Source/Editor/Windows/Profiler/Overall.cs @@ -1,5 +1,6 @@ // Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. +#if USE_PROFILER using FlaxEngine; using FlaxEngine.GUI; @@ -114,3 +115,4 @@ namespace FlaxEditor.Windows.Profiler } } } +#endif diff --git a/Source/Editor/Windows/Profiler/Physics.cs b/Source/Editor/Windows/Profiler/Physics.cs index ec80a6633..3e5ec6605 100644 --- a/Source/Editor/Windows/Profiler/Physics.cs +++ b/Source/Editor/Windows/Profiler/Physics.cs @@ -1,5 +1,6 @@ // Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. +#if USE_PROFILER using FlaxEngine; using FlaxEngine.GUI; @@ -111,3 +112,4 @@ namespace FlaxEditor.Windows.Profiler } } } +#endif diff --git a/Source/Editor/Windows/Profiler/ProfilerMode.cs b/Source/Editor/Windows/Profiler/ProfilerMode.cs index 088edd558..297d7045d 100644 --- a/Source/Editor/Windows/Profiler/ProfilerMode.cs +++ b/Source/Editor/Windows/Profiler/ProfilerMode.cs @@ -1,5 +1,6 @@ // Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. +#if USE_PROFILER using System; using System.Collections.Generic; using FlaxEditor.GUI; @@ -169,3 +170,4 @@ namespace FlaxEditor.Windows.Profiler } } } +#endif diff --git a/Source/Editor/Windows/Profiler/ProfilerWindow.cs b/Source/Editor/Windows/Profiler/ProfilerWindow.cs index 6b7a41db2..4a85c246e 100644 --- a/Source/Editor/Windows/Profiler/ProfilerWindow.cs +++ b/Source/Editor/Windows/Profiler/ProfilerWindow.cs @@ -14,6 +14,7 @@ namespace FlaxEditor.Windows.Profiler /// public sealed class ProfilerWindow : EditorWindow { +#if USE_PROFILER private readonly ToolStripButton _liveRecordingButton; private readonly ToolStripButton _clearButton; private readonly ToolStripButton _prevFrameButton; @@ -77,6 +78,7 @@ namespace FlaxEditor.Windows.Profiler } } } +#endif /// /// Initializes a new instance of the class. @@ -87,6 +89,7 @@ namespace FlaxEditor.Windows.Profiler { Title = "Profiler"; +#if USE_PROFILER var toolstrip = new ToolStrip { Parent = this, @@ -121,8 +124,10 @@ namespace FlaxEditor.Windows.Profiler FlaxEditor.Utilities.Utils.SetupCommonInputActions(this); InputActions.Bindings.RemoveAll(x => x.Callback == this.FocusOrShow); InputActions.Add(options => options.ProfilerWindow, Hide); +#endif } +#if USE_PROFILER private void OnLiveRecordingChanged() { _liveRecordingButton.Icon = LiveRecording ? Editor.Icons.Stop64 : Editor.Icons.Play64; @@ -298,5 +303,6 @@ namespace FlaxEditor.Windows.Profiler return false; } +#endif } } diff --git a/Source/Editor/Windows/Profiler/SamplesBuffer.cs b/Source/Editor/Windows/Profiler/SamplesBuffer.cs index 3a5d51f5e..5a707aa1e 100644 --- a/Source/Editor/Windows/Profiler/SamplesBuffer.cs +++ b/Source/Editor/Windows/Profiler/SamplesBuffer.cs @@ -36,7 +36,11 @@ namespace FlaxEditor.Windows.Profiler /// Initializes a new instance of the class. /// /// The maximum buffer capacity. +#if USE_PROFILER public SamplesBuffer(int capacity = ProfilerMode.MaxSamples) +#else + public SamplesBuffer(int capacity = 600) +#endif { _data = new T[capacity]; _count = 0; diff --git a/Source/Editor/Windows/Profiler/SingleChart.cs b/Source/Editor/Windows/Profiler/SingleChart.cs index cd24ac635..259af1c69 100644 --- a/Source/Editor/Windows/Profiler/SingleChart.cs +++ b/Source/Editor/Windows/Profiler/SingleChart.cs @@ -63,7 +63,11 @@ namespace FlaxEditor.Windows.Profiler /// Initializes a new instance of the class. /// /// The maximum samples to collect. +#if USE_PROFILER public SingleChart(int maxSamples = ProfilerMode.MaxSamples) +#else + public SingleChart(int maxSamples = 600) +#endif : base(0, 0, 100, DefaultHeight) { _samples = new SamplesBuffer(maxSamples);