@@ -59,16 +59,16 @@ void Start()
59
59
string [ ] args = Environment . GetCommandLineArgs ( ) ;
60
60
if ( args != null && args . Length > 2 )
61
61
{
62
- var commandArg = args [ 1 ] ;
63
- if ( commandArg == "-projectPath" )
62
+ var commandLineArgs = args [ 1 ] ;
63
+ if ( commandLineArgs == "-projectPath" )
64
64
{
65
65
SetStatus ( "Launching from commandline.." ) ;
66
66
67
67
var projectPathArgument = args [ 2 ] ;
68
-
69
68
var version = GetProjectVersion ( projectPathArgument ) ;
70
69
71
70
LaunchProject ( projectPathArgument , version , true ) ;
71
+
72
72
SetStatus ( "Ready" ) ;
73
73
74
74
// quit after launch if enabled in settings
@@ -272,7 +272,6 @@ void UpdateRecentProjectsList()
272
272
gridRecent . Rows [ gridRecent . Rows . Count - 1 ] . Cells [ 1 ] . Style . ForeColor = HaveExactVersionInstalled ( projectVersion ) ? Color . Green : Color . Red ;
273
273
}
274
274
}
275
-
276
275
SetStatus ( "Ready" ) ;
277
276
}
278
277
@@ -294,36 +293,44 @@ void LaunchProject(string projectPath, string version, bool openProject = true)
294
293
{
295
294
if ( Directory . Exists ( projectPath ) == true )
296
295
{
297
- if ( Directory . Exists ( Path . Combine ( projectPath , "Assets" ) ) )
296
+ // no assets path, probably we want to create new project then
297
+ var assetsFolder = Path . Combine ( projectPath , "Assets" ) ;
298
+ if ( Directory . Exists ( assetsFolder ) == false )
298
299
{
299
- //var version = GetProjectVersion(projectPath);
300
- //Console.WriteLine("Detected project version: " + version);
300
+ // TODO could ask if want to create project
301
+ Directory . CreateDirectory ( assetsFolder ) ;
302
+ }
301
303
302
- bool haveExactVersion = HaveExactVersionInstalled ( version ) ;
303
- if ( haveExactVersion == true )
304
- {
305
- //Console.WriteLine("Opening unity version " + version);
306
- SetStatus ( "Launching project in unity " + version ) ;
304
+ bool haveExactVersion = HaveExactVersionInstalled ( version ) ;
305
+ if ( haveExactVersion == true )
306
+ {
307
+ //Console.WriteLine("Opening unity version " + version);
308
+ SetStatus ( "Launching project in unity " + version ) ;
307
309
308
- try
309
- {
310
- Process myProcess = new Process ( ) ;
311
- var cmd = "\" " + unityList [ version ] + "\" " ;
312
- myProcess . StartInfo . FileName = cmd ;
313
- if ( openProject == true )
314
- {
315
- var pars = " -projectPath " + "\" " + projectPath + "\" " ;
316
- myProcess . StartInfo . Arguments = pars ;
317
- }
318
- myProcess . Start ( ) ;
319
- }
320
- catch ( Exception ex )
310
+ try
311
+ {
312
+ Process myProcess = new Process ( ) ;
313
+ var cmd = "\" " + unityList [ version ] + "\" " ;
314
+ myProcess . StartInfo . FileName = cmd ;
315
+ if ( openProject == true )
321
316
{
322
- Console . WriteLine ( ex ) ;
317
+ var pars = " -projectPath " + "\" " + projectPath + "\" " ;
318
+ myProcess . StartInfo . Arguments = pars ;
323
319
}
324
-
320
+ myProcess . Start ( ) ;
321
+ }
322
+ catch ( Exception ex )
323
+ {
324
+ Console . WriteLine ( ex ) ;
325
+ }
326
+ }
327
+ else // we dont have this version installed (or no version info available)
328
+ {
329
+ if ( string . IsNullOrEmpty ( version ) == true )
330
+ {
331
+ DisplayUpgradeDialog ( version , projectPath ) ;
325
332
}
326
- else // we dont have this version installed
333
+ else // offer to download or open web
327
334
{
328
335
SetStatus ( "Missing unity version: " + version ) ;
329
336
@@ -351,10 +358,6 @@ void LaunchProject(string projectPath, string version, bool openProject = true)
351
358
}
352
359
}
353
360
}
354
- else
355
- {
356
- SetStatus ( "No Assets folder founded in: " + projectPath ) ;
357
- }
358
361
}
359
362
else // given path doesnt exists, strange
360
363
{
@@ -877,40 +880,54 @@ private static string FindNearestVersionFromSimilarVersions(string version, IEnu
877
880
return null ;
878
881
}
879
882
883
+ // displays version selector to upgrade project
880
884
void UpgradeProject ( )
881
885
{
882
886
var selected = gridRecent . CurrentCell . RowIndex ;
883
887
if ( selected > - 1 )
884
888
{
885
889
SetStatus ( "Upgrading project.." ) ;
886
890
887
- var path = gridRecent . Rows [ selected ] . Cells [ "_path" ] . Value . ToString ( ) ;
888
- var currentVersion = GetProjectVersion ( path ) ;
889
-
890
- bool haveExactVersion = HaveExactVersionInstalled ( currentVersion ) ;
891
- if ( haveExactVersion == true )
892
- {
893
- // you already have same version, are you sure?
894
- }
895
-
896
- Form2 upgradeDialog = new Form2 ( ) ;
897
- Form2 . currentVersion = currentVersion ;
891
+ var projectPath = gridRecent . Rows [ selected ] . Cells [ "_path" ] . Value . ToString ( ) ;
892
+ var currentVersion = GetProjectVersion ( projectPath ) ;
898
893
899
- if ( upgradeDialog . ShowDialog ( this ) == DialogResult . OK )
894
+ if ( string . IsNullOrEmpty ( currentVersion ) == true )
900
895
{
901
- // yes, upgrade
902
- SetStatus ( "Upgrading project to " + Form2 . currentVersion ) ;
903
- var projectPath = gridRecent . Rows [ selected ] . Cells [ "_path" ] . Value . ToString ( ) ;
904
- LaunchProject ( projectPath , Form2 . currentVersion ) ;
896
+ // TODO no version info available, should handle errors?
905
897
}
906
- else
898
+ else // have version info
907
899
{
908
- // cancelled
909
- SetStatus ( "Cancelled project upgrade" ) ;
900
+ bool haveExactVersion = HaveExactVersionInstalled ( currentVersion ) ;
901
+ if ( haveExactVersion == true )
902
+ {
903
+ // you already have exact version, are you sure about upgrade?
904
+ }
910
905
}
911
- upgradeDialog . Close ( ) ;
912
906
907
+ DisplayUpgradeDialog ( currentVersion , projectPath , true ) ;
908
+ }
909
+ }
910
+
911
+ void DisplayUpgradeDialog ( string currentVersion , string projectPath , bool launchProject = true )
912
+ {
913
+ // display upgrade dialog (version selector)
914
+ Form2 upgradeDialog = new Form2 ( ) ;
915
+ Form2 . currentVersion = currentVersion ;
916
+
917
+ if ( upgradeDialog . ShowDialog ( this ) == DialogResult . OK )
918
+ {
919
+ // yes, upgrade
920
+ SetStatus ( "Upgrading project to " + Form2 . currentVersion ) ;
921
+ if ( launchProject == true ) LaunchProject ( projectPath , Form2 . currentVersion ) ;
922
+ }
923
+ else
924
+ {
925
+ // cancelled
926
+ SetStatus ( "Cancelled project upgrade" ) ;
913
927
}
928
+
929
+ upgradeDialog . Close ( ) ;
914
930
}
931
+
915
932
}
916
933
}
0 commit comments