@@ -85,7 +85,7 @@ public NewProject(string unityVersion, string suggestedName, string targetFolder
8585 gridAvailableVersions . SelectedIndex = i ;
8686 gridAvailableVersions . ScrollIntoView ( gridAvailableVersions . SelectedItem ) ;
8787
88- string baseVersion = GetBaseVersion ( newVersion ) ;
88+ string baseVersion = Tools . GetBaseVersion ( newVersion ) ;
8989 if ( fetchOnlineTemplates ) _ = LoadOnlineTemplatesAsync ( baseVersion ) ;
9090 break ;
9191 }
@@ -127,6 +127,12 @@ public NewProject(string unityVersion, string suggestedName, string targetFolder
127127 private void LoadSettings ( )
128128 {
129129 chkForceDX11 . IsChecked = Settings . Default . forceDX11 ;
130+ chkEnableLfs . IsChecked = Settings . Default . gitIEnableLFS ;
131+ chkInitialCommit . IsChecked = Settings . Default . gitInitialCommit ;
132+ chkAddReadme . IsChecked = Settings . Default . gitAddReadme ;
133+ //chkAddUnityGitIgnore.IsChecked = Settings.Default.gitAddUnityGitIgnore; // not used yet
134+ chkEnableVersionControl . IsChecked = Settings . Default . gitEnableVersionControl ;
135+ expVersionControl . IsExpanded = Settings . Default . gitPanelExpanded || Settings . Default . gitEnableVersionControl ;
130136 }
131137
132138 void UpdateTemplatesDropDown ( string unityPath )
@@ -388,25 +394,14 @@ private void GridAvailableVersions_SelectionChanged(object sender, SelectionChan
388394 listOnlineTemplates . ItemsSource = null ; // clear previous items
389395 if ( loadOnlineTemplates )
390396 {
391- string baseVersion = GetBaseVersion ( k . Version ) ;
397+ string baseVersion = Tools . GetBaseVersion ( k . Version ) ;
392398 // Cancel previous request
393399 _templateLoadCancellation ? . Cancel ( ) ;
394400 _templateLoadCancellation = new CancellationTokenSource ( ) ;
395401 _ = LoadOnlineTemplatesAsync ( baseVersion , _templateLoadCancellation . Token ) ;
396402 }
397403 }
398404
399- string GetBaseVersion ( string version )
400- {
401- // e.g. 2020.3.15f1 -> 2020.3
402- var parts = version . Split ( '.' ) ;
403- if ( parts . Length >= 2 )
404- {
405- return parts [ 0 ] + "." + parts [ 1 ] ;
406- }
407- return version ;
408- }
409-
410405 private void GridAvailableVersions_Loaded ( object sender , RoutedEventArgs e )
411406 {
412407 // set initial default row color
@@ -463,6 +458,9 @@ private void chkEnableVersionControl_Checked(object sender, RoutedEventArgs e)
463458 chkInitialCommit . IsEnabled = state ;
464459 //chkAddUnityGitIgnore.IsEnabled = state; // not used yet
465460 chkAddReadme . IsEnabled = state ;
461+
462+ Settings . Default . gitEnableVersionControl = state ;
463+ Settings . Default . Save ( ) ;
466464 }
467465
468466 private void btnBrowseForProjectFolder_Click ( object sender , RoutedEventArgs e )
@@ -531,7 +529,6 @@ private void btnCreateMissingFolder_Click(object sender, RoutedEventArgs e)
531529 }
532530 }
533531
534- // Add this static field to the class (near other static fields)
535532 private static readonly HttpClient _httpClient = new HttpClient ( ) ;
536533
537534 private async Task LoadOnlineTemplatesAsync ( string baseVersion , CancellationToken cancellationToken = default )
@@ -782,8 +779,6 @@ private int FindMatchingBrace(string json, int openBraceIndex)
782779 return - 1 ;
783780 } // FindMatchingBrace
784781
785-
786-
787782 private void listOnlineTemplates_PreviewMouseDown ( object sender , MouseButtonEventArgs e )
788783 {
789784 // Get the item that was clicked
@@ -811,7 +806,6 @@ private void listOnlineTemplates_PreviewMouseDown(object sender, MouseButtonEven
811806 }
812807 }
813808
814-
815809 private void listOnlineTemplates_SelectionChanged ( object sender , SelectionChangedEventArgs e )
816810 {
817811 if ( listOnlineTemplates . SelectedItem is OnlineTemplateItem selectedTemplate )
@@ -932,7 +926,7 @@ private void btnFetchTemplates_Click(object sender, RoutedEventArgs e)
932926 {
933927 if ( gridAvailableVersions . SelectedItem is UnityInstallation selectedInstallation )
934928 {
935- string baseVersion = GetBaseVersion ( selectedInstallation . Version ) ;
929+ string baseVersion = Tools . GetBaseVersion ( selectedInstallation . Version ) ;
936930 _templateLoadCancellation ? . Cancel ( ) ;
937931 _templateLoadCancellation = new CancellationTokenSource ( ) ;
938932 _ = LoadOnlineTemplatesAsync ( baseVersion , _templateLoadCancellation . Token ) ;
@@ -957,27 +951,38 @@ private void btnAuthorizeToken_Click(object sender, RoutedEventArgs e)
957951
958952 private void chkEnableLfs_Checked ( object sender , RoutedEventArgs e )
959953 {
954+ if ( isInitializing ) return ;
960955
956+ Settings . Default . gitIEnableLFS = chkEnableLfs . IsChecked == true ;
957+ Settings . Default . Save ( ) ;
961958 }
962959
963960 private void chkInitialCommit_Checked ( object sender , RoutedEventArgs e )
964961 {
962+ if ( isInitializing ) return ;
965963
964+ Settings . Default . gitInitialCommit = chkInitialCommit . IsChecked == true ;
965+ Settings . Default . Save ( ) ;
966966 }
967967
968968 private void chkAddReadme_Checked ( object sender , RoutedEventArgs e )
969969 {
970+ if ( isInitializing ) return ;
970971
972+ Settings . Default . gitAddReadme = chkAddReadme . IsChecked == true ;
973+ Settings . Default . Save ( ) ;
971974 }
972975
973976 private void txtRepoName_TextChanged ( object sender , TextChangedEventArgs e )
974977 {
975- // TODO validate repo name with github requirements and show error if invalid AND check if already used
976978 }
977979
978980 private void expVersionControl_Collapsed ( object sender , RoutedEventArgs e )
979981 {
980- // TODO save state of expander to settings AND if version control is enabled, always show expander and disable collapsing
982+ if ( isInitializing ) return ;
983+
984+ Settings . Default . gitPanelExpanded = expVersionControl . IsExpanded ;
985+ Settings . Default . Save ( ) ;
981986 }
982987
983988
0 commit comments