From 99a11d2bb19d74f6cc8584ac16838062af4fb301 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 03 四月 2026 11:24:07 +0800
Subject: [PATCH] webgl 优化
---
Main/Component/UI/Effect/EllipseMask.cs | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/Main/Component/UI/Effect/EllipseMask.cs b/Main/Component/UI/Effect/EllipseMask.cs
index 8361294..de4b87d 100644
--- a/Main/Component/UI/Effect/EllipseMask.cs
+++ b/Main/Component/UI/Effect/EllipseMask.cs
@@ -23,6 +23,8 @@
private Image m_MaskImage;
private RectTransform m_RectTransform;
private List<Graphic> m_MaskedChildren = new List<Graphic>();
+ // 缂撳瓨GetComponentsInChildren缁撴灉锛岄伩鍏嶆瘡娆nEnable鍒嗛厤鏁扮粍
+ private static List<Graphic> _graphicCacheList = new List<Graphic>();
public Vector2 EllipseCenter
{
@@ -228,10 +230,12 @@
// 娓呴櫎涔嬪墠鐨勫垪琛�
m_MaskedChildren.Clear();
- // 鑾峰彇鎵�鏈夊瓙瀵硅薄鐨凣raphic缁勪欢
- Graphic[] childrenGraphics = GetComponentsInChildren<Graphic>();
- foreach (var graphic in childrenGraphics)
+ // 浣跨敤闈欐�佺紦瀛樺垪琛ㄩ伩鍏嶆瘡娆″垎閰嶆暟缁�
+ _graphicCacheList.Clear();
+ GetComponentsInChildren(false, _graphicCacheList);
+ for (int i = 0; i < _graphicCacheList.Count; i++)
{
+ var graphic = _graphicCacheList[i];
// 璺宠繃閬僵鏈韩
if (graphic.gameObject == this.gameObject)
continue;
@@ -240,6 +244,7 @@
CreateChildMaskMaterial(graphic);
m_MaskedChildren.Add(graphic);
}
+ _graphicCacheList.Clear();
}
/// <summary>
--
Gitblit v1.8.0