@@ -1048,6 +1048,53 @@ private void listOnlineTemplates_SelectionChanged(object sender, SelectionChange
10481048 UpdateCreateButtonsEnabledState ( ) ;
10491049 }
10501050
1051+ private void DeleteTemplate_Click ( object sender , RoutedEventArgs e )
1052+ {
1053+ if ( ! ( sender is MenuItem menuItem ) || ! ( menuItem . DataContext is OnlineTemplateItem template ) ) return ;
1054+ if ( string . IsNullOrEmpty ( template . TarBallURL ) ) return ;
1055+
1056+ string templatesPath = Path . Combine (
1057+ Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) ,
1058+ "UnityHub" , "Templates" ) ;
1059+ string fileName ;
1060+
1061+ try
1062+ {
1063+ fileName = Path . GetFileName ( new Uri ( template . TarBallURL ) . LocalPath ) ;
1064+ }
1065+ catch
1066+ {
1067+ return ;
1068+ }
1069+
1070+ if ( string . IsNullOrEmpty ( fileName ) ) return ;
1071+
1072+ string filePath = Path . Combine ( templatesPath , fileName ) ;
1073+ try
1074+ {
1075+ if ( File . Exists ( filePath ) ) File . Delete ( filePath ) ;
1076+ template . IsDownloaded = false ;
1077+
1078+ if ( listOnlineTemplates . SelectedItem == template )
1079+ {
1080+ btnCreateNewProject . Content = "Download Template First >" ;
1081+ }
1082+ }
1083+ catch ( Exception ex )
1084+ {
1085+ MessageBox . Show ( this , "Could not delete the template:\n " + ex . Message ,
1086+ "Delete template" , MessageBoxButton . OK , MessageBoxImage . Error ) ;
1087+ }
1088+ }
1089+
1090+ private void OpenTemplateInExplorer_Click ( object sender , RoutedEventArgs e )
1091+ {
1092+ string templatesPath = Path . Combine (
1093+ Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) ,
1094+ "UnityHub" , "Templates" ) ;
1095+ Tools . LaunchExplorer ( templatesPath ) ;
1096+ }
1097+
10511098 private async void btnDownloadTemplate_Click ( object sender , RoutedEventArgs e )
10521099 {
10531100 var button = sender as Button ;
@@ -1361,6 +1408,5 @@ private void txtTokenInput_PasswordChanged(object sender, RoutedEventArgs e)
13611408 btnAuthorizeToken . IsEnabled = tokenSeemsOK ;
13621409 }
13631410
1364-
13651411 } // class NewProject
13661412} // namespace UnityLauncherPro
0 commit comments