@@ -197,6 +197,7 @@ public class GithubRelease
197
197
[ Serializable ]
198
198
public class TransportArtifactDefinition
199
199
{
200
+ public int breaking_version ;
200
201
public TransportArtifact [ ] artifacts ;
201
202
}
202
203
@@ -236,12 +237,14 @@ public class GithubAsset
236
237
[ InitializeOnLoad ]
237
238
public class MLAPIEditor : EditorWindow
238
239
{
240
+ private const int COMPATIBLE_ARTIFACT_PATH_VERSION = 1 ;
239
241
private const string API_URL = "https://api.github.com/repos/MidLevel/MLAPI/releases" ;
240
242
private const string TRANSPORT_ARTIFACT_PATH_URL = "https://api.github.com/repos/MidLevel/MLAPI.Transports/contents/artifact_paths.json" ;
241
243
private const string TRANSPORT_ARTIFACT_DOWNLOAD_URL_TEMPLATE = "https://ci.appveyor.com/api/projects/MidLevel/MLAPI-Transports/artifacts/<path>?branch=master" ;
242
244
private GithubRelease [ ] releases = new GithubRelease [ 0 ] ;
243
245
private TransportArtifactDefinition transportArtifacts = null ;
244
- private int [ ] transportVersionSelections = new int [ 0 ] ;
246
+ private bool transportArtifactIncompatble = false ;
247
+ private bool forceRenderAtrifacts = false ;
245
248
private bool [ ] releaseFoldoutStatus = new bool [ 0 ] ;
246
249
private bool [ ] transportFoldoutStatus = new bool [ 0 ] ;
247
250
@@ -375,112 +378,124 @@ private void OnGUI()
375
378
}
376
379
else if ( tab == 1 )
377
380
{
378
- MLAPIVersion currentMLAPIVersion = MLAPIVersion . Parse ( currentVersion ) ;
379
-
380
- if ( transportArtifacts != null && transportArtifacts . artifacts != null && transportFoldoutStatus != null )
381
+ if ( transportArtifactIncompatble && ! forceRenderAtrifacts )
381
382
{
382
- for ( int i = 0 ; i < transportArtifacts . artifacts . Length ; i ++ )
383
- {
384
- if ( transportArtifacts . artifacts [ i ] == null )
385
- continue ;
386
-
387
- string transportDirectory = Path . Combine ( Path . Combine ( Path . Combine ( Application . dataPath , "MLAPI" ) , "OfficialTransports" ) , transportArtifacts . artifacts [ i ] . id ) ;
388
- bool isInstalled = Directory . Exists ( transportDirectory ) && Directory . GetFiles ( transportDirectory ) . Length > 0 ;
383
+ EditorGUILayout . HelpBox ( "The transport installer version you are using is incompatbile with the latest manifest. Please upgrade your installer by downloading the latest MLAPI version.." , MessageType . Warning ) ;
389
384
390
- transportFoldoutStatus [ i ] = EditorGUILayout . Foldout ( transportFoldoutStatus [ i ] , transportArtifacts . artifacts [ i ] . name + ( ( isInstalled ) ? " - [Installed]" : "" ) ) ;
385
+ if ( GUILayout . Button ( new GUIContent ( "Ignore" , "Ignore the version diff and try to render the content anyways. This might lead to render failures or other errors." ) ) )
386
+ {
387
+ forceRenderAtrifacts = true ;
388
+ }
389
+ }
390
+ else
391
+ {
392
+ MLAPIVersion currentMLAPIVersion = MLAPIVersion . Parse ( currentVersion ) ;
391
393
392
- if ( transportFoldoutStatus [ i ] )
394
+ if ( transportArtifacts != null && transportArtifacts . artifacts != null && transportFoldoutStatus != null )
395
+ {
396
+ for ( int i = 0 ; i < transportArtifacts . artifacts . Length ; i ++ )
393
397
{
394
- EditorGUI . indentLevel ++ ;
398
+ if ( transportArtifacts . artifacts [ i ] == null )
399
+ continue ;
395
400
396
- EditorGUILayout . LabelField ( "Description" , EditorStyles . boldLabel ) ;
397
- EditorGUILayout . LabelField ( transportArtifacts . artifacts [ i ] . description , EditorStyles . wordWrappedLabel ) ;
401
+ string transportDirectory = Path . Combine ( Path . Combine ( Path . Combine ( Application . dataPath , "MLAPI" ) , "OfficialTransports" ) , transportArtifacts . artifacts [ i ] . id ) ;
402
+ bool isInstalled = Directory . Exists ( transportDirectory ) && Directory . GetFiles ( transportDirectory ) . Length > 0 ;
398
403
399
- EditorGUILayout . LabelField ( "Credits" , EditorStyles . boldLabel ) ;
400
- EditorGUILayout . LabelField ( transportArtifacts . artifacts [ i ] . credits , EditorStyles . wordWrappedLabel ) ;
404
+ transportFoldoutStatus [ i ] = EditorGUILayout . Foldout ( transportFoldoutStatus [ i ] , transportArtifacts . artifacts [ i ] . name + ( ( isInstalled ) ? " - [Installed]" : "" ) ) ;
401
405
402
- EditorGUILayout . LabelField ( "Platform Compatibility" , EditorStyles . boldLabel ) ;
403
- EditorGUILayout . LabelField ( transportArtifacts . artifacts [ i ] . platform_compatibility_description , EditorStyles . wordWrappedLabel ) ;
406
+ if ( transportFoldoutStatus [ i ] )
407
+ {
408
+ EditorGUI . indentLevel ++ ;
404
409
405
- EditorGUILayout . LabelField ( "Licence " , EditorStyles . boldLabel ) ;
406
- EditorGUILayout . LabelField ( transportArtifacts . artifacts [ i ] . licence , EditorStyles . wordWrappedLabel ) ;
410
+ EditorGUILayout . LabelField ( "Description " , EditorStyles . boldLabel ) ;
411
+ EditorGUILayout . LabelField ( transportArtifacts . artifacts [ i ] . description , EditorStyles . wordWrappedLabel ) ;
407
412
408
- if ( currentMLAPIVersion . MAJOR != ( byte ) transportArtifacts . artifacts [ i ] . mlapi_major_version )
409
- {
410
- EditorGUILayout . Space ( ) ;
411
- GUIStyle style = new GUIStyle ( EditorStyles . wordWrappedLabel ) ;
412
- style . normal . textColor = new Color ( 1f , 0f , 0f ) ;
413
- EditorGUILayout . LabelField ( "The MLAPI version you have installed through the installer has a different major version from the transports major version. You have version v" + currentMLAPIVersion . ToString ( ) + " while this transport targets version v" + transportArtifacts . artifacts [ i ] . mlapi_major_version + ".x.x. This means there could potentially be compatibility issues, but its not guaranteed. If you have installed the MLAPI manually and have version v" + transportArtifacts . artifacts [ i ] . mlapi_major_version + ".x.x you can ignore this message." , style ) ;
414
- EditorGUILayout . Space ( ) ;
415
- }
413
+ EditorGUILayout . LabelField ( "Credits" , EditorStyles . boldLabel ) ;
414
+ EditorGUILayout . LabelField ( transportArtifacts . artifacts [ i ] . credits , EditorStyles . wordWrappedLabel ) ;
416
415
417
- if ( transportArtifacts . artifacts [ i ] . experimental )
418
- {
419
- EditorGUILayout . Space ( ) ;
420
- GUIStyle style = new GUIStyle ( EditorStyles . boldLabel ) ;
421
- style . normal . textColor = new Color ( 1f , 0.5f , 0f ) ;
422
- EditorGUILayout . LabelField ( "Experimental" , style ) ;
423
- }
424
- else
425
- {
426
- EditorGUILayout . Space ( ) ;
427
- GUIStyle style = new GUIStyle ( EditorStyles . boldLabel ) ;
428
- style . normal . textColor = new Color ( 0f , 1f , 0f ) ;
429
- EditorGUILayout . LabelField ( "Stable" , style ) ;
430
- }
416
+ EditorGUILayout . LabelField ( "Platform Compatibility" , EditorStyles . boldLabel ) ;
417
+ EditorGUILayout . LabelField ( transportArtifacts . artifacts [ i ] . platform_compatibility_description , EditorStyles . wordWrappedLabel ) ;
431
418
432
- if ( isInstalled )
433
- {
434
- GUIStyle boldStyle = new GUIStyle ( EditorStyles . boldLabel ) ;
435
- boldStyle . normal . textColor = new Color ( 0.3f , 1f , 0.3f ) ;
436
- EditorGUILayout . LabelField ( "Installed" , boldStyle ) ;
419
+ EditorGUILayout . LabelField ( "Licence" , EditorStyles . boldLabel ) ;
420
+ EditorGUILayout . LabelField ( transportArtifacts . artifacts [ i ] . licence , EditorStyles . wordWrappedLabel ) ;
437
421
438
- // This is installed
439
- if ( GUILayout . Button ( "Reinstall Latest" ) )
422
+ if ( currentMLAPIVersion . MAJOR != ( byte ) transportArtifacts . artifacts [ i ] . mlapi_major_version )
440
423
{
441
- EditorCoroutine . Start ( InstallTransport ( i ) ) ;
424
+ EditorGUILayout . Space ( ) ;
425
+ GUIStyle style = new GUIStyle ( EditorStyles . wordWrappedLabel ) ;
426
+ style . normal . textColor = new Color ( 1f , 0f , 0f ) ;
427
+ EditorGUILayout . LabelField ( "The MLAPI version you have installed through the installer has a different major version from the transports major version. You have version v" + currentMLAPIVersion . ToString ( ) + " while this transport targets version v" + transportArtifacts . artifacts [ i ] . mlapi_major_version + ".x.x. This means there could potentially be compatibility issues, but its not guaranteed. If you have installed the MLAPI manually and have version v" + transportArtifacts . artifacts [ i ] . mlapi_major_version + ".x.x you can ignore this message." , style ) ;
428
+ EditorGUILayout . Space ( ) ;
442
429
}
443
430
444
- if ( GUILayout . Button ( "Remove" ) )
431
+ if ( transportArtifacts . artifacts [ i ] . experimental )
445
432
{
446
- Directory . Delete ( transportDirectory , true ) ;
447
-
448
- string metaFileName = transportDirectory ;
449
-
450
- if ( metaFileName . EndsWith ( Path . DirectorySeparatorChar . ToString ( ) ) ||
451
- metaFileName . EndsWith ( Path . AltDirectorySeparatorChar . ToString ( ) ) )
452
- {
453
- metaFileName = metaFileName . Substring ( metaFileName . Length , metaFileName . Length - 1 ) ;
454
- }
433
+ EditorGUILayout . Space ( ) ;
434
+ GUIStyle style = new GUIStyle ( EditorStyles . boldLabel ) ;
435
+ style . normal . textColor = new Color ( 1f , 0.5f , 0f ) ;
436
+ EditorGUILayout . LabelField ( "Experimental" , style ) ;
437
+ }
438
+ else
439
+ {
440
+ EditorGUILayout . Space ( ) ;
441
+ GUIStyle style = new GUIStyle ( EditorStyles . boldLabel ) ;
442
+ style . normal . textColor = new Color ( 0f , 1f , 0f ) ;
443
+ EditorGUILayout . LabelField ( "Stable" , style ) ;
444
+ }
455
445
456
- metaFileName += ".meta" ;
446
+ if ( isInstalled )
447
+ {
448
+ GUIStyle boldStyle = new GUIStyle ( EditorStyles . boldLabel ) ;
449
+ boldStyle . normal . textColor = new Color ( 0.3f , 1f , 0.3f ) ;
450
+ EditorGUILayout . LabelField ( "Installed" , boldStyle ) ;
457
451
458
- if ( File . Exists ( metaFileName ) )
452
+ // This is installed
453
+ if ( GUILayout . Button ( "Reinstall Latest" ) )
459
454
{
460
- File . Delete ( metaFileName ) ;
455
+ EditorCoroutine . Start ( InstallTransport ( i ) ) ;
461
456
}
462
457
463
- try
458
+ if ( GUILayout . Button ( "Remove" ) )
464
459
{
465
- AssetDatabase . Refresh ( ) ;
466
- }
467
- catch ( Exception e )
468
- {
469
- Debug . LogError ( e . ToString ( ) ) ;
470
- Debug . LogError ( e . GetType ( ) . FullName ) ;
460
+ Directory . Delete ( transportDirectory , true ) ;
461
+
462
+ string metaFileName = transportDirectory ;
463
+
464
+ if ( metaFileName . EndsWith ( Path . DirectorySeparatorChar . ToString ( ) ) ||
465
+ metaFileName . EndsWith ( Path . AltDirectorySeparatorChar . ToString ( ) ) )
466
+ {
467
+ metaFileName = metaFileName . Substring ( metaFileName . Length , metaFileName . Length - 1 ) ;
468
+ }
469
+
470
+ metaFileName += ".meta" ;
471
+
472
+ if ( File . Exists ( metaFileName ) )
473
+ {
474
+ File . Delete ( metaFileName ) ;
475
+ }
476
+
477
+ try
478
+ {
479
+ AssetDatabase . Refresh ( ) ;
480
+ }
481
+ catch ( Exception e )
482
+ {
483
+ Debug . LogError ( e . ToString ( ) ) ;
484
+ Debug . LogError ( e . GetType ( ) . FullName ) ;
485
+ }
471
486
}
472
487
}
473
- }
474
- else
475
- {
476
- if ( GUILayout . Button ( "Install Latest" ) )
488
+ else
477
489
{
478
- EditorCoroutine . Start ( InstallTransport ( i ) ) ;
490
+ if ( GUILayout . Button ( "Install Latest" ) )
491
+ {
492
+ EditorCoroutine . Start ( InstallTransport ( i ) ) ;
493
+ }
479
494
}
480
- }
481
495
482
- EditorGUILayout . Space ( ) ;
483
- EditorGUI . indentLevel -- ;
496
+ EditorGUILayout . Space ( ) ;
497
+ EditorGUI . indentLevel -- ;
498
+ }
484
499
}
485
500
}
486
501
}
@@ -742,16 +757,24 @@ private IEnumerator InstallTransport(int index)
742
757
743
758
if ( ! useNet35 && ! useNet45 )
744
759
{
745
- Debug . LogError ( ( "Could not download transport \" " + transportArtifacts . artifacts [ index ] + "\" . There is no valid target for your platform." ) ) ;
760
+ Debug . LogError ( ( "Could not download transport \" " + transportArtifacts . artifacts [ index ] . name + "\" . There is no valid target for your platform." ) ) ;
746
761
}
747
762
748
763
foreach ( ZipStorer . ZipFileEntry entry in dir )
749
764
{
750
- if ( ( useNet35 && entry . FilenameInZip . Contains ( "net35" ) ) ||
751
- ( useNet45 && entry . FilenameInZip . Contains ( "net45" ) ) )
765
+ if ( useNet35 && entry . FilenameInZip . Contains ( "net35" ) )
752
766
{
753
- string fileName = Path . GetFileName ( entry . FilenameInZip ) ;
754
- zip . ExtractFile ( entry , Path . Combine ( transportDirectory , fileName ) ) ;
767
+ int lastIndexOfNet35 = entry . FilenameInZip . LastIndexOf ( "net35" , StringComparison . Ordinal ) ;
768
+ string fileSubPath = entry . FilenameInZip . Substring ( lastIndexOfNet35 , entry . FilenameInZip . Length - lastIndexOfNet35 ) ;
769
+
770
+ zip . ExtractFile ( entry , Path . Combine ( transportDirectory , fileSubPath ) ) ;
771
+ }
772
+ else if ( useNet45 && entry . FilenameInZip . Contains ( "net45" ) )
773
+ {
774
+ int lastIndexOfNet45 = entry . FilenameInZip . LastIndexOf ( "net45" , StringComparison . Ordinal ) ;
775
+ string fileSubPath = entry . FilenameInZip . Substring ( lastIndexOfNet45 , entry . FilenameInZip . Length - lastIndexOfNet45 ) ;
776
+
777
+ zip . ExtractFile ( entry , Path . Combine ( transportDirectory , fileSubPath ) ) ;
755
778
}
756
779
}
757
780
@@ -900,6 +923,18 @@ private IEnumerator FetchAll()
900
923
901
924
transportArtifacts = JsonUtility . FromJson < TransportArtifactDefinition > ( decodedJson ) ;
902
925
926
+ if ( transportArtifacts != null && transportArtifacts . breaking_version != COMPATIBLE_ARTIFACT_PATH_VERSION )
927
+ {
928
+ // Incompatbile
929
+ transportArtifactIncompatble = true ;
930
+ }
931
+ else
932
+ {
933
+ transportArtifactIncompatble = false ;
934
+ }
935
+
936
+ forceRenderAtrifacts = false ;
937
+
903
938
if ( transportArtifacts == null )
904
939
{
905
940
transportArtifacts = new TransportArtifactDefinition ( ) ;
0 commit comments