diff --git a/CHANGELOG.md b/CHANGELOG.md
index c9a08ad..df8f8ea 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,10 @@ All package updates & migration steps will be listed in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [4.6.1] - 2025-12-24
+### Changed
+- MenuItem code is code generated in one file to reduce git diffs when an info is added/removed.
+
## [4.6.0] - 2025-07-24
### Added
- Support to add pre-build events to the `ParameterBuildProcessor`
diff --git a/Editor/CodeGeneration/Operations/GenerateImplementationFilesOperation.cs b/Editor/CodeGeneration/Operations/GenerateImplementationFilesOperation.cs
index 01e504d..ffab6a2 100644
--- a/Editor/CodeGeneration/Operations/GenerateImplementationFilesOperation.cs
+++ b/Editor/CodeGeneration/Operations/GenerateImplementationFilesOperation.cs
@@ -1,4 +1,3 @@
-using System.Linq;
using PocketGems.Parameters.CodeGeneration.Operation.Editor;
using PocketGems.Parameters.CodeGeneration.Util.Editor;
using PocketGems.Parameters.Common.Operations.Editor;
@@ -23,18 +22,18 @@ public override void Execute(ICodeOperationContext context)
var fbFileRemover = new UnusedFileRemover(flatBufferClassesDir);
// generate files
- var orderedInfos = context.ParameterInfos.OrderBy(t => t.BaseName);
- int index = 0;
- foreach (var parameterInfo in orderedInfos)
+ foreach (var parameterInfo in context.ParameterInfos)
{
- var soFilename = CodeGenerator.GenerateScriptableObjectFile(parameterInfo, index, scriptableObjectDir);
+ var soFilename = CodeGenerator.GenerateScriptableObjectFile(parameterInfo, scriptableObjectDir);
soFileRemover.UsedFile(soFilename);
var fbClassFile = CodeGenerator.GenerateFlatBufferClassFile(parameterInfo, true, flatBufferClassesDir);
fbFileRemover.UsedFile(fbClassFile);
- index++;
}
+ var menuItemFilename = CodeGenerator.GenerateScriptableObjectMenuItems(context.ParameterInfos, scriptableObjectDir);
+ soFileRemover.UsedFile(menuItemFilename);
+
var parameterStructs = context.ParameterStructs;
for (int i = 0; i < parameterStructs.Count; i++)
{
diff --git a/Editor/CodeGeneration/Util/CodeGenerator.cs b/Editor/CodeGeneration/Util/CodeGenerator.cs
index 23d49a9..6634863 100644
--- a/Editor/CodeGeneration/Util/CodeGenerator.cs
+++ b/Editor/CodeGeneration/Util/CodeGenerator.cs
@@ -119,14 +119,53 @@ private static bool AttemptGenerateValidationFile(IParameterInterface parameterI
return true;
}
+ ///
+ /// Generate the Scriptable Object class file that implements the interface.
+ ///
+ /// All of the parameter infos.
+ /// Directory to write the class to.
+ /// filepath of the file written
+ public static string GenerateScriptableObjectMenuItems(IReadOnlyList parameterInfos, string outputDirectory)
+ {
+ if (!Directory.Exists(outputDirectory))
+ Directory.CreateDirectory(outputDirectory);
+
+ var orderedInfos = parameterInfos.OrderBy(t => t.BaseName);
+
+ var infoInterfaces = new List