Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita8a49f7

Browse files
committed
add disable unity hub from launching on Editor start#95
1 parentfd47430 commita8a49f7

File tree

4 files changed

+146
-10
lines changed

4 files changed

+146
-10
lines changed

‎UnityLauncherPro/MainWindow.xaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,7 @@
811811
<CheckBoxx:Name="chkAllowSingleInstanceOnly"Content="Allow single instance only"Checked="ChkAllowSingleInstanceOnly_CheckedChanged"Unchecked="ChkAllowSingleInstanceOnly_CheckedChanged"ToolTip="Activates already running instance, instead of starting new exe (not working if app is minized to taskbar)"HorizontalAlignment="Left"/>
812812
<CheckBoxx:Name="useAlphaReleaseNotesSite"Content="Use Unity Alpha Release Notes Site (only for final versions)"ToolTip="Use the superior (but alpha) Unity Release Notes (https://alpha.release-notes.ds.unity3d.com/) site when clicking on the ReleaseNotes button. Otherwise will default to the normal build page."Checked="UseAlphaReleaseNotes_Checked"Unchecked="UseAlphaReleaseNotes_Checked"/>
813813
<CheckBoxx:Name="useUnofficialReleaseList"Content="Use Unofficial Release Watch List (for latest downloads)"ToolTip="Checks latest releases from https://github.com/unitycoder/UnofficialUnityReleasesWatcher (if not yet available in The Unity Releases API)"Checked="useUnofficialReleaseList_Checked"Unchecked="useUnofficialReleaseList_Checked"/>
814+
<CheckBoxx:Name="chkDisableUnityHubLaunch"Content="Disable UnityHub launch at Editor start"ToolTip="Overrides UnityHub IPC port. Note: You will be logged out in Editor!"Checked="chkDisableUnityHubLaunch_Checked"Unchecked="chkDisableUnityHubLaunch_Checked"/>
814815
<CheckBoxx:Name="chkStreamerMode"Content="Streamer Mode (hide project names and folders)"ToolTip="Hide project names and folders in main view"Checked="ChkStreamerMode_Checked"Unchecked="ChkStreamerMode_Checked"HorizontalAlignment="Left"/>
815816
<!--<StackPanel Orientation="Horizontal" Margin="0,0,0,4">
816817
<TextBox x:Name="txtTemplatePackagesFolder" BorderBrush="Transparent" CaretBrush="{DynamicResource ThemeSearchCaret}" Background="{DynamicResource ThemeTextBoxBackground}" SelectionBrush="{DynamicResource ThemeSearchSelection}" Foreground="{DynamicResource ThemeSearchForeground}" ToolTip="Folder for your custom unitypackage templates (for new project)" Padding="0,3,0,0" Width="110" TextChanged="TxtTemplatePackagesFolder_TextChanged" />

‎UnityLauncherPro/MainWindow.xaml.cs‎

Lines changed: 130 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public partial class MainWindow : Window
5555
string_filterString=null;
5656
boolmultiWordSearch=false;
5757
string[]searchWords;
58+
boolisDirtyCell=false;
5859

5960
intlastSelectedProjectIndex=0;
6061
MutexmyMutex;
@@ -73,8 +74,9 @@ public partial class MainWindow : Window
7374
List<BuildReport>buildReports=newList<BuildReport>();// multiple reports, each contains their own stats and items
7475
intcurrentBuildReport=0;
7576

76-
privateNamedPipeServerStreampipeServer;
77-
privateconststringPipeName=appName;
77+
privateNamedPipeServerStreamlauncherPipeServer;
78+
privateconststringlauncherPipeName=appName;
79+
readonlystringunityHubPipeName="Unity-hubIPCService";
7880

7981
[DllImport("user32",CharSet=CharSet.Unicode)]
8082
staticexternIntPtrFindWindow(stringcls,stringwin);
@@ -190,9 +192,61 @@ void Start()
190192
//themeEditorWindow = new ThemeEditor();
191193
//themeEditorWindow.Show();
192194

195+
// test override IPC so that unityhub doesnt start
196+
// open "Unity-hubIPCService" pipe, if not already open
197+
198+
if(Settings.Default.disableUnityHubLaunch==true)StartHubPipe();
199+
193200
isInitializing=false;
194201
}
195202

