2024-11-26 08:22:26 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using TMPro;
|
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
using UnityEditor;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
https://bonnate.tistory.com/
|
|
|
|
|
|
|
|
Insert the script into the game object
|
|
|
|
insert the TMP font in the inspector
|
|
|
|
and press the button to find and replace all components.
|
|
|
|
|
|
|
|
It may work abnormally, so make sure to back up your scene before using it!!
|
|
|
|
*/
|
|
|
|
|
|
|
|
public class TMP_FontChanger : MonoBehaviour
|
|
|
|
{
|
|
|
|
[SerializeField] public TMP_FontAsset FontAsset;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
[CustomEditor(typeof(TMP_FontChanger))]
|
|
|
|
public class TMP_FontChangerEditor : Editor
|
|
|
|
{
|
|
|
|
public override void OnInspectorGUI()
|
|
|
|
{
|
|
|
|
base.OnInspectorGUI();
|
|
|
|
|
|
|
|
if (GUILayout.Button("Change Font!"))
|
|
|
|
{
|
|
|
|
TMP_FontAsset fontAsset = ((TMP_FontChanger)target).FontAsset;
|
|
|
|
|
2024-11-28 23:07:50 +00:00
|
|
|
foreach(TextMeshPro textMeshPro3D in FindObjectsByType<TextMeshPro>(FindObjectsInactive.Include, FindObjectsSortMode.None))
|
2024-11-26 08:22:26 +00:00
|
|
|
{
|
|
|
|
textMeshPro3D.font = fontAsset;
|
|
|
|
}
|
2024-11-28 23:07:50 +00:00
|
|
|
foreach(TextMeshProUGUI textMeshProUi in FindObjectsByType<TextMeshProUGUI>(FindObjectsInactive.Include, FindObjectsSortMode.None))
|
2024-11-26 08:22:26 +00:00
|
|
|
{
|
|
|
|
textMeshProUi.font = fontAsset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|