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/CanvasUpdateRegistry.cs2
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/Clipping.cs1
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics/Graphic.cs2
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics/MaskableGraphic.cs6
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Mask/RectMask2D.cs7
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/Shadow.cs3
6 files changed, 15 insertions, 6 deletions
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs
index d03d0e7..200b4e5 100644
--- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs
@@ -150,7 +150,7 @@ namespace UnityEngine.UI
instance.m_LayoutRebuildQueue.Clear();
m_PerformingLayoutUpdate = false;
- // 做剔除(裁剪)
+ // 做剔除+裁剪
// now layout is complete do culling...
ClipperRegistry.instance.Cull();
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/Clipping.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/Clipping.cs
index 7707ecf..7dd39bf 100644
--- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/Clipping.cs
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/Clipping.cs
@@ -29,6 +29,7 @@ namespace UnityEngine.UI
return new Rect(point1.x, point1.y, point2.x - point1.x, point2.y - point1.y);
}
+ // 计算矩形交集
private static Rect RectIntersect(Rect a, Rect b)
{
float xMin = Mathf.Max(a.x, b.x);
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 53cc1bd..e0d70f3 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
@@ -367,7 +367,7 @@ namespace UnityEngine.UI
canvasRenderer.materialCount = 1;
canvasRenderer.SetMaterial(materialForRendering, 0);
- canvasRenderer.SetTexture(mainTexture);
+ canvasRenderer.SetTexture(mainTexture); // 设置_MainTex,会覆盖材质上设置的_MainTex
}
//c 顶点重建
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics/MaskableGraphic.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics/MaskableGraphic.cs
index 4995dc1..51e2fe2 100644
--- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics/MaskableGraphic.cs
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Graphics/MaskableGraphic.cs
@@ -101,15 +101,15 @@ namespace UnityEngine.UI
{
UISystemProfilerApi.AddMarker("MaskableGraphic.cullingChanged", this);
m_OnCullStateChanged.Invoke(cull);
- SetVerticesDirty();
+ SetVerticesDirty(); // 这里需要更新一下canvasRenderer的网格数据
}
}
public virtual void SetClipRect(Rect clipRect, bool validRect)
{
if (validRect)
- canvasRenderer.EnableRectClipping(clipRect);
- else
+ canvasRenderer.EnableRectClipping(clipRect);
+ else
canvasRenderer.DisableRectClipping();
}
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Mask/RectMask2D.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Mask/RectMask2D.cs
index 87d2dbf..5f8f2e7 100644
--- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Mask/RectMask2D.cs
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Mask/RectMask2D.cs
@@ -22,6 +22,7 @@ namespace UnityEngine.UI
[NonSerialized]
private bool m_ShouldRecalculateClipRects;
+ // 父节点的所有RectMask2D,用来算交集
[NonSerialized]
private List<RectMask2D> m_Clippers = new List<RectMask2D>();
@@ -101,7 +102,7 @@ namespace UnityEngine.UI
public virtual void PerformClipping()
{
//TODO See if an IsActive() test would work well here or whether it might cause unexpected side effects (re case 776771)
-
+
// if the parents are changed
// or something similar we
// do a recalculate here
@@ -111,6 +112,8 @@ namespace UnityEngine.UI
m_ShouldRecalculateClipRects = false;
}
+ // 裁剪
+
// get the compound rects from
// the clippers that are valid
bool validRect = true;
@@ -125,6 +128,8 @@ namespace UnityEngine.UI
m_LastValidClipRect = validRect;
}
+ // 剔除
+
foreach (IClippable clipTarget in m_ClipTargets)
{
var maskable = clipTarget as MaskableGraphic;
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/Shadow.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/Shadow.cs
index c0b7cfb..e0a813c 100644
--- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/Shadow.cs
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/VertexModifiers/Shadow.cs
@@ -76,6 +76,7 @@ namespace UnityEngine.UI
}
}
+ //x,y是偏移量
protected void ApplyShadowZeroAlloc(List<UIVertex> verts, Color32 color, int start, int end, float x, float y)
{
UIVertex vt;
@@ -93,9 +94,11 @@ namespace UnityEngine.UI
v.x += x;
v.y += y;
vt.position = v;
+
var newColor = color;
if (m_UseGraphicAlpha)
newColor.a = (byte)((newColor.a * verts[i].color.a) / 255);
+
vt.color = newColor;
verts[i] = vt;
}