@@ -197,6 +197,7 @@ public class GithubRelease
197197[ Serializable ]
198198public class TransportArtifactDefinition
199199{
200+ public int breaking_version ;
200201 public TransportArtifact [ ] artifacts ;
201202}
202203
@@ -236,12 +237,14 @@ public class GithubAsset
236237[ InitializeOnLoad ]
237238public class MLAPIEditor : EditorWindow
238239{
240+ private const int COMPATIBLE_ARTIFACT_PATH_VERSION = 1 ;
239241 private const string API_URL = "https://api.github.com/repos/MidLevel/MLAPI/releases" ;
240242 private const string TRANSPORT_ARTIFACT_PATH_URL = "https://api.github.com/repos/MidLevel/MLAPI.Transports/contents/artifact_paths.json" ;
241243 private const string TRANSPORT_ARTIFACT_DOWNLOAD_URL_TEMPLATE = "https://ci.appveyor.com/api/projects/MidLevel/MLAPI-Transports/artifacts/<path>?branch=master" ;
242244 private GithubRelease [ ] releases = new GithubRelease [ 0 ] ;
243245 private TransportArtifactDefinition transportArtifacts = null ;
244- private int [ ] transportVersionSelections = new int [ 0 ] ;
246+ private bool transportArtifactIncompatble = false ;
247+ private bool forceRenderAtrifacts = false ;
245248 private bool [ ] releaseFoldoutStatus = new bool [ 0 ] ;
246249 private bool [ ] transportFoldoutStatus = new bool [ 0 ] ;
247250
@@ -375,112 +378,124 @@ private void OnGUI()
375378 }
376379 else if ( tab == 1 )
377380 {
378- MLAPIVersion currentMLAPIVersion = MLAPIVersion . Parse ( currentVersion ) ;
379-
380- if ( transportArtifacts != null && transportArtifacts . artifacts != null && transportFoldoutStatus != null )
381+ if ( transportArtifactIncompatble && ! forceRenderAtrifacts )
381382 {
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 ) ;
389384
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 ) ;
391393
392- if ( transportFoldoutStatus [ i ] )
394+ if ( transportArtifacts != null && transportArtifacts . artifacts != null && transportFoldoutStatus != null )
395+ {
396+ for ( int i = 0 ; i < transportArtifacts . artifacts . Length ; i ++ )
393397 {
394- EditorGUI . indentLevel ++ ;
398+ if ( transportArtifacts . artifacts [ i ] == null )
399+ continue ;
395400
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 ;
398403
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]" : "" ) ) ;
401405
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 ++ ;
404409
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 ) ;
407412
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 ) ;
416415
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 ) ;
431418
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 ) ;
437421
438- // This is installed
439- if ( GUILayout . Button ( "Reinstall Latest" ) )
422+ if ( currentMLAPIVersion . MAJOR != ( byte ) transportArtifacts . artifacts [ i ] . mlapi_major_version )
440423 {
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 ( ) ;
442429 }
443430
444- if ( GUILayout . Button ( "Remove" ) )
431+ if ( transportArtifacts . artifacts [ i ] . experimental )
445432 {
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+ }
455445
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 ) ;
457451
458- if ( File . Exists ( metaFileName ) )
452+ // This is installed
453+ if ( GUILayout . Button ( "Reinstall Latest" ) )
459454 {
460- File . Delete ( metaFileName ) ;
455+ EditorCoroutine . Start ( InstallTransport ( i ) ) ;
461456 }
462457
463- try
458+ if ( GUILayout . Button ( "Remove" ) )
464459 {
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+ }
471486 }
472487 }
473- }
474- else
475- {
476- if ( GUILayout . Button ( "Install Latest" ) )
488+ else
477489 {
478- EditorCoroutine . Start ( InstallTransport ( i ) ) ;
490+ if ( GUILayout . Button ( "Install Latest" ) )
491+ {
492+ EditorCoroutine . Start ( InstallTransport ( i ) ) ;
493+ }
479494 }
480- }
481495
482- EditorGUILayout . Space ( ) ;
483- EditorGUI . indentLevel -- ;
496+ EditorGUILayout . Space ( ) ;
497+ EditorGUI . indentLevel -- ;
498+ }
484499 }
485500 }
486501 }
@@ -742,16 +757,24 @@ private IEnumerator InstallTransport(int index)
742757
743758 if ( ! useNet35 && ! useNet45 )
744759 {
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." ) ) ;
746761 }
747762
748763 foreach ( ZipStorer . ZipFileEntry entry in dir )
749764 {
750- if ( ( useNet35 && entry . FilenameInZip . Contains ( "net35" ) ) ||
751- ( useNet45 && entry . FilenameInZip . Contains ( "net45" ) ) )
765+ if ( useNet35 && entry . FilenameInZip . Contains ( "net35" ) )
752766 {
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 ) ) ;
755778 }
756779 }
757780
@@ -900,6 +923,18 @@ private IEnumerator FetchAll()
900923
901924 transportArtifacts = JsonUtility . FromJson < TransportArtifactDefinition > ( decodedJson ) ;
902925
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+
903938 if ( transportArtifacts == null )
904939 {
905940 transportArtifacts = new TransportArtifactDefinition ( ) ;
0 commit comments