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

Commit f393e0d

Browse files
committed
Include Arial font, don't rely on built-in resource
TODO add font to legacy bundles
1 parent ab8acc9 commit f393e0d

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

src/Resources/modern.bundle

439 KB
Binary file not shown.

src/UI/UIFactory.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ public static class UIFactory
1616
internal static Vector2 _largeElementSize = new Vector2(100, 30);
1717
internal static Vector2 _smallElementSize = new Vector2(25, 25);
1818
internal static Color _defaultTextColor = Color.white;
19-
internal static Font _defaultFont;
20-
21-
public static void Init()
22-
{
23-
_defaultFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
24-
}
2519

2620
public static GameObject CreateUIObject(string name, GameObject parent, Vector2 size = default)
2721
{
@@ -48,7 +42,7 @@ public static GameObject CreateUIObject(string name, GameObject parent, Vector2
4842
internal static void SetDefaultTextValues(Text text)
4943
{
5044
text.color = _defaultTextColor;
51-
text.font = _defaultFont;
45+
text.font = UIManager.DefaultFont;
5246
text.fontSize = 14;
5347
}
5448

src/UI/UIManager.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public enum VerticalAnchor
5252
internal static GameObject PanelHolder { get; private set; }
5353

5454
internal static Font ConsoleFont { get; private set; }
55+
internal static Font DefaultFont { get; private set; }
5556
internal static Shader BackupShader { get; private set; }
5657

5758
public static RectTransform NavBarRect;
@@ -92,8 +93,6 @@ internal static void InitUI()
9293
{
9394
LoadBundle();
9495

95-
UIFactory.Init();
96-
9796
CreateRootCanvas();
9897

9998
// Global UI Pool Holder
@@ -423,11 +422,11 @@ private static void LoadBundle()
423422
int minor = int.Parse(split[1]);
424423

425424
// Use appropriate AssetBundle for Unity version
426-
// >= 2017.3
427-
if (major > 2017 || (major == 2017 && minor >= 3))
425+
// >= 2017
426+
if (major >= 2017)
428427
bundle = LoadBundle("modern");
429-
// 5.6.0 to 2017.3
430-
else if (major == 2017 || (major == 5 && minor >= 6))
428+
// 5.6.0 to <2017
429+
else if (major == 5 && minor >= 6)
431430
bundle = LoadBundle("legacy.5.6");
432431
// < 5.6.0
433432
else
@@ -452,11 +451,15 @@ AssetBundle LoadBundle(string id)
452451
{
453452
ExplorerCore.LogWarning("Could not load the ExplorerUI Bundle!");
454453
ConsoleFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
454+
DefaultFont = ConsoleFont;
455455
return;
456456
}
457457

458-
BackupShader = bundle.LoadAsset<Shader>("DefaultUI");
458+
// Bundle loaded
459+
ConsoleFont = bundle.LoadAsset<Font>("CONSOLA");
460+
DefaultFont = bundle.LoadAsset<Font>("arial");
459461

462+
BackupShader = bundle.LoadAsset<Shader>("DefaultUI");
460463
// Fix for games which don't ship with 'UI/Default' shader.
461464
if (Graphic.defaultGraphicMaterial.shader?.name != "UI/Default")
462465
{
@@ -466,7 +469,6 @@ AssetBundle LoadBundle(string id)
466469
else
467470
BackupShader = Graphic.defaultGraphicMaterial.shader;
468471

469-
ConsoleFont = bundle.LoadAsset<Font>("CONSOLA");
470472
}
471473

472474
private static byte[] ReadFully(Stream input)

0 commit comments

Comments
 (0)