Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit 802bb72

Browse files
committed
Use Application.unityVersion to load appropriate AssetBundle
And fix issue with Dropdowns and Time input label not refreshing properly on launch
1 parent 9ca992b commit 802bb72

File tree

4 files changed

+34
-15
lines changed

4 files changed

+34
-15
lines changed

src/Resources/legacy.5.6.bundle

213 KB
Binary file not shown.
File renamed without changes.
File renamed without changes.

src/UI/UIManager.cs

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ internal static void InitUI()
121121
lastScreenWidth = Screen.width;
122122
lastScreenHeight = Screen.height;
123123

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+
124130
Initializing = false;
125131
}
126132

@@ -404,18 +410,41 @@ private static void CreateTopNavBar()
404410
closeBtn.OnClick += OnCloseButtonClicked;
405411
}
406412

407-
#region UI AssetBundle
413+
// UI AssetBundle
408414

409415
private static void LoadBundle()
410416
{
411417
AssetBundle bundle = null;
412418
try
413419
{
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")));
417447
}
418-
catch { }
419448

420449
if (bundle == null)
421450
{
@@ -438,14 +467,6 @@ private static void LoadBundle()
438467
ConsoleFont = bundle.LoadAsset<Font>("CONSOLA");
439468
}
440469

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-
449470
private static byte[] ReadFully(Stream input)
450471
{
451472
using (var ms = new MemoryStream())
@@ -457,7 +478,5 @@ private static byte[] ReadFully(Stream input)
457478
return ms.ToArray();
458479
}
459480
}
460-
461-
#endregion
462481
}
463482
}

0 commit comments

Comments
 (0)