From 2ab1df7a407ae9615fba6c2b69204bbf2675c2b9 Mon Sep 17 00:00:00 2001 From: HardCodeDev Date: Sun, 25 Jan 2026 19:03:03 +0400 Subject: [PATCH 1/7] Add UnityHub CLI args to Open command --- src/ucll/AppConfiguration.cs | 2 ++ src/ucll/Commands/Open/OpenCommand.cs | 6 +++++- src/ucll/Commands/Open/OpenSettings.cs | 5 +++++ src/ucll/Shared/UnityHub.cs | 30 ++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/ucll/AppConfiguration.cs b/src/ucll/AppConfiguration.cs index 8576d66..7a01a0d 100644 --- a/src/ucll/AppConfiguration.cs +++ b/src/ucll/AppConfiguration.cs @@ -22,6 +22,8 @@ public static void Build(IConfigurator config) .WithExample("open") .WithExample("open", "--favorite") .WithExample("open", ".") + .WithExample("open", "searchPath", "--no-hub-args", "--", "-batchmode", "-quit") + .WithExample("open", "searchPath", "--no-hub-args") .WithExample("open", "searchPath", "--code-editor") .WithExample("open", "searchPath", "--only-code-editor") .WithExample("open", "searchPath", "--", "-batchmode", "-quit"); diff --git a/src/ucll/Commands/Open/OpenCommand.cs b/src/ucll/Commands/Open/OpenCommand.cs index acc67f6..86ba2d1 100644 --- a/src/ucll/Commands/Open/OpenCommand.cs +++ b/src/ucll/Commands/Open/OpenCommand.cs @@ -6,7 +6,7 @@ protected override int ExecuteImpl(OpenSettings settings) string searchPath = ResolveSearchPath(settings.SearchPath, settings.Favorite); ProjectInfo project = Project.Parse(searchPath); - + string infoLine = string.Empty; if (settings.SearchPath != project.Path) infoLine = "Project: " + project.Path; @@ -22,6 +22,10 @@ protected override int ExecuteImpl(OpenSettings settings) string[] additionalArgs = Context.Remaining.Raw.ToArray(); var args = new List { "-projectPath", project.Path }; + + if (!settings.NoHubArgs) + args.Add(UnityHub.GetProjectArgs(project.Path)); + args.AddRange(additionalArgs); settings.MutatingProcess.Run( diff --git a/src/ucll/Commands/Open/OpenSettings.cs b/src/ucll/Commands/Open/OpenSettings.cs index 1e9051d..cae046c 100644 --- a/src/ucll/Commands/Open/OpenSettings.cs +++ b/src/ucll/Commands/Open/OpenSettings.cs @@ -10,6 +10,10 @@ internal class OpenSettings : MutatingSettings [Description(Descriptions.Favorite)] public bool Favorite { get; init; } + [CommandOption("--no-hub-args")] + [Description("Do not use CLI arguments from Unity Hub")] + public bool NoHubArgs { get; init; } + [CommandOption("-c|--code-editor")] [Description("Open the solution file in the default code editor")] public bool CodeEditor { get; init; } @@ -18,6 +22,7 @@ internal class OpenSettings : MutatingSettings [Description("Open only the code editor without launching Unity")] public bool OnlyCodeEditor { get; init; } + public override ValidationResult Validate() { if (CodeEditor && OnlyCodeEditor) diff --git a/src/ucll/Shared/UnityHub.cs b/src/ucll/Shared/UnityHub.cs index 5441a19..a393c86 100644 --- a/src/ucll/Shared/UnityHub.cs +++ b/src/ucll/Shared/UnityHub.cs @@ -34,6 +34,9 @@ public string GetEditorPath(string version) if (appBundlePath == null) throw new UserException($"Unity version {version} is not installed."); + if (appBundlePath.EndsWith("Unity.exe", StringComparison.OrdinalIgnoreCase)) + return appBundlePath; + return Path.Combine(appBundlePath, platformSupport.RelativeEditorPathToExecutable); } @@ -75,6 +78,33 @@ public IEnumerable GetRecentProjects(bool favoriteOnly = false) } } + public string GetProjectArgs(string projectPath) + { + string configDir = platformSupport.UnityHubConfigDirectory; + string argsFile = Path.Combine(configDir, "projectsInfo.json"); + + try + { + string json = File.ReadAllText(argsFile); + var root = JsonNode.Parse(json); + var project = root?[projectPath]?.AsObject()!; + + // If you remove args from project in Unity Hub, this field still will exist but now with empty value, + // so we can't guarantee that it has value and we need to check + string? cliArgs = project["cliArgs"]?.GetValue(); + + if (!string.IsNullOrEmpty(cliArgs)) + return cliArgs; + + return string.Empty; + } + catch + { + return string.Empty; + } + + } + public void InstallEditorChecked( string version, string? changeset, From 537cc071ec03a62b8691a5bd45018779da87bf89 Mon Sep 17 00:00:00 2001 From: HardCodeDev Date: Mon, 26 Jan 2026 10:18:15 +0400 Subject: [PATCH 2/7] Remove Open command Windows fix --- src/ucll/Shared/UnityHub.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ucll/Shared/UnityHub.cs b/src/ucll/Shared/UnityHub.cs index a393c86..9c37564 100644 --- a/src/ucll/Shared/UnityHub.cs +++ b/src/ucll/Shared/UnityHub.cs @@ -34,9 +34,6 @@ public string GetEditorPath(string version) if (appBundlePath == null) throw new UserException($"Unity version {version} is not installed."); - if (appBundlePath.EndsWith("Unity.exe", StringComparison.OrdinalIgnoreCase)) - return appBundlePath; - return Path.Combine(appBundlePath, platformSupport.RelativeEditorPathToExecutable); } @@ -217,4 +214,4 @@ private static void WriteStatusUpdate(string message) // However, we do want the progress feedback that the Hub provides. AnsiConsole.MarkupLine($"[cyan]{message}...[/]"); } -} \ No newline at end of file +} From ac16d7ea93961f8a09b8542f194c874a9f8ef841 Mon Sep 17 00:00:00 2001 From: HardCodeDev Date: Tue, 27 Jan 2026 17:36:03 +0400 Subject: [PATCH 3/7] Fix formatting Co-authored-by: Chris Yarbrough <17833862+chrisyarbrough@users.noreply.github.com> --- src/ucll/Commands/Open/OpenCommand.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ucll/Commands/Open/OpenCommand.cs b/src/ucll/Commands/Open/OpenCommand.cs index 86ba2d1..ed9d338 100644 --- a/src/ucll/Commands/Open/OpenCommand.cs +++ b/src/ucll/Commands/Open/OpenCommand.cs @@ -6,7 +6,6 @@ protected override int ExecuteImpl(OpenSettings settings) string searchPath = ResolveSearchPath(settings.SearchPath, settings.Favorite); ProjectInfo project = Project.Parse(searchPath); - string infoLine = string.Empty; if (settings.SearchPath != project.Path) infoLine = "Project: " + project.Path; From 287192806514f15370bee8b560ca727534ef876a Mon Sep 17 00:00:00 2001 From: HardCodeDev Date: Tue, 27 Jan 2026 17:36:13 +0400 Subject: [PATCH 4/7] Fix formatting Co-authored-by: Chris Yarbrough <17833862+chrisyarbrough@users.noreply.github.com> --- src/ucll/Commands/Open/OpenSettings.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ucll/Commands/Open/OpenSettings.cs b/src/ucll/Commands/Open/OpenSettings.cs index cae046c..0010b5e 100644 --- a/src/ucll/Commands/Open/OpenSettings.cs +++ b/src/ucll/Commands/Open/OpenSettings.cs @@ -22,7 +22,6 @@ internal class OpenSettings : MutatingSettings [Description("Open only the code editor without launching Unity")] public bool OnlyCodeEditor { get; init; } - public override ValidationResult Validate() { if (CodeEditor && OnlyCodeEditor) From f480e258b2c0e24a5ad00a7c7bce7c137d50743f Mon Sep 17 00:00:00 2001 From: HardCodeDev Date: Tue, 27 Jan 2026 17:36:26 +0400 Subject: [PATCH 5/7] Fix formatting Co-authored-by: Chris Yarbrough <17833862+chrisyarbrough@users.noreply.github.com> --- src/ucll/Shared/UnityHub.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ucll/Shared/UnityHub.cs b/src/ucll/Shared/UnityHub.cs index 9c37564..2baaef2 100644 --- a/src/ucll/Shared/UnityHub.cs +++ b/src/ucll/Shared/UnityHub.cs @@ -99,7 +99,6 @@ public string GetProjectArgs(string projectPath) { return string.Empty; } - } public void InstallEditorChecked( From 178f97661e7868b81f41c63db1f49542fda44009 Mon Sep 17 00:00:00 2001 From: HardCodeDev Date: Tue, 27 Jan 2026 17:36:38 +0400 Subject: [PATCH 6/7] Fix formatting Co-authored-by: Chris Yarbrough <17833862+chrisyarbrough@users.noreply.github.com> --- src/ucll/Shared/UnityHub.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ucll/Shared/UnityHub.cs b/src/ucll/Shared/UnityHub.cs index 2baaef2..fe0db51 100644 --- a/src/ucll/Shared/UnityHub.cs +++ b/src/ucll/Shared/UnityHub.cs @@ -86,8 +86,8 @@ public string GetProjectArgs(string projectPath) var root = JsonNode.Parse(json); var project = root?[projectPath]?.AsObject()!; - // If you remove args from project in Unity Hub, this field still will exist but now with empty value, - // so we can't guarantee that it has value and we need to check + // The cliArgs field persists even when arguments are removed from a project in Unity Hub, + // but will contain an empty value. Validation is required before use. string? cliArgs = project["cliArgs"]?.GetValue(); if (!string.IsNullOrEmpty(cliArgs)) From a04e435ed07a4ff224419a7f6278b3d17e676db3 Mon Sep 17 00:00:00 2001 From: HardCodeDev Date: Tue, 27 Jan 2026 17:37:44 +0400 Subject: [PATCH 7/7] Fix formatting