Skip to content

Commit 3e3bd65

Browse files
committed
fix: Improve project creation and template handling
- Resolves issues with directory selection when creating a new project. - Implements a try-catch block to gracefully handle errors when a template .tgz file fails to parse, preventing the process from crashing.
1 parent 8e8b25c commit 3e3bd65

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

ULauncherPro/MainWindow.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,6 +2128,7 @@ void CreateNewEmptyProject(string targetFolder = null)
21282128
if (results == true)
21292129
{
21302130
// TODO check if that folder already exists (automatic naming avoids it, but manual naming could cause it)
2131+
rootFolder = NewProject.targetFolder;
21312132
Console.WriteLine("Create project " + NewProject.newVersion + " : " + rootFolder);
21322133
if (string.IsNullOrEmpty(rootFolder)) return;
21332134

ULauncherPro/NewProject.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public partial class NewProject : Window
2222
int previousSelectedTemplateIndex = -1;
2323
int previousSelectedModuleIndex = -1;
2424

25-
static string targetFolder = null;
25+
public static string targetFolder { get; private set; } = null;
2626

2727
public NewProject(string unityVersion, string suggestedName, string targetFolder, bool nameIsLocked = false)
2828
{
@@ -355,6 +355,7 @@ private void txtNewProjectFolder_TextChanged(object sender, TextChangedEventArgs
355355
{
356356
txtNewProjectFolder.BorderBrush = null;
357357
btnCreateNewProject.IsEnabled = true;
358+
targetFolder = txtNewProjectFolder.Text;
358359
}
359360
}
360361
}

ULauncherPro/Tools.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,11 +1708,18 @@ public static Project FastCreateProject(string version, string baseFolder, strin
17081708
// unzip or copy template
17091709
if (templateZipPath != null)
17101710
{
1711-
//Console.WriteLine(templateZipPath);
1711+
// Console.WriteLine(templateZipPath);
17121712

17131713
if (File.Exists(templateZipPath))
17141714
{
1715-
TarLib.Tar.ExtractTarGz(templateZipPath, newPath);
1715+
try
1716+
{
1717+
TarLib.Tar.ExtractTarGz(templateZipPath, newPath);
1718+
}
1719+
catch (Exception ex)
1720+
{
1721+
SetStatus("Error extract template file:" + ex.Message);
1722+
}
17161723
}
17171724
else if (Directory.Exists(templateZipPath))
17181725
{

0 commit comments

Comments
 (0)