@@ -152,7 +152,43 @@ private void BtnCreateNewProject_Click(object sender, RoutedEventArgs e)
152152 return ;
153153 }
154154
155- templateZipPath = ( ( KeyValuePair < string , string > ) cmbNewProjectTemplate . SelectedValue ) . Value ;
155+ // Check if online template is selected
156+ if ( listOnlineTemplates . SelectedItem is OnlineTemplateItem selectedOnlineTemplate )
157+ {
158+ // Use online template path
159+ string appDataPath = Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) ;
160+ string templatesPath = Path . Combine ( appDataPath , "UnityHub" , "Templates" ) ;
161+
162+ if ( ! string . IsNullOrEmpty ( selectedOnlineTemplate . TarBallURL ) )
163+ {
164+ string fileName = Path . GetFileName ( new Uri ( selectedOnlineTemplate . TarBallURL ) . LocalPath ) ;
165+ if ( string . IsNullOrEmpty ( fileName ) )
166+ {
167+ string safeFileName = string . Join ( "_" , selectedOnlineTemplate . Name . Split ( Path . GetInvalidFileNameChars ( ) ) ) ;
168+ fileName = $ "{ safeFileName } .tgz";
169+ }
170+
171+ templateZipPath = Path . Combine ( templatesPath , fileName ) ;
172+
173+ // Verify the file exists
174+ if ( ! File . Exists ( templateZipPath ) )
175+ {
176+ Tools . SetStatus ( "Selected online template is not downloaded. Please download it first." ) ;
177+ return ;
178+ }
179+ }
180+ else
181+ {
182+ Tools . SetStatus ( "Invalid online template URL" ) ;
183+ return ;
184+ }
185+ }
186+ else
187+ {
188+ // Use built-in template from dropdown
189+ templateZipPath = ( ( KeyValuePair < string , string > ) cmbNewProjectTemplate . SelectedValue ) . Value ;
190+ }
191+
156192 selectedPlatform = cmbNewProjectPlatform . SelectedValue . ToString ( ) ;
157193 UpdateSelectedVersion ( ) ;
158194
@@ -163,6 +199,7 @@ private void BtnCreateNewProject_Click(object sender, RoutedEventArgs e)
163199 DialogResult = true ;
164200 }
165201
202+
166203 private void BtnCancelNewProject_Click ( object sender , RoutedEventArgs e )
167204 {
168205 DialogResult = false ;
@@ -666,6 +703,7 @@ private int FindMatchingBrace(string json, int openBraceIndex)
666703 } // FindMatchingBrace
667704
668705
706+
669707 private void listOnlineTemplates_PreviewMouseDown ( object sender , MouseButtonEventArgs e )
670708 {
671709 // Get the item that was clicked
@@ -693,20 +731,27 @@ private void listOnlineTemplates_PreviewMouseDown(object sender, MouseButtonEven
693731 }
694732 }
695733
734+
696735 private void listOnlineTemplates_SelectionChanged ( object sender , SelectionChangedEventArgs e )
697736 {
698737 if ( listOnlineTemplates . SelectedItem is OnlineTemplateItem selectedTemplate )
699738 {
700739 lblSelectedTemplate . Content = selectedTemplate . Name ;
701740 lblSelectedTemplate . BorderThickness = new Thickness ( 1 ) ;
741+
742+ // Disable built-in template dropdown when online template is selected
743+ cmbNewProjectTemplate . IsEnabled = false ;
744+ cmbNewProjectTemplate . SelectedIndex = 0 ; // Reset to default
702745 }
703746 else
704747 {
705748 lblSelectedTemplate . Content = "None" ;
706749 lblSelectedTemplate . BorderThickness = new Thickness ( 0 ) ;
750+
751+ // Re-enable built-in template dropdown when no online template is selected
752+ cmbNewProjectTemplate . IsEnabled = true ;
707753 }
708754 }
709-
710755 private async void btnDownloadTemplate_Click ( object sender , RoutedEventArgs e )
711756 {
712757 var button = sender as Button ;
0 commit comments