Add option to build editor without profiler

This commit is contained in:
Wojtek Figat
2024-11-06 09:29:26 +01:00
parent 3f50625cc3
commit e9dcb8a8bb
15 changed files with 40 additions and 2 deletions

View File

@@ -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)

View File

@@ -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());

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -14,6 +14,7 @@ namespace FlaxEditor.Windows.Profiler
/// <seealso cref="FlaxEditor.Windows.EditorWindow" />
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
/// <summary>
/// Initializes a new instance of the <see cref="ProfilerWindow"/> 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
}
}

View File

@@ -36,7 +36,11 @@ namespace FlaxEditor.Windows.Profiler
/// Initializes a new instance of the <see cref="SamplesBuffer{T}"/> class.
/// </summary>
/// <param name="capacity">The maximum buffer capacity.</param>
#if USE_PROFILER
public SamplesBuffer(int capacity = ProfilerMode.MaxSamples)
#else
public SamplesBuffer(int capacity = 600)
#endif
{
_data = new T[capacity];
_count = 0;

View File

@@ -63,7 +63,11 @@ namespace FlaxEditor.Windows.Profiler
/// Initializes a new instance of the <see cref="SingleChart"/> class.
/// </summary>
/// <param name="maxSamples">The maximum samples to collect.</param>
#if USE_PROFILER
public SingleChart(int maxSamples = ProfilerMode.MaxSamples)
#else
public SingleChart(int maxSamples = 600)
#endif
: base(0, 0, 100, DefaultHeight)
{
_samples = new SamplesBuffer<float>(maxSamples);