@@ -312,8 +312,15 @@ void LaunchProject(string projectPath, string version, bool openProject = true)
312
312
Directory . CreateDirectory ( assetsFolder ) ;
313
313
}
314
314
315
- bool haveExactVersion = HaveExactVersionInstalled ( version ) ;
316
- if ( haveExactVersion == true )
315
+ // check for crashed backup scene first
316
+ var cancelLaunch = CheckCrashBackupScene ( projectPath ) ;
317
+ Console . WriteLine ( cancelLaunch ) ;
318
+ if ( cancelLaunch == true )
319
+ {
320
+ return ;
321
+ }
322
+
323
+ if ( HaveExactVersionInstalled ( version ) == true )
317
324
{
318
325
//Console.WriteLine("Opening unity version " + version);
319
326
SetStatus ( "Launching project in unity " + version ) ;
@@ -352,6 +359,41 @@ void LaunchProject(string projectPath, string version, bool openProject = true)
352
359
}
353
360
}
354
361
362
+ bool CheckCrashBackupScene ( string projectPath )
363
+ {
364
+ var cancelRunningUnity = false ;
365
+ var recoveryFile = Path . Combine ( projectPath , "Temp" , "__Backupscenes" , "0.backup" ) ;
366
+ if ( File . Exists ( recoveryFile ) )
367
+ {
368
+ DialogResult dialogResult = MessageBox . Show ( "Crash recovery scene founded, do you want to copy it into Assets/_Recovery/-folder?" , "UnityLauncher - Scene Recovery" , MessageBoxButtons . YesNoCancel ) ;
369
+ if ( dialogResult == DialogResult . Yes ) // restore
370
+ {
371
+ var restoreFolder = Path . Combine ( projectPath , "Assets" , "_Recovery" ) ;
372
+ if ( Directory . Exists ( restoreFolder ) == false )
373
+ {
374
+ Directory . CreateDirectory ( restoreFolder ) ;
375
+ }
376
+ if ( Directory . Exists ( restoreFolder ) == true )
377
+ {
378
+ Int32 unixTimestamp = ( Int32 ) ( DateTime . UtcNow . Subtract ( new DateTime ( 1970 , 1 , 1 ) ) ) . TotalSeconds ;
379
+ var uniqueFileName = "Recovered_Scene" + unixTimestamp + ".unity" ;
380
+ File . Copy ( recoveryFile , Path . Combine ( restoreFolder , uniqueFileName ) ) ;
381
+ SetStatus ( "Recovered crashed scene into: " + restoreFolder ) ;
382
+ }
383
+ else
384
+ {
385
+ SetStatus ( "Error: Failed to create restore folder: " + restoreFolder ) ;
386
+ cancelRunningUnity = true ;
387
+ }
388
+ }
389
+ else if ( dialogResult == DialogResult . Cancel ) // dont do restore, but run unity
390
+ {
391
+ cancelRunningUnity = true ;
392
+ }
393
+ }
394
+ return cancelRunningUnity ;
395
+ }
396
+
355
397
// parse unity installer exe from release page
356
398
// thanks to https://github.com/softfruit
357
399
string GetDownloadUrlForUnityVersion ( string releaseUrl )
@@ -712,7 +754,7 @@ private void Form1_KeyPress(object sender, KeyPressEventArgs e)
712
754
{
713
755
tbSearchBar . Focus ( ) ;
714
756
tbSearchBar . Text += e . KeyChar ;
715
- tbSearchBar . Select ( tbSearchBar . Text . Length , 0 ) ;
757
+ tbSearchBar . Select ( tbSearchBar . Text . Length , 0 ) ;
716
758
}
717
759
break ;
718
760
}
@@ -743,7 +785,7 @@ private void gridRecent_KeyDown(object sender, KeyEventArgs e)
743
785
//Checks if you are doubleclicking the current cell
744
786
private void GridRecent_CellMouseDoubleClick ( object sender , DataGridViewCellMouseEventArgs e )
745
787
{
746
- if ( e . Button == MouseButtons . Left && e . RowIndex == gridRecent . CurrentCell . RowIndex )
788
+ if ( e . Button == MouseButtons . Left && e . RowIndex == gridRecent . CurrentCell . RowIndex )
747
789
{
748
790
LaunchSelectedProject ( ) ;
749
791
}
0 commit comments