yyl
2026-04-03 99a11d2bb19d74f6cc8584ac16838062af4fb301
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结果,避免每次OnEnable分配数组
    private static List<Graphic> _graphicCacheList = new List<Graphic>();
    public Vector2 EllipseCenter
    {
@@ -228,10 +230,12 @@
        // 清除之前的列表
        m_MaskedChildren.Clear();
        
        // 获取所有子对象的Graphic组件
        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>