| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using TMPro;
- using UnityEngine;
- public static class LocaleUI
- {
- public static void SetText(Transform root, string path, string key)
- {
- if (root == null || string.IsNullOrEmpty(key))
- return;
- TMP_Text text = string.IsNullOrEmpty(path)
- ? root.GetComponent<TMP_Text>()
- : UIViewUtility.Text(root, path);
- if (text != null)
- text.text = L.Get(key);
- }
- public static void SetFormat(Transform root, string path, string key, params object[] args)
- {
- if (root == null || string.IsNullOrEmpty(key))
- return;
- TMP_Text text = string.IsNullOrEmpty(path)
- ? root.GetComponent<TMP_Text>()
- : UIViewUtility.Text(root, path);
- if (text != null)
- text.text = L.F(key, args);
- }
- public static void ApplyLocalizedTmp(Transform root)
- {
- if (root == null)
- return;
- var items = root.GetComponentsInChildren<LocalizedTMP>(true);
- for (int i = 0; i < items.Length; i++)
- items[i].Apply();
- }
- }
|