using System.Collections.Generic; using System.Globalization; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; public static class UIViewUtility { static readonly Dictionary AvatarSprites = new Dictionary(); public static Transform Find(Transform root, string path) { if (root == null || string.IsNullOrEmpty(path)) return null; Transform direct = root.Find(path); if (direct != null) return direct; string[] segments = path.Split('/'); string leaf = segments[segments.Length - 1]; return FindByName(root, leaf); } public static Transform FindByName(Transform root, string name) { if (root == null) return null; if (root.name == name) return root; for (int i = 0; i < root.childCount; i++) { Transform match = FindByName(root.GetChild(i), name); if (match != null) return match; } return null; } public static T Get(Transform root, string path) where T : Component { Transform target = Find(root, path); return target != null ? target.GetComponent() : null; } public static TMP_Text Text(Transform root, string path) { return Get(root, path); } public static Image Image(Transform root, string path) { return Get(root, path); } public static Button Button(Transform root, string path, bool ensure = true) { Transform target = Find(root, path); if (target == null) return null; return EnsureButton(target); } public static Button EnsureButton(Transform target) { if (target == null) return null; Button button = target.GetComponent