Skip to content

Commit e29680f

Browse files
committed
fix nullref for initscript folder #207
1 parent b9a37eb commit e29680f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

UnityLauncherPro/MainWindow.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,6 +2095,11 @@ void CreateNewEmptyProject(string targetFolder = null)
20952095
}
20962096
}
20972097

2098+
if (string.IsNullOrEmpty(initScriptFileFullPath) == true)
2099+
{
2100+
initScriptFileFullPath = Tools.GetSafeFilePath("Scripts", "InitializeProject.cs");
2101+
}
2102+
20982103
// for new projects created from explorer, always ask for name
20992104
if (chkAskNameForQuickProject.IsChecked == true || targetFolder != null)
21002105
{
@@ -3486,6 +3491,11 @@ private void btnExploreScriptsFolder_Click(object sender, RoutedEventArgs e)
34863491
{
34873492
if (Tools.LaunchExplorer(Path.GetDirectoryName(initScriptFileFullPath)) == false)
34883493
{
3494+
if (string.IsNullOrEmpty(initScriptFileFullPath) == true)
3495+
{
3496+
initScriptFileFullPath = Tools.GetSafeFilePath("Scripts", "InitializeProject.cs");
3497+
}
3498+
34893499
// if failed, open parent folder (probably path was using URL or no scripts yet)
34903500
var parentPath = Directory.GetParent(Path.GetDirectoryName(initScriptFileFullPath)).FullName;
34913501
if (Tools.LaunchExplorer(parentPath) == false)

UnityLauncherPro/Tools.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,8 @@ public static string GetUnityExePath(string version)
455455
// opens Explorer to target folder
456456
public static bool LaunchExplorer(string folder)
457457
{
458+
if (folder == null || folder.Length < 1) return false;
459+
458460
if (Directory.Exists(folder) == true)
459461
{
460462
Process.Start(folder);

0 commit comments

Comments
 (0)