Skip to content

Commit e3add93

Browse files
updated to dotnet 10.0 && version v0.9 && added option to close app after opening in terminal
1 parent 2e5dce2 commit e3add93

File tree

5 files changed

+51
-14
lines changed

5 files changed

+51
-14
lines changed

UnityHubNative.Net/MainWindow.cs

+44-10
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ public static void OpenSelectedProjectWith()
121121
public static void OpenSelectedProjectInTerminal()
122122
{
123123
if (TryGetSelectedProject(out var unityProject))
124+
{
124125
OsUtils.OpenInTerminal(unityProject.path);
126+
if (UnityHubNativeNetApp.Config.closeAfterOpenInTerminal)
127+
Instance.Close();
128+
}
125129
}
126130

127131
public static void OnRemoveProjectFromListClicked()
@@ -396,7 +400,8 @@ public static void MoveSelectedProjectDown()
396400
Header = "Options",
397401
Content = new DockPanel
398402
{
399-
LastChildFill = false
403+
LastChildFill = false,
404+
Margin = new(10),
400405
}.AddChildren
401406
([
402407
new SettingsExpander
@@ -544,19 +549,42 @@ public static void MoveSelectedProjectDown()
544549
{
545550
Content = new DockPanel
546551
{
552+
LastChildFill = false
547553
}.AddChildren
548554
([
549-
new TextBlock
555+
new DockPanel
550556
{
551-
Text = "Format to open project in Terminal",
552-
VerticalAlignment = VerticalAlignment.Center,
553-
Margin = new(0, 0, 10, 0),
554-
}.SetDock(Dock.Left),
555-
s_openInTerminalFormatText = new TextBox
557+
}.AddChildren
558+
([
559+
new TextBlock
560+
{
561+
Text = "Format to open project in Terminal",
562+
VerticalAlignment = VerticalAlignment.Center,
563+
Margin = new(0, 0, 10, 0),
564+
}.SetDock(Dock.Left),
565+
s_openInTerminalFormatText = new TextBox
566+
{
567+
Text = UnityHubNativeNetApp.Config.openInTerminalFormat,
568+
VerticalAlignment = VerticalAlignment.Center,
569+
}.OnTextChanged(OnOpenInTerminalFormatChanged).SetDock(Dock.Right)
570+
]).SetDock(Dock.Top),
571+
new DockPanel
556572
{
557-
Text = UnityHubNativeNetApp.Config.openInTerminalFormat,
558-
VerticalAlignment = VerticalAlignment.Center,
559-
}.OnTextChanged(OnOpenInTerminalFormatChanged).SetDock(Dock.Right)
573+
LastChildFill = false
574+
}.AddChildren
575+
([
576+
new TextBlock
577+
{
578+
Text = "Close after open in terminal",
579+
VerticalAlignment = VerticalAlignment.Center,
580+
Margin = new(0, 0, 10, 0),
581+
}.SetDock(Dock.Left),
582+
new CheckBox
583+
{
584+
IsChecked = UnityHubNativeNetApp.Config.closeAfterOpenInTerminal,
585+
VerticalAlignment = VerticalAlignment.Center,
586+
}.OnCheckChanged(OnCloseAfterOpenInTerminalChanged).SetDock(Dock.Right)
587+
]).SetDock(Dock.Top).SetTooltip("Whether or not to close the app after opening project in terminal"),
560588
])
561589
}.SetTooltip("Defines the process format of when opening a project in terminal. {path} will be replaced by the project path"),
562590
])
@@ -566,6 +594,12 @@ public static void MoveSelectedProjectDown()
566594
])
567595
]);
568596

597+
static void OnCloseAfterOpenInTerminalChanged()
598+
{
599+
UnityHubNativeNetApp.Config.closeAfterOpenInTerminal = !UnityHubNativeNetApp.Config.closeAfterOpenInTerminal;
600+
UnityHubNativeNetApp.SaveConfig(UnityHubNativeNetApp.Config);
601+
}
602+
569603
static void OnOpenInTerminalFormatChanged()
570604
{
571605
UnityHubNativeNetApp.Config.openInTerminalFormat = s_openInTerminalFormatText.Text;

UnityHubNative.Net/Manifest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ namespace UnityHubNative.Net;
22

33
static class Manifest
44
{
5-
public const string Version = "v0.8";
5+
public const string Version = "v0.9";
66
}

UnityHubNative.Net/UnityHubNative.Net.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Library</OutputType>
5-
<TargetFramework>net9.0</TargetFramework>
5+
<TargetFramework>net10.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<PublishAot>true</PublishAot>
88
<AssemblyName>UnityNativeHub.Net</AssemblyName>

UnityHubNative.Net/UnityHubNativeNetApp.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public static AppConfig LoadConfig()
5555
closeAfterProjectOpen = txt.Length >= 4 && txt[3] == "true",
5656
extendToTitlebar = txt.Length >= 5 && txt[4] == "true",
5757
openInTerminalFormat = txt.Length >= 6 ? txt[5] : "cmd.exe /K cd /d \"{path}\"",
58+
closeAfterOpenInTerminal = txt.Length >= 7 && txt[6] == "true",
5859
};
5960
}
6061
catch (Exception ex)
@@ -73,7 +74,8 @@ public static void SaveConfig(AppConfig config)
7374
config.blurIntensity.ToString(),
7475
config.closeAfterProjectOpen ? "true" : "false",
7576
config.extendToTitlebar ? "true" : "false",
76-
config.openInTerminalFormat
77+
config.openInTerminalFormat,
78+
config.closeAfterOpenInTerminal ? "true" : "false",
7779
]);
7880
}
7981

@@ -85,5 +87,6 @@ public struct AppConfig
8587
public bool extendToTitlebar;
8688
public bool closeAfterProjectOpen;
8789
public string openInTerminalFormat;
90+
public bool closeAfterOpenInTerminal;
8891
}
8992
}

Windows/UnityHubNative.Net.Windows.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>WinExe</OutputType>
5-
<TargetFramework>net9.0-windows</TargetFramework>
5+
<TargetFramework>net10.0-windows7.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<PublishAot>true</PublishAot>
88
<PublishTrimmed>True</PublishTrimmed>

0 commit comments

Comments
 (0)