diff --git a/Source/Editor/Cooker/CookingData.h b/Source/Editor/Cooker/CookingData.h
index 8a5bfb58f..ce661f3e7 100644
--- a/Source/Editor/Cooker/CookingData.h
+++ b/Source/Editor/Cooker/CookingData.h
@@ -145,6 +145,16 @@ public:
///
API_FIELD(ReadOnly) BuildOptions Options;
+ ///
+ /// The name of build preset used for cooking (can be used by editor and game plugins).
+ ///
+ API_FIELD(ReadOnly) String Preset;
+
+ ///
+ /// The name of build preset target used for cooking (can be used by editor and game plugins).
+ ///
+ API_FIELD(ReadOnly) String PresetTarget;
+
///
/// The list of custom defines passed to the build tool when compiling project scripts. Can be used in build scripts for configuration (Configuration.CustomDefines).
///
diff --git a/Source/Editor/Cooker/GameCooker.cpp b/Source/Editor/Cooker/GameCooker.cpp
index b7a78c45a..ddf670873 100644
--- a/Source/Editor/Cooker/GameCooker.cpp
+++ b/Source/Editor/Cooker/GameCooker.cpp
@@ -318,7 +318,7 @@ PlatformTools* GameCooker::GetTools(BuildPlatform platform)
return result;
}
-void GameCooker::Build(BuildPlatform platform, BuildConfiguration configuration, const StringView& outputPath, BuildOptions options, const Array& customDefines)
+void GameCooker::Build(BuildPlatform platform, BuildConfiguration configuration, const StringView& outputPath, BuildOptions options, const Array& customDefines, const StringView& preset, const StringView& presetTarget)
{
if (IsRunning())
{
@@ -342,6 +342,8 @@ void GameCooker::Build(BuildPlatform platform, BuildConfiguration configuration,
data.Platform = platform;
data.Configuration = configuration;
data.Options = options;
+ data.Preset = preset;
+ data.PresetTarget = presetTarget;
data.CustomDefines = customDefines;
data.OriginalOutputPath = outputPath;
FileSystem::NormalizePath(data.OriginalOutputPath);
diff --git a/Source/Editor/Cooker/GameCooker.h b/Source/Editor/Cooker/GameCooker.h
index dec559fee..13016fd57 100644
--- a/Source/Editor/Cooker/GameCooker.h
+++ b/Source/Editor/Cooker/GameCooker.h
@@ -83,7 +83,9 @@ public:
/// The output path (output directory).
/// The build options.
/// The list of custom defines passed to the build tool when compiling project scripts. Can be used in build scripts for configuration (Configuration.CustomDefines).
- API_FUNCTION() static void Build(BuildPlatform platform, BuildConfiguration configuration, const StringView& outputPath, BuildOptions options, const Array& customDefines);
+ /// The name of build preset used for cooking (can be used by editor and game plugins).
+ /// The name of build preset target used for cooking (can be used by editor and game plugins).
+ API_FUNCTION() static void Build(BuildPlatform platform, BuildConfiguration configuration, const StringView& outputPath, BuildOptions options, const Array& customDefines, const StringView& preset = StringView::Empty, const StringView& presetTarget = StringView::Empty);
///
/// Sends a cancel event to the game building service.
diff --git a/Source/Editor/Editor.cs b/Source/Editor/Editor.cs
index 9e0375c31..19d699726 100644
--- a/Source/Editor/Editor.cs
+++ b/Source/Editor/Editor.cs
@@ -1189,7 +1189,7 @@ namespace FlaxEditor
return true;
}
- Windows.GameCookerWin.Build(target);
+ Windows.GameCookerWin.Build(preset, target);
}
Windows.GameCookerWin.ExitOnBuildQueueEnd();
diff --git a/Source/Editor/Windows/GameCookerWindow.cs b/Source/Editor/Windows/GameCookerWindow.cs
index e288553d7..e9b19c4a6 100644
--- a/Source/Editor/Windows/GameCookerWindow.cs
+++ b/Source/Editor/Windows/GameCookerWindow.cs
@@ -446,12 +446,18 @@ namespace FlaxEditor.Windows
}
}
+ private struct QueueItem
+ {
+ public string PresetName;
+ public BuildTarget Target;
+ }
+
private PresetsColumn _presets;
private TargetsColumn _targets;
private int _selectedPresetIndex = -1;
private int _selectedTargetIndex = -1;
private CustomEditorPresenter _targetSettings;
- private readonly Queue _buildingQueue = new Queue();
+ private readonly Queue _buildingQueue = new Queue();
private string _preBuildAction;
private string _postBuildAction;
private BuildPreset[] _data;
@@ -487,16 +493,19 @@ namespace FlaxEditor.Windows
{
if (type == GameCooker.EventType.BuildStarted)
{
+ Debug.Log("Cooking started: " + (GameCooker.CurrentData.Preset ?? "null"));
+ Debug.Log("Cooking started: " + (GameCooker.CurrentData.PresetTarget ?? "null"));
+
// Execute pre-build action
if (!string.IsNullOrEmpty(_preBuildAction))
- ExecueAction(_preBuildAction);
+ ExecuteAction(_preBuildAction);
_preBuildAction = null;
}
else if (type == GameCooker.EventType.BuildDone)
{
// Execute post-build action
if (!string.IsNullOrEmpty(_postBuildAction))
- ExecueAction(_postBuildAction);
+ ExecuteAction(_postBuildAction);
_postBuildAction = null;
}
else if (type == GameCooker.EventType.BuildFailed)
@@ -506,7 +515,7 @@ namespace FlaxEditor.Windows
}
}
- private void ExecueAction(string action)
+ private void ExecuteAction(string action)
{
string command = "echo off\ncd \"" + Globals.ProjectFolder.Replace('/', '\\') + "\"\necho on\n" + action;
command = command.Replace("\n", "\r\n");
@@ -545,21 +554,30 @@ namespace FlaxEditor.Windows
Editor.Log("Building all targets");
foreach (var e in preset.Targets)
{
- _buildingQueue.Enqueue(e.DeepClone());
+ _buildingQueue.Enqueue(new QueueItem
+ {
+ PresetName = preset.Name,
+ Target = e.DeepClone(),
+ });
}
}
///
/// Builds the target.
///
+ /// The preset.
/// The target.
- public void Build(BuildTarget target)
+ public void Build(BuildPreset preset, BuildTarget target)
{
if (target == null)
throw new ArgumentNullException(nameof(target));
Editor.Log("Building target");
- _buildingQueue.Enqueue(target.DeepClone());
+ _buildingQueue.Enqueue(new QueueItem
+ {
+ PresetName = preset.Name,
+ Target = target.DeepClone(),
+ });
}
private void BuildTarget()
@@ -569,7 +587,8 @@ namespace FlaxEditor.Windows
if (_data[_selectedPresetIndex].Targets == null || _data[_selectedPresetIndex].Targets.Length <= _selectedTargetIndex)
return;
- Build(_data[_selectedPresetIndex].Targets[_selectedTargetIndex]);
+ var preset = _data[_selectedPresetIndex];
+ Build(preset, preset.Targets[_selectedTargetIndex]);
}
private void BuildAllTargets()
@@ -825,12 +844,13 @@ namespace FlaxEditor.Windows
{
if (_buildingQueue.Count > 0)
{
- var target = _buildingQueue.Dequeue();
+ var item = _buildingQueue.Dequeue();
+ var target = item.Target;
_preBuildAction = target.PreBuildAction;
_postBuildAction = target.PostBuildAction;
- GameCooker.Build(target.Platform, target.Mode, target.Output, BuildOptions.None, target.CustomDefines);
+ GameCooker.Build(target.Platform, target.Mode, target.Output, BuildOptions.None, target.CustomDefines, item.PresetName, target.Name);
}
else if (_exitOnBuildEnd)
{