From ed98029a88cd89702980ac7c40b711afddc5aeb2 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期四, 20 十一月 2025 14:44:59 +0800
Subject: [PATCH] Merge branch 'master' of http://mobile.secondworld.net.cn:10010/r/Project_SG_scripts

---
 Main/Utility/UIUtility.cs |   58 ++++++++++++++++++++++++++--------------------------------
 1 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/Main/Utility/UIUtility.cs b/Main/Utility/UIUtility.cs
index 98468b2..1ae82d0 100644
--- a/Main/Utility/UIUtility.cs
+++ b/Main/Utility/UIUtility.cs
@@ -3,7 +3,7 @@
 using UnityEngine;
 using UnityEngine.UI;
 using UnityEngine.EventSystems;
-using vnxbqy.UI;
+
 
 
 public static class UIUtility
@@ -11,7 +11,7 @@
 
     public static GameObject CreateWidget(string _sourceName, string _name)
     {
-        var prefab = ResManager.Instance.LoadAsset<GameObject>("UI", _sourceName);
+        var prefab = UILoader.LoadPrefab(_sourceName);
         if (prefab == null)
         {
             return null;
@@ -78,22 +78,16 @@
 
     public static Vector2 GetMaxWorldPosition(this RectTransform _rectTransform)
     {
-        Vector2 max;
-        var offsetY = (1 - _rectTransform.pivot.y) * _rectTransform.rect.height;
-        var offsetX = (1 - _rectTransform.pivot.x) * _rectTransform.rect.width;
-        max = _rectTransform.TransformPoint(offsetX, offsetY, 0);
-
-        return max;
+        Vector3[] cornors = new Vector3[4];
+        _rectTransform.GetWorldCorners(cornors);
+        return cornors[2];
     }
 
     public static Vector2 GetMinWorldPosition(this RectTransform _rectTransform)
     {
-        Vector2 min;
-        var offsetY = -_rectTransform.pivot.y * _rectTransform.rect.height;
-        var offsetX = -_rectTransform.pivot.x * _rectTransform.rect.width;
-        min = _rectTransform.TransformPoint(offsetX, offsetY, 0);
-
-        return min;
+        Vector3[] cornors = new Vector3[4];
+        _rectTransform.GetWorldCorners(cornors);
+        return cornors[0];
     }
 
     public static Vector2 GetMaxReferencePosition(this RectTransform _rectTransform, Transform _reference)
@@ -316,24 +310,6 @@
         vertexHelper.AddTriangle(currentVertCount, currentVertCount + 1, currentVertCount + 2);
     }
 
-    // public static string GetUIElementRelativePath(UIRoot _root, Transform _transform)
-    // {
-    //     List<Transform> parents = new List<Transform>() { _transform };
-    //     GetParents(_transform, ref parents);
-
-    //     if (parents.Contains(_root.transform))
-    //     {
-    //         parents.Remove(_root.transform);
-    //     }
-
-    //     var names = new string[parents.Count];
-    //     for (int i = 0; i < names.Length; i++)
-    //     {
-    //         names[i] = parents[i].gameObject.name;
-    //     }
-
-    //     return string.Join("/", names);
-    // }
 
     public static void GetParents(Transform _transform, ref List<Transform> _parents)
     {
@@ -350,4 +326,22 @@
         }
     }
 
+    public static string GetUIElementRelativePath(Transform _root, Transform _transform)
+    {
+        List<Transform> parents = new List<Transform>() { _transform };
+        GetParents(_transform, ref parents);
+
+        if (parents.Contains(_root))
+        {
+            parents.Remove(_root);
+        }
+
+        var names = new string[parents.Count];
+        for (int i = 0; i < names.Length; i++)
+        {
+            names[i] = parents[i].gameObject.name;
+        }
+
+        return string.Join("/", names);
+    }
 }

--
Gitblit v1.8.0