diff options
Diffstat (limited to 'Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics')
-rw-r--r-- | Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics/Graphic.cs | 9 | ||||
-rw-r--r-- | Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics/GraphicRegistry.cs | 2 |
2 files changed, 10 insertions, 1 deletions
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<Canvas>.Get(); + // 找到所有父节点中所有canvas,从里到外 gameObject.GetComponentsInParent(false, list); if (list.Count > 0) { @@ -235,10 +237,14 @@ namespace UnityEngine.UI } } + /// <summary>
+ /// 提交到CanvasRenderer用这个,要应用IMaterialModifier的修改结果
+ /// </summary> public virtual Material materialForRendering { get { + // 在这里调用IMaterialModifier的修改 var components = ListPool<Component>.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<Component>.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<Canvas, IndexedSet<Graphic>> m_Graphics = new Dictionary<Canvas, IndexedSet<Graphic>>(); protected GraphicRegistry() |