summaryrefslogtreecommitdiff
path: root/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/uGUI-2017.1/UnityEngine.UI/UI/Core')
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics/Graphic.cs9
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics/GraphicRegistry.cs2
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/SpecializedCollections/IndexedSet.cs2
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/VertexHelper.cs19
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/IMeshModifier.cs13
5 files changed, 28 insertions, 17 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()
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/SpecializedCollections/IndexedSet.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/SpecializedCollections/IndexedSet.cs
index a968577..0f37983 100644
--- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/SpecializedCollections/IndexedSet.cs
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/SpecializedCollections/IndexedSet.cs
@@ -115,7 +115,7 @@ namespace UnityEngine.UI.Collections
T item = m_List[index];
m_Dictionary.Remove(item);
m_List[index] = value;
- m_Dictionary.Add(item, index);
+ m_Dictionary.Add(item, index); // 这里有问题,应该是value
}
}
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/VertexHelper.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/VertexHelper.cs
index f7e35cd..3020d4d 100644
--- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/VertexHelper.cs
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Utility/VertexHelper.cs
@@ -5,15 +5,16 @@ namespace UnityEngine.UI
{
public class VertexHelper : IDisposable
{
- private List<Vector3> m_Positions = ListPool<Vector3>.Get();
- private List<Color32> m_Colors = ListPool<Color32>.Get();
- private List<Vector2> m_Uv0S = ListPool<Vector2>.Get();
- private List<Vector2> m_Uv1S = ListPool<Vector2>.Get();
- private List<Vector2> m_Uv2S = ListPool<Vector2>.Get();
- private List<Vector2> m_Uv3S = ListPool<Vector2>.Get();
- private List<Vector3> m_Normals = ListPool<Vector3>.Get();
- private List<Vector4> m_Tangents = ListPool<Vector4>.Get();
- private List<int> m_Indices = ListPool<int>.Get();
+ //c 改成public方便看
+ /*private*/ public List<Vector3> m_Positions = ListPool<Vector3>.Get();
+ /*private*/ public List<Color32> m_Colors = ListPool<Color32>.Get();
+ /*private*/ public List<Vector2> m_Uv0S = ListPool<Vector2>.Get();
+ /*private*/ public List<Vector2> m_Uv1S = ListPool<Vector2>.Get();
+ /*private*/ public List<Vector2> m_Uv2S = ListPool<Vector2>.Get();
+ /*private*/ public List<Vector2> m_Uv3S = ListPool<Vector2>.Get();
+ /*private*/ public List<Vector3> m_Normals = ListPool<Vector3>.Get();
+ /*private*/ public List<Vector4> m_Tangents = ListPool<Vector4>.Get();
+ /*private*/ public List<int> m_Indices = ListPool<int>.Get();
private static readonly Vector4 s_DefaultTangent = new Vector4(1.0f, 0.0f, 0.0f, -1.0f);
private static readonly Vector3 s_DefaultNormal = Vector3.back;
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/IMeshModifier.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/IMeshModifier.cs
index a12505c..582a820 100644
--- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/IMeshModifier.cs
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/IMeshModifier.cs
@@ -3,12 +3,13 @@ using System.Collections.Generic;
namespace UnityEngine.UI
{
- [Obsolete("Use IMeshModifier instead", true)]
- public interface IVertexModifier
- {
- [Obsolete("use IMeshModifier.ModifyMesh (VertexHelper verts) instead", true)]
- void ModifyVertices(List<UIVertex> verts);
- }
+
+ //[Obsolete("Use IMeshModifier instead", true)]
+ //public interface IVertexModifier
+ //{
+ // [Obsolete("use IMeshModifier.ModifyMesh (VertexHelper verts) instead", true)]
+ // void ModifyVertices(List<UIVertex> verts);
+ //}
public interface IMeshModifier
{