You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
3 months ago
|
using System;
|
||
|
using D2D.UI;
|
||
|
using TMPro;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace D2D.UI
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// Can be extended with other classes to secondary game font, etc.
|
||
|
/// Or use enum for primary, secondary text. Or bold, regular.
|
||
|
/// </summary>
|
||
|
public class DefaultFontInjection : MonoBehaviour
|
||
|
{
|
||
|
[SerializeField] private bool _isOn = true;
|
||
|
|
||
|
private void Start()
|
||
|
{
|
||
|
return;
|
||
|
|
||
|
if (!_isOn)
|
||
|
return;
|
||
|
|
||
|
// var defaultGameFont = UISettings.Instance.defaultGameFont;
|
||
|
var defaultGameFont = FindObjectOfType<TextMeshPro>().font;
|
||
|
var uiLabel = GetComponent<TextMeshProUGUI>();
|
||
|
var worldUILabel = GetComponent<TextMeshPro>();
|
||
|
|
||
|
if (uiLabel == null && worldUILabel == null)
|
||
|
{
|
||
|
throw new NullReferenceException("text wanted to have default font");
|
||
|
}
|
||
|
|
||
|
if (uiLabel != null)
|
||
|
uiLabel.font = defaultGameFont;
|
||
|
|
||
|
if (worldUILabel != null)
|
||
|
worldUILabel.font = defaultGameFont;
|
||
|
}
|
||
|
}
|
||
|
}
|