mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-17 22:48:04 +08:00
Include Arial font, don't rely on built-in resource
TODO add font to legacy bundles
This commit is contained in:
parent
ab8acc9e84
commit
f393e0d706
Binary file not shown.
@ -16,12 +16,6 @@ namespace UnityExplorer.UI
|
|||||||
internal static Vector2 _largeElementSize = new Vector2(100, 30);
|
internal static Vector2 _largeElementSize = new Vector2(100, 30);
|
||||||
internal static Vector2 _smallElementSize = new Vector2(25, 25);
|
internal static Vector2 _smallElementSize = new Vector2(25, 25);
|
||||||
internal static Color _defaultTextColor = Color.white;
|
internal static Color _defaultTextColor = Color.white;
|
||||||
internal static Font _defaultFont;
|
|
||||||
|
|
||||||
public static void Init()
|
|
||||||
{
|
|
||||||
_defaultFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GameObject CreateUIObject(string name, GameObject parent, Vector2 size = default)
|
public static GameObject CreateUIObject(string name, GameObject parent, Vector2 size = default)
|
||||||
{
|
{
|
||||||
@ -48,7 +42,7 @@ namespace UnityExplorer.UI
|
|||||||
internal static void SetDefaultTextValues(Text text)
|
internal static void SetDefaultTextValues(Text text)
|
||||||
{
|
{
|
||||||
text.color = _defaultTextColor;
|
text.color = _defaultTextColor;
|
||||||
text.font = _defaultFont;
|
text.font = UIManager.DefaultFont;
|
||||||
text.fontSize = 14;
|
text.fontSize = 14;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ namespace UnityExplorer.UI
|
|||||||
internal static GameObject PanelHolder { get; private set; }
|
internal static GameObject PanelHolder { get; private set; }
|
||||||
|
|
||||||
internal static Font ConsoleFont { get; private set; }
|
internal static Font ConsoleFont { get; private set; }
|
||||||
|
internal static Font DefaultFont { get; private set; }
|
||||||
internal static Shader BackupShader { get; private set; }
|
internal static Shader BackupShader { get; private set; }
|
||||||
|
|
||||||
public static RectTransform NavBarRect;
|
public static RectTransform NavBarRect;
|
||||||
@ -92,8 +93,6 @@ namespace UnityExplorer.UI
|
|||||||
{
|
{
|
||||||
LoadBundle();
|
LoadBundle();
|
||||||
|
|
||||||
UIFactory.Init();
|
|
||||||
|
|
||||||
CreateRootCanvas();
|
CreateRootCanvas();
|
||||||
|
|
||||||
// Global UI Pool Holder
|
// Global UI Pool Holder
|
||||||
@ -423,11 +422,11 @@ namespace UnityExplorer.UI
|
|||||||
int minor = int.Parse(split[1]);
|
int minor = int.Parse(split[1]);
|
||||||
|
|
||||||
// Use appropriate AssetBundle for Unity version
|
// Use appropriate AssetBundle for Unity version
|
||||||
// >= 2017.3
|
// >= 2017
|
||||||
if (major > 2017 || (major == 2017 && minor >= 3))
|
if (major >= 2017)
|
||||||
bundle = LoadBundle("modern");
|
bundle = LoadBundle("modern");
|
||||||
// 5.6.0 to 2017.3
|
// 5.6.0 to <2017
|
||||||
else if (major == 2017 || (major == 5 && minor >= 6))
|
else if (major == 5 && minor >= 6)
|
||||||
bundle = LoadBundle("legacy.5.6");
|
bundle = LoadBundle("legacy.5.6");
|
||||||
// < 5.6.0
|
// < 5.6.0
|
||||||
else
|
else
|
||||||
@ -452,11 +451,15 @@ namespace UnityExplorer.UI
|
|||||||
{
|
{
|
||||||
ExplorerCore.LogWarning("Could not load the ExplorerUI Bundle!");
|
ExplorerCore.LogWarning("Could not load the ExplorerUI Bundle!");
|
||||||
ConsoleFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
|
ConsoleFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
|
||||||
|
DefaultFont = ConsoleFont;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BackupShader = bundle.LoadAsset<Shader>("DefaultUI");
|
// Bundle loaded
|
||||||
|
ConsoleFont = bundle.LoadAsset<Font>("CONSOLA");
|
||||||
|
DefaultFont = bundle.LoadAsset<Font>("arial");
|
||||||
|
|
||||||
|
BackupShader = bundle.LoadAsset<Shader>("DefaultUI");
|
||||||
// Fix for games which don't ship with 'UI/Default' shader.
|
// Fix for games which don't ship with 'UI/Default' shader.
|
||||||
if (Graphic.defaultGraphicMaterial.shader?.name != "UI/Default")
|
if (Graphic.defaultGraphicMaterial.shader?.name != "UI/Default")
|
||||||
{
|
{
|
||||||
@ -466,7 +469,6 @@ namespace UnityExplorer.UI
|
|||||||
else
|
else
|
||||||
BackupShader = Graphic.defaultGraphicMaterial.shader;
|
BackupShader = Graphic.defaultGraphicMaterial.shader;
|
||||||
|
|
||||||
ConsoleFont = bundle.LoadAsset<Font>("CONSOLA");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] ReadFully(Stream input)
|
private static byte[] ReadFully(Stream input)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user