@@ -121,6 +121,12 @@ internal static void InitUI()
121
121
lastScreenWidth = Screen . width ;
122
122
lastScreenHeight = Screen . height ;
123
123
124
+ // Failsafe fix
125
+ foreach ( var dropdown in CanvasRoot . GetComponentsInChildren < Dropdown > ( true ) )
126
+ dropdown . RefreshShownValue ( ) ;
127
+ timeInput . Text = string . Empty ;
128
+ timeInput . Text = Time . timeScale . ToString ( ) ;
129
+
124
130
Initializing = false ;
125
131
}
126
132
@@ -404,18 +410,41 @@ private static void CreateTopNavBar()
404
410
closeBtn . OnClick += OnCloseButtonClicked ;
405
411
}
406
412
407
- #region UI AssetBundle
413
+ // UI AssetBundle
408
414
409
415
private static void LoadBundle ( )
410
416
{
411
417
AssetBundle bundle = null ;
412
418
try
413
419
{
414
- bundle = LoadBundle ( "modern" ) ;
415
- if ( bundle == null )
416
- bundle = LoadBundle ( "legacy" ) ;
420
+ // Get the Unity version (without the 'f_' suffix).
421
+ Version version = new Version ( Application . unityVersion . Substring ( 0 , Application . unityVersion . LastIndexOf ( 'f' ) ) ) ;
422
+
423
+ // Use appropriate AssetBundle for Unity version
424
+ // >= 2017.3
425
+ if ( version . Major > 2017 || ( version . Major == 2017 && version . Minor >= 3 ) )
426
+ bundle = LoadBundle ( "modern" ) ;
427
+ // 5.6.0 to 2017.3
428
+ else if ( version . Major == 2017 || ( version . Major == 5 && version . Minor >= 6 ) )
429
+ bundle = LoadBundle ( "legacy.5.6" ) ;
430
+ // < 5.6.0
431
+ else
432
+ bundle = LoadBundle ( "legacy" ) ;
433
+ }
434
+ catch ( Exception ex )
435
+ {
436
+ ExplorerCore . LogWarning ( $ "Exception loading Explorer AssetBundle!") ;
437
+ ExplorerCore . Log ( ex ) ;
438
+ }
439
+
440
+ AssetBundle LoadBundle ( string id )
441
+ {
442
+ ExplorerCore . Log ( $ "Loading { id } bundle for Unity { Application . unityVersion } ") ;
443
+
444
+ return AssetBundle . LoadFromMemory ( ReadFully ( typeof ( ExplorerCore )
445
+ . Assembly
446
+ . GetManifestResourceStream ( $ "UnityExplorer.Resources.{ id } .bundle") ) ) ;
417
447
}
418
- catch { }
419
448
420
449
if ( bundle == null )
421
450
{
@@ -438,14 +467,6 @@ private static void LoadBundle()
438
467
ConsoleFont = bundle . LoadAsset < Font > ( "CONSOLA" ) ;
439
468
}
440
469
441
- private static AssetBundle LoadBundle ( string id )
442
- {
443
- var stream = typeof ( ExplorerCore ) . Assembly
444
- . GetManifestResourceStream ( $ "UnityExplorer.Resources.explorerui.{ id } .bundle") ;
445
-
446
- return AssetBundle . LoadFromMemory ( ReadFully ( stream ) ) ;
447
- }
448
-
449
470
private static byte [ ] ReadFully ( Stream input )
450
471
{
451
472
using ( var ms = new MemoryStream ( ) )
@@ -457,7 +478,5 @@ private static byte[] ReadFully(Stream input)
457
478
return ms . ToArray ( ) ;
458
479
}
459
480
}
460
-
461
- #endregion
462
481
}
463
482
}
0 commit comments