CapersProject/Assets/AllIn1VfxToolkit/Demo & Assets/Demo/Scripts/AllIn1ChangeAllChildTextFonts.cs

24 lines
613 B
C#
Raw Normal View History

2025-02-10 05:47:48 +00:00
using UnityEngine;
using UnityEngine.UI;
namespace AllIn1VfxToolkit.Demo.Scripts
{
public class AllIn1ChangeAllChildTextFonts : MonoBehaviour
{
[SerializeField] private Font newFont;
[SerializeField] private bool changeFontOnStart;
private void Start()
{
if(changeFontOnStart) ChangeFonts();
}
[ContextMenu("ChangeFonts")]
private void ChangeFonts()
{
Text[] canvasTexts = GetComponentsInChildren<Text>();
for(int i = 0; i < canvasTexts.Length; i++) canvasTexts[i].font = newFont;
}
}
}