203+
privatestaticNamedPipeServerStreamhubPipeServer;
204+
privateCancellationTokenSource_hubCancellationTokenSource;
205+
206+
privateasyncTaskStartPipeServerAsync(stringpipeName,Action<string>onMessageReceived,CancellationTokencancellationToken)
207+
{
208+
try
209+
{
210+
while(!cancellationToken.IsCancellationRequested)
211+
{
212+
using(varpipeServer=newNamedPipeServerStream(pipeName,PipeDirection.InOut,NamedPipeServerStream.MaxAllowedServerInstances,PipeTransmissionMode.Byte,PipeOptions.Asynchronous))
213+
{
214+
awaitpipeServer.WaitForConnectionAsync(cancellationToken);
215+
Console.WriteLine($"Client connected to pipe '{pipeName}'!");
216+
217+
using(varreader=newStreamReader(pipeServer))
218+
{
219+
while(!cancellationToken.IsCancellationRequested)
220+
{
221+
stringmessage=awaitreader.ReadLineAsync();
222+
if(message==null)break;// End of stream
223+
onMessageReceived(message);
224+
}
225+
}
226+
}
227+
}
228+
}
229+
catch(OperationCanceledException)
230+
{
231+
// Expected when the cancellation token is triggered
232+
Console.WriteLine("Pipe server operation canceled.");
233+
}
234+
catch(Exceptionex)
235+
{
236+
Console.WriteLine($"Error in pipe server:{ex.Message}");
237+
}
238+
finally
239+
{
240+
Console.WriteLine("Named pipe server stopped.");
241+
}
242+
}
243+
244+
245+
privatevoidOnHubMessageReceived(stringmessage)
246+
{
247+
//Console.WriteLine(message);
248+
}
249+
196250
privatevoidDataGridUpdates_SelectionChanged(objectsender,SelectionChangedEventArgse)
197251
{
198252
varselectedUp=GetSelectedUpdate();
@@ -460,6 +514,7 @@ void LoadSettings()
460514
txtCustomThemeFile.Text=Settings.Default.themeFile;
461515
useAlphaReleaseNotesSite.IsChecked=Settings.Default.useAlphaReleaseNotes;
462516
useUnofficialReleaseList.IsChecked=Settings.Default.useUnofficialReleaseList;
517+
chkDisableUnityHubLaunch.IsChecked=Settings.Default.disableUnityHubLaunch;
463518

464519
chkEnablePlatformSelection.IsChecked=Settings.Default.enablePlatformSelection;
465520
chkRunAutomatically.IsChecked=Settings.Default.runAutomatically;
@@ -1137,11 +1192,11 @@ private void Window_Closing(object sender, CancelEventArgs e)
11371192
{
11381193
// (TODO force) close theme editor, if still open, TODO NEED to cancel all changes
11391194
CloseThemeEditor();
1140-
11411195
SaveSettingsOnExit();
1196+
CloseHubPipeAsync();
11421197
}
11431198

1144-
privatevoidCloseThemeEditor()
1199+
privatevoidCloseThemeEditor()
11451200
{
11461201
if(themeEditorWindow!=null)themeEditorWindow.Close();
11471202
}
@@ -2150,7 +2205,6 @@ public void CanExecute_Copy(object sender, CanExecuteRoutedEventArgs e)
21502205
e.CanExecute=true;
21512206
}
21522207

2153-
boolisDirtyCell=false;
21542208
privatevoidGridRecent_BeginningEdit(objectsender,DataGridBeginningEditEventArgse)
21552209
{
21562210
isDirtyCell=true;
@@ -3730,7 +3784,7 @@ private void ActivateRunningInstance()
37303784
{
37313785
try
37323786
{
3733-
using(varpipeClient=newNamedPipeClientStream(".",PipeName,PipeDirection.Out))
3787+
using(varpipeClient=newNamedPipeClientStream(".",launcherPipeName,PipeDirection.Out))
37343788
{
37353789
pipeClient.Connect(1000);// Wait for 1 second to connect
37363790
using(varwriter=newStreamWriter(pipeClient))
@@ -3749,18 +3803,18 @@ private void ActivateRunningInstance()
37493803

37503804
privatevoidStartPipeServer()
37513805
{
3752-
pipeServer=newNamedPipeServerStream(PipeName,PipeDirection.In,1,PipeTransmissionMode.Message,PipeOptions.Asynchronous);
3753-
pipeServer.BeginWaitForConnection(OnPipeConnection,null);
3806+
launcherPipeServer=newNamedPipeServerStream(launcherPipeName,PipeDirection.In,1,PipeTransmissionMode.Message,PipeOptions.Asynchronous);
3807+
launcherPipeServer.BeginWaitForConnection(OnPipeConnection,null);
37543808
}
37553809

37563810
privatevoidOnPipeConnection(IAsyncResultresult)
37573811
{
37583812
try
37593813
{
3760-
pipeServer.EndWaitForConnection(result);
3814+
launcherPipeServer.EndWaitForConnection(result);
37613815

37623816
// Read the message
3763-
using(varreader=newStreamReader(pipeServer))
3817+
using(varreader=newStreamReader(launcherPipeServer))
37643818
{
37653819
stringmessage=reader.ReadLine();
37663820
if(message=="WakeUp")
@@ -3841,6 +3895,72 @@ private void useUnofficialReleaseList_Checked(object sender, RoutedEventArgs e)
38413895
Settings.Default.useUnofficialReleaseList=(bool)useUnofficialReleaseList.IsChecked;
38423896
Settings.Default.Save();
38433897
}
3898+
3899+
privateasyncvoidchkDisableUnityHubLaunch_Checked(objectsender,RoutedEventArgse)
3900+
{
3901+
if(!this.IsActive)return;// Don't run code during window initialization
3902+
3903+
Console.WriteLine((bool)chkDisableUnityHubLaunch.IsChecked);
3904+
3905+
if((bool)chkDisableUnityHubLaunch.IsChecked)
3906+
{
3907+
awaitCloseHubPipeAsync();// Ensure old task is closed before starting a new one
3908+
StartHubPipe();
3909+
}
3910+
else
3911+
{
3912+
awaitCloseHubPipeAsync();
3913+
}
3914+
3915+
Settings.Default.disableUnityHubLaunch=(bool)chkDisableUnityHubLaunch.IsChecked;
3916+
Settings.Default.Save();
3917+
}
3918+
3919+
privatevoidStartHubPipe()
3920+
{
3921+
if(_hubCancellationTokenSource!=null&&!_hubCancellationTokenSource.IsCancellationRequested)
3922+
{
3923+
Console.WriteLine("Pipe server already running.");
3924+
return;// Avoid starting multiple instances
3925+
}
3926+
3927+
_hubCancellationTokenSource=newCancellationTokenSource();
3928+
Task.Run(()=>StartPipeServerAsync("Unity-hubIPCService",OnHubMessageReceived,_hubCancellationTokenSource.Token));
3929+
Console.WriteLine("StartHubPipe");
3930+
}
3931+
3932+
privateasyncTaskCloseHubPipeAsync()
3933+
{
3934+
if(_hubCancellationTokenSource==null||_hubCancellationTokenSource.IsCancellationRequested)
3935+
{
3936+
Console.WriteLine("Pipe server already stopped.");
3937+
return;
3938+
}
3939+
3940+
Console.WriteLine("CloseHubPipe..");
3941+
3942+
// Cancel the token to stop the server task
3943+
_hubCancellationTokenSource.Cancel();
3944+
3945+
try
3946+
{
3947+
// Allow the server to shut down gracefully
3948+
awaitTask.Delay(100);// Optional: Give some time for clean-up
3949+
}
3950+
catch(Exceptionex)
3951+
{
3952+
Console.WriteLine($"Error during pipe server shutdown:{ex.Message}");
3953+
}
3954+
finally
3955+
{
3956+
_hubCancellationTokenSource.Dispose();
3957+
_hubCancellationTokenSource=null;
3958+
Console.WriteLine("Pipe server stopped.");
3959+
}
3960+
}
3961+
3962+
3963+
38443964
//private void menuProjectProperties_Click(object sender, RoutedEventArgs e)
38453965
//{
38463966
// var proj = GetSelectedProject();

‎UnityLauncherPro/Properties/Settings.Designer.cs‎

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎UnityLauncherPro/Properties/Settings.settings‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,8 @@
151151
<SettingName="useUnofficialReleaseList"Type="System.Boolean"Scope="User">
152152
<ValueProfile="(Default)">False</Value>
153153
</Setting>
154+
<SettingName="disableUnityHubLaunch"Type="System.Boolean"Scope="User">
155+
<ValueProfile="(Default)">False</Value>
156+
</Setting>
154157
</Settings>
155158
</SettingsFile>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp