From b357a6a6d914e46c2c782f215e9f566f92663850 Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 9 Apr 2021 20:37:24 +0800 Subject: *UI effect --- Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics/Graphic.cs | 9 ++++++++- .../UnityEngine.UI/UI/Core/Graphics/GraphicRegistry.cs | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics') diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics/Graphic.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics/Graphic.cs index 1ded27a..53cc1bd 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics/Graphic.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics/Graphic.cs @@ -177,9 +177,11 @@ namespace UnityEngine.UI } } + // 找到父节点中最近的canvas private void CacheCanvas() { var list = ListPool.Get(); + // 找到所有父节点中所有canvas,从里到外 gameObject.GetComponentsInParent(false, list); if (list.Count > 0) { @@ -235,10 +237,14 @@ namespace UnityEngine.UI } } + /// + /// 提交到CanvasRenderer用这个,要应用IMaterialModifier的修改结果 + /// public virtual Material materialForRendering { get { + // 在这里调用IMaterialModifier的修改 var components = ListPool.Get(); GetComponents(typeof(IMaterialModifier), components); @@ -380,7 +386,7 @@ namespace UnityEngine.UI private void DoMeshGeneration() { if (rectTransform != null && rectTransform.rect.width >= 0 && rectTransform.rect.height >= 0) - OnPopulateMesh(s_VertexHelper); + OnPopulateMesh(s_VertexHelper); // 填充vertexHelper else s_VertexHelper.Clear(); // clear the vertex helper so invalid graphics dont draw. @@ -394,6 +400,7 @@ namespace UnityEngine.UI ListPool.Release(components); s_VertexHelper.FillMesh(workerMesh); + // 传入canvasRenderer作为mesh canvasRenderer.SetMesh(workerMesh); } diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics/GraphicRegistry.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics/GraphicRegistry.cs index ca7eddf..0642792 100644 --- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics/GraphicRegistry.cs +++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics/GraphicRegistry.cs @@ -3,10 +3,12 @@ using UnityEngine.UI.Collections; namespace UnityEngine.UI { + // 游戏中只有一份单例 public class GraphicRegistry { private static GraphicRegistry s_Instance; + // 按Canvas分类统计Graphic private readonly Dictionary> m_Graphics = new Dictionary>(); protected GraphicRegistry() -- cgit v1.1-26-g67d0