From 84fba9533cc9a0f1a3400bbc3f9a36cca94a1fbc Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 26 十二月 2025 18:30:16 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.1.20:10010/r/Project_SG_scripts
---
Main/Component/UI/Core/OutlineEx.cs | 226 ++++++++++++++++++++++++++++----------------------------
1 files changed, 113 insertions(+), 113 deletions(-)
diff --git a/Main/Component/UI/Core/OutlineEx.cs b/Main/Component/UI/Core/OutlineEx.cs
index 62ef5c2..e37e4b9 100644
--- a/Main/Component/UI/Core/OutlineEx.cs
+++ b/Main/Component/UI/Core/OutlineEx.cs
@@ -41,9 +41,9 @@
private static List<UIVertex> m_VetexList = new List<UIVertex>();
- protected override void Awake()
+ protected override void Start()
{
- base.Awake();
+ base.Start();
if (base.graphic)
{
@@ -137,135 +137,135 @@
}
-public override void ModifyMesh(VertexHelper vh)
+ public override void ModifyMesh(VertexHelper vh)
+ {
+ vh.GetUIVertexStream(m_VetexList);
+
+ this._ProcessVertices();
+
+ vh.Clear();
+ vh.AddUIVertexTriangleStream(m_VetexList);
+ }
+
+
+ private void _ProcessVertices()
+ {
+ for (int i = 0, count = m_VetexList.Count - 3; i <= count; i += 3)
{
- vh.GetUIVertexStream(m_VetexList);
-
- this._ProcessVertices();
-
- vh.Clear();
- vh.AddUIVertexTriangleStream(m_VetexList);
- }
-
-
- private void _ProcessVertices()
- {
- for (int i = 0, count = m_VetexList.Count - 3; i <= count; i += 3)
+ var v1 = m_VetexList[i];
+ var v2 = m_VetexList[i + 1];
+ var v3 = m_VetexList[i + 2];
+ // 璁$畻鍘熼《鐐瑰潗鏍囦腑蹇冪偣
+ //
+ var minX = _Min(v1.position.x, v2.position.x, v3.position.x);
+ var minY = _Min(v1.position.y, v2.position.y, v3.position.y);
+ var maxX = _Max(v1.position.x, v2.position.x, v3.position.x);
+ var maxY = _Max(v1.position.y, v2.position.y, v3.position.y);
+ var posCenter = new Vector2(minX + maxX, minY + maxY) * 0.5f;
+ // 璁$畻鍘熷椤剁偣鍧愭爣鍜孶V鐨勬柟鍚�
+ //
+ Vector2 triX, triY, uvX, uvY;
+ Vector2 pos1 = v1.position;
+ Vector2 pos2 = v2.position;
+ Vector2 pos3 = v3.position;
+ if (Mathf.Abs(Vector2.Dot((pos2 - pos1).normalized, Vector2.right))
+ > Mathf.Abs(Vector2.Dot((pos3 - pos2).normalized, Vector2.right)))
{
- var v1 = m_VetexList[i];
- var v2 = m_VetexList[i + 1];
- var v3 = m_VetexList[i + 2];
- // 璁$畻鍘熼《鐐瑰潗鏍囦腑蹇冪偣
- //
- var minX = _Min(v1.position.x, v2.position.x, v3.position.x);
- var minY = _Min(v1.position.y, v2.position.y, v3.position.y);
- var maxX = _Max(v1.position.x, v2.position.x, v3.position.x);
- var maxY = _Max(v1.position.y, v2.position.y, v3.position.y);
- var posCenter = new Vector2(minX + maxX, minY + maxY) * 0.5f;
- // 璁$畻鍘熷椤剁偣鍧愭爣鍜孶V鐨勬柟鍚�
- //
- Vector2 triX, triY, uvX, uvY;
- Vector2 pos1 = v1.position;
- Vector2 pos2 = v2.position;
- Vector2 pos3 = v3.position;
- if (Mathf.Abs(Vector2.Dot((pos2 - pos1).normalized, Vector2.right))
- > Mathf.Abs(Vector2.Dot((pos3 - pos2).normalized, Vector2.right)))
- {
- triX = pos2 - pos1;
- triY = pos3 - pos2;
- uvX = v2.uv0 - v1.uv0;
- uvY = v3.uv0 - v2.uv0;
- }
- else
- {
- triX = pos3 - pos2;
- triY = pos2 - pos1;
- uvX = v3.uv0 - v2.uv0;
- uvY = v2.uv0 - v1.uv0;
- }
- // 璁$畻鍘熷UV妗�
- var uvMin = _Min(v1.uv0, v2.uv0, v3.uv0);
- var uvMax = _Max(v1.uv0, v2.uv0, v3.uv0);
- //OutlineColor 鍜� OutlineWidth 涔熶紶鍏ワ紝閬垮厤鍑虹幇涓嶅悓鐨勬潗璐ㄧ悆
- var col_rg = new Vector2(OutlineColor.r, OutlineColor.g); //鎻忚竟棰滆壊 鐢╱v3 鍜� tangent鐨� zw浼犻��
- var col_ba = new Vector4(0,0,OutlineColor.b, OutlineColor.a);
- var normal = new Vector3(0, 0, OutlineWidth); //鎻忚竟鐨勫搴� 鐢╪ormal鐨剒浼犻��
-
- // 涓烘瘡涓《鐐硅缃柊鐨凱osition鍜孶V锛屽苟浼犲叆鍘熷UV妗�
- v1 = _SetNewPosAndUV(v1, this.OutlineWidth, posCenter, triX, triY, uvX, uvY, uvMin, uvMax);
- v1.uv3 = col_rg;
- v1.tangent = col_ba;
- v1.normal = normal;
- v2 = _SetNewPosAndUV(v2, this.OutlineWidth, posCenter, triX, triY, uvX, uvY, uvMin, uvMax);
- v2.uv3 = col_rg;
- v2.tangent = col_ba;
- v2.normal = normal;
- v3 = _SetNewPosAndUV(v3, this.OutlineWidth, posCenter, triX, triY, uvX, uvY, uvMin, uvMax);
- v3.uv3 = col_rg;
- v3.tangent = col_ba;
- v3.normal = normal;
-
-
- // 搴旂敤璁剧疆鍚庣殑UIVertex
- //
- m_VetexList[i] = v1;
- m_VetexList[i + 1] = v2;
- m_VetexList[i + 2] = v3;
+ triX = pos2 - pos1;
+ triY = pos3 - pos2;
+ uvX = v2.uv0 - v1.uv0;
+ uvY = v3.uv0 - v2.uv0;
}
+ else
+ {
+ triX = pos3 - pos2;
+ triY = pos2 - pos1;
+ uvX = v3.uv0 - v2.uv0;
+ uvY = v2.uv0 - v1.uv0;
+ }
+ // 璁$畻鍘熷UV妗�
+ var uvMin = _Min(v1.uv0, v2.uv0, v3.uv0);
+ var uvMax = _Max(v1.uv0, v2.uv0, v3.uv0);
+ //OutlineColor 鍜� OutlineWidth 涔熶紶鍏ワ紝閬垮厤鍑虹幇涓嶅悓鐨勬潗璐ㄧ悆
+ var col_rg = new Vector2(OutlineColor.r, OutlineColor.g); //鎻忚竟棰滆壊 鐢╱v3 鍜� tangent鐨� zw浼犻��
+ var col_ba = new Vector4(0,0,OutlineColor.b, OutlineColor.a);
+ var normal = new Vector3(0, 0, OutlineWidth); //鎻忚竟鐨勫搴� 鐢╪ormal鐨剒浼犻��
+
+ // 涓烘瘡涓《鐐硅缃柊鐨凱osition鍜孶V锛屽苟浼犲叆鍘熷UV妗�
+ v1 = _SetNewPosAndUV(v1, this.OutlineWidth, posCenter, triX, triY, uvX, uvY, uvMin, uvMax);
+ v1.uv3 = col_rg;
+ v1.tangent = col_ba;
+ v1.normal = normal;
+ v2 = _SetNewPosAndUV(v2, this.OutlineWidth, posCenter, triX, triY, uvX, uvY, uvMin, uvMax);
+ v2.uv3 = col_rg;
+ v2.tangent = col_ba;
+ v2.normal = normal;
+ v3 = _SetNewPosAndUV(v3, this.OutlineWidth, posCenter, triX, triY, uvX, uvY, uvMin, uvMax);
+ v3.uv3 = col_rg;
+ v3.tangent = col_ba;
+ v3.normal = normal;
+
+
+ // 搴旂敤璁剧疆鍚庣殑UIVertex
+ //
+ m_VetexList[i] = v1;
+ m_VetexList[i + 1] = v2;
+ m_VetexList[i + 2] = v3;
}
+ }
- private static UIVertex _SetNewPosAndUV(UIVertex pVertex, int pOutLineWidth,
- Vector2 pPosCenter,
- Vector2 pTriangleX, Vector2 pTriangleY,
- Vector2 pUVX, Vector2 pUVY,
- Vector2 pUVOriginMin, Vector2 pUVOriginMax)
- {
- // Position
- var pos = pVertex.position;
- var posXOffset = pos.x > pPosCenter.x ? pOutLineWidth : -pOutLineWidth;
- var posYOffset = pos.y > pPosCenter.y ? pOutLineWidth : -pOutLineWidth;
- pos.x += posXOffset;
- pos.y += posYOffset;
- pVertex.position = pos;
- // UV
- var uv = pVertex.uv0;
+ private static UIVertex _SetNewPosAndUV(UIVertex pVertex, int pOutLineWidth,
+ Vector2 pPosCenter,
+ Vector2 pTriangleX, Vector2 pTriangleY,
+ Vector2 pUVX, Vector2 pUVY,
+ Vector2 pUVOriginMin, Vector2 pUVOriginMax)
+ {
+ // Position
+ var pos = pVertex.position;
+ var posXOffset = pos.x > pPosCenter.x ? pOutLineWidth : -pOutLineWidth;
+ var posYOffset = pos.y > pPosCenter.y ? pOutLineWidth : -pOutLineWidth;
+ pos.x += posXOffset;
+ pos.y += posYOffset;
+ pVertex.position = pos;
+ // UV
+ var uv = pVertex.uv0;
- uv += new Vector4((pUVX / pTriangleX.magnitude * posXOffset * (Vector2.Dot(pTriangleX, Vector2.right) > 0 ? 1 : -1)).x, (pUVX / pTriangleX.magnitude * posXOffset * (Vector2.Dot(pTriangleX, Vector2.right) > 0 ? 1 : -1)).y, 0, 0);
- uv += new Vector4((pUVY / pTriangleY.magnitude * posYOffset * (Vector2.Dot(pTriangleY, Vector2.up) > 0 ? 1 : -1)).x, (pUVY / pTriangleY.magnitude * posYOffset * (Vector2.Dot(pTriangleY, Vector2.up) > 0 ? 1 : -1)).y, 0, 0);
-
- pVertex.uv0 = uv;
+ uv += new Vector4((pUVX / pTriangleX.magnitude * posXOffset * (Vector2.Dot(pTriangleX, Vector2.right) > 0 ? 1 : -1)).x, (pUVX / pTriangleX.magnitude * posXOffset * (Vector2.Dot(pTriangleX, Vector2.right) > 0 ? 1 : -1)).y, 0, 0);
+ uv += new Vector4((pUVY / pTriangleY.magnitude * posYOffset * (Vector2.Dot(pTriangleY, Vector2.up) > 0 ? 1 : -1)).x, (pUVY / pTriangleY.magnitude * posYOffset * (Vector2.Dot(pTriangleY, Vector2.up) > 0 ? 1 : -1)).y, 0, 0);
+
+ pVertex.uv0 = uv;
- pVertex.uv1 = pUVOriginMin; //uv1 uv2 鍙敤 tangent normal 鍦ㄧ缉鏀炬儏鍐� 浼氭湁闂
- pVertex.uv2 = pUVOriginMax;
+ pVertex.uv1 = pUVOriginMin; //uv1 uv2 鍙敤 tangent normal 鍦ㄧ缉鏀炬儏鍐� 浼氭湁闂
+ pVertex.uv2 = pUVOriginMax;
- return pVertex;
- }
+ return pVertex;
+ }
- private static float _Min(float pA, float pB, float pC)
- {
- return Mathf.Min(Mathf.Min(pA, pB), pC);
- }
+ private static float _Min(float pA, float pB, float pC)
+ {
+ return Mathf.Min(Mathf.Min(pA, pB), pC);
+ }
- private static float _Max(float pA, float pB, float pC)
- {
- return Mathf.Max(Mathf.Max(pA, pB), pC);
- }
+ private static float _Max(float pA, float pB, float pC)
+ {
+ return Mathf.Max(Mathf.Max(pA, pB), pC);
+ }
- private static Vector2 _Min(Vector2 pA, Vector2 pB, Vector2 pC)
- {
- return new Vector2(_Min(pA.x, pB.x, pC.x), _Min(pA.y, pB.y, pC.y));
- }
+ private static Vector2 _Min(Vector2 pA, Vector2 pB, Vector2 pC)
+ {
+ return new Vector2(_Min(pA.x, pB.x, pC.x), _Min(pA.y, pB.y, pC.y));
+ }
- private static Vector2 _Max(Vector2 pA, Vector2 pB, Vector2 pC)
- {
- return new Vector2(_Max(pA.x, pB.x, pC.x), _Max(pA.y, pB.y, pC.y));
- }
+ private static Vector2 _Max(Vector2 pA, Vector2 pB, Vector2 pC)
+ {
+ return new Vector2(_Max(pA.x, pB.x, pC.x), _Max(pA.y, pB.y, pC.y));
+ }
}
\ No newline at end of file
--
Gitblit v1.8.0