static StackObject *AddUIVertexTriangleStream_13(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Collections.Generic.List <UnityEngine.UIVertex> @verts = (System.Collections.Generic.List <UnityEngine.UIVertex>) typeof(System.Collections.Generic.List <UnityEngine.UIVertex>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.UI.VertexHelper instance_of_this_method = (UnityEngine.UI.VertexHelper) typeof(UnityEngine.UI.VertexHelper).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.AddUIVertexTriangleStream(@verts); return(__ret); }
protected override void OnPopulateMesh(UnityEngine.UI.VertexHelper vh) { if (buffer.modified) { buffer.modified = false; vh.Clear(); int count = rectangleCount * 4; List <UIVertex> vertices = new List <UIVertex>(); for (int i = 0; i < count; i += 4) { vertices.Add(buffer.vertices[i + 0]); vertices.Add(buffer.vertices[i + 1]); vertices.Add(buffer.vertices[i + 2]); vertices.Add(buffer.vertices[i + 2]); vertices.Add(buffer.vertices[i + 3]); vertices.Add(buffer.vertices[i + 0]); } vh.AddUIVertexTriangleStream(vertices); } }
static int _m_AddUIVertexTriangleStream(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.UI.VertexHelper __cl_gen_to_be_invoked = (UnityEngine.UI.VertexHelper)translator.FastGetCSObj(L, 1); try { { System.Collections.Generic.List <UnityEngine.UIVertex> verts = (System.Collections.Generic.List <UnityEngine.UIVertex>)translator.GetObject(L, 2, typeof(System.Collections.Generic.List <UnityEngine.UIVertex>)); __cl_gen_to_be_invoked.AddUIVertexTriangleStream(verts); return(0); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
protected override void OnPopulateMesh(UnityEngine.UI.VertexHelper vh) { base.OnPopulateMesh(vh); var verts = ListPool <UnityEngine.UIVertex> .Get(); vh.GetUIVertexStream(verts); var spriteTagCount = spriteTagList.Count; for (int i = 0; i < spriteTagCount; ++i) { var spriteTag = spriteTagList[i]; spriteTag.active = true; var vertStart = spriteTag.index * 6; if (vertStart >= verts.Count) { spriteTag.active = false; continue; } var posLT = verts[vertStart].position; var posRB = verts[vertStart + 2].position; spriteTag.position = (posLT + posRB) * 0.5f; for (int j = 0; j < 6; ++j) { int index = spriteTag.index * 6 + j; var vert = verts[index]; vert.uv0 = Vector2.zero; vert.color = new Color(0, 0, 0, 0); verts[index] = vert; } spriteTagList[i] = spriteTag; } spriteTagChanged = true; vh.Clear(); vh.AddUIVertexTriangleStream(verts); verts.ReleaseToPool(); }
public override void ModifyMesh(UnityEngine.UI.VertexHelper helper) { var verts = ListPool <UIVertex> .Get(); if (m_image == null) { return; } helper.GetUIVertexStream(verts); int count = verts.Count; var shapeCount = m_image.fillCenter ? 9 : 8; if (count < shapeCount * 6 || m_image.overrideSprite == null) { return; } helper.Clear(); var overrideSprite = m_image.overrideSprite; var border = overrideSprite.border; var spriteSize = overrideSprite.rect.size; float tileWidth = (spriteSize.x - border.x - border.z) / m_image.pixelsPerUnit; float tileHeight = (spriteSize.y - border.y - border.w) / m_image.pixelsPerUnit; for (int i = 0; i < shapeCount; ++i) { var leftTopUV = verts[6 * i + 1].uv0; var rightBottomUV = verts[6 * i + 4].uv0; var rectBorder = verts[6 * i + 4].position - verts[6 * i + 1].position; rectBorder = new Vector3(Mathf.Abs(rectBorder.x), Mathf.Abs(rectBorder.y), Mathf.Abs(rectBorder.z)); bool bTileVertical = m_image.fillCenter ? (IsBorderTileVertical && (i == 1 || i == 7) || IsCenterTileVertical && i == 4) : IsBorderTileVertical && (i == 1 || i == 6); bool bTileHorizontal = m_image.fillCenter ? (IsBorderTileHorizontal && (i == 3 || i == 5) || IsCenterTileHorizontal && i == 4) : IsBorderTileHorizontal && (i == 3 || i == 4); for (int j = 0; j < 6; ++j) { var index = 6 * i + j; var vert = verts[index]; var uv1 = Vector2.zero; if (bTileVertical && tileHeight != 0) { uv1.y = (tileHeight == 0 ? 0f : rectBorder.y / tileHeight); } if (bTileHorizontal && tileWidth != 0) { uv1.x = (tileWidth == 0 ? 0f : rectBorder.x / tileWidth); } vert.uv1 = uv1; var tangent = m_image.rectTransform.InverseTransformDirection(leftTopUV.x, leftTopUV.y, rightBottomUV.x); vert.tangent = new Vector4(tangent.x, tangent.y, tangent.z, rightBottomUV.y); if (m_changeBorderColor && !(m_image.fillCenter && i == 4)) { vert.color *= m_borderColor; } if (m_changeCenterColor && (m_image.fillCenter && i == 4)) { if (j == 0 || j == 5) { vert.color = vert.color * m_customCenterColor[0]; } else if (j == 1) { vert.color = vert.color * m_customCenterColor[1]; } else if (j == 2 || j == 3) { vert.color = vert.color * m_customCenterColor[2]; } else if (j == 4) { vert.color = vert.color * m_customCenterColor[3]; } } verts[index] = vert; } } helper.Clear(); helper.AddUIVertexTriangleStream(verts); verts.ReleaseToPool(); }
public override void ModifyMesh(UnityEngine.UI.VertexHelper helper) { var verts = ListPool <UIVertex> .Get(); if (m_image == null) { return; } helper.GetUIVertexStream(verts); int count = verts.Count; var shapeCount = m_image.fillCenter ? 9 : 8; if (count < shapeCount * 6 || m_image.overrideSprite == null) { return; } helper.Clear(); var overrideSprite = m_image.overrideSprite; var border = overrideSprite.border; var spriteSize = overrideSprite.rect.size; float tileWidth = (spriteSize.x - border.x - border.z) / m_image.pixelsPerUnit; float tileHeight = (spriteSize.y - border.y - border.w) / m_image.pixelsPerUnit; for (int i = 0; i < shapeCount; ++i) { var leftTopUV = verts[6 * i + 1].uv0; var rightBottomUV = verts[6 * i + 4].uv0; leftTopUV = new Vector2((int)(leftTopUV.x * 10000), (int)(leftTopUV.y * 10000)); rightBottomUV = new Vector2((int)(rightBottomUV.x * 10000), (int)(rightBottomUV.y * 10000)); var rectBorder = verts[6 * i + 4].position - verts[6 * i + 1].position; rectBorder = new Vector3(Mathf.Abs(rectBorder.x), Mathf.Abs(rectBorder.y), Mathf.Abs(rectBorder.z)); bool bTileVertical = m_image.fillCenter ? (IsBorderTileVertical && (i == 1 || i == 7) || IsCenterTileVertical && i == 4) : IsBorderTileVertical && (i == 1 || i == 6); bool bTileHorizontal = m_image.fillCenter ? (IsBorderTileHorizontal && (i == 3 || i == 5) || IsCenterTileHorizontal && i == 4) : IsBorderTileHorizontal && (i == 3 || i == 4); for (int j = 0; j < 6; ++j) { var index = 6 * i + j; var vert = verts[index]; var uv0 = vert.uv0; var uv1 = Vector2.zero; if (bTileVertical && tileHeight != 0) { uv1.y = ((tileHeight == 0 || tileHeight >= rectBorder.y) ? 1f : tileHeight / rectBorder.y); } if (bTileHorizontal && tileWidth != 0) { uv1.x = ((tileWidth == 0 || tileWidth >= rectBorder.x) ? 1f : tileWidth / rectBorder.x); } uv0 *= 0.5f; uv0.x += (uv0.x * leftTopUV.x) < 0 ? -leftTopUV.x : leftTopUV.x; uv0.y += (uv0.y * leftTopUV.y) < 0 ? -leftTopUV.y : leftTopUV.y; uv1 *= 0.5f; uv1.x += rightBottomUV.x < 0 ? -rightBottomUV.x : rightBottomUV.x; uv1.y += rightBottomUV.y < 0 ? -rightBottomUV.y : rightBottomUV.y; vert.uv0 = uv0; vert.uv1 = uv1; if (m_changeBorderColor && !(m_image.fillCenter && i == 4)) { vert.color *= m_borderColor; } if (m_changeCenterColor && (m_image.fillCenter && i == 4)) { if (j == 0 || j == 5) { vert.color = vert.color * m_customCenterColor[0]; } else if (j == 1) { vert.color = vert.color * m_customCenterColor[1]; } else if (j == 2 || j == 3) { vert.color = vert.color * m_customCenterColor[2]; } else if (j == 4) { vert.color = vert.color * m_customCenterColor[3]; } } verts[index] = vert; } } helper.Clear(); helper.AddUIVertexTriangleStream(verts); verts.ReleaseToPool(); }
/// <summary> /// Modifies the mesh. /// </summary> /// <param name="vh">Vertex buffer object.</param> public override void ModifyMesh(UnityEngine.UI.VertexHelper vh) #endif { if (!IsActive()) { return; } using (ListPool <UIVertex> .Scope uiVertices = new ListPool <UIVertex> .Scope()) { #if IS_VBO_UI_VERTEX int count = vertices.Count; #else #if IS_VBO_MESH using (UnityEngine.UI.VertexHelper vh = new UnityEngine.UI.VertexHelper(mesh)) { vh.GetUIVertexStream(uiVertices.List); } #else vh.GetUIVertexStream(uiVertices.List); #endif int count = uiVertices.List.Count; #endif if (count == 0) { return; } float yMin = this.graphic.rectTransform.rect.yMin; float yMax = this.graphic.rectTransform.rect.yMax; switch (m_FillMode) { case GradientFillMode.PerQuad: #if IS_VBO_UI_VERTEX for (int i = 0; i < count; i += 4) { ApplyTint(vertices, i, m_TopColor); ApplyTint(vertices, i + 1, m_TopColor); ApplyTint(vertices, i + 2, m_BottomColor); ApplyTint(vertices, i + 3, m_BottomColor); } #else for (int i = 0; i < count; i += 6) { ApplyTint(uiVertices.List, i, m_TopColor); ApplyTint(uiVertices.List, i + 1, m_TopColor); ApplyTint(uiVertices.List, i + 2, m_BottomColor); ApplyTint(uiVertices.List, i + 3, m_BottomColor); ApplyTint(uiVertices.List, i + 4, m_BottomColor); ApplyTint(uiVertices.List, i + 5, m_TopColor); } #if IS_VBO_MESH using (UnityEngine.UI.VertexHelper vh = new UnityEngine.UI.VertexHelper()) { vh.AddUIVertexTriangleStream(uiVertices.List); vh.FillMesh(mesh); } #else vh.Clear(); vh.AddUIVertexTriangleStream(uiVertices.List); #endif #endif return; case GradientFillMode.GeometryBounds: yMin = uiVertices.List[0].position.y; yMax = uiVertices.List[0].position.y; for (int i = 1; i < count; i++) { float y = uiVertices.List[i].position.y; if (y > yMax) { yMax = y; } if (y < yMin) { yMin = y; } } break; } float div = 1f / (yMax - yMin); #if IS_VBO_UI_VERTEX for (int i = 0; i < count; ++i) { ApplyTint( vertices, i, Color32.Lerp(m_TopColor, m_BottomColor, (yMax - uiVertices.List[i].position.y) * div) ); } #else for (int i = 0; i < count; ++i) { ApplyTint( uiVertices.List, i, Color32.Lerp(m_TopColor, m_BottomColor, (yMax - uiVertices.List[i].position.y) * div) ); } #if IS_VBO_MESH using (UnityEngine.UI.VertexHelper vh = new UnityEngine.UI.VertexHelper()) { vh.AddUIVertexTriangleStream(uiVertices.List); vh.FillMesh(mesh); } #else vh.Clear(); vh.AddUIVertexTriangleStream(uiVertices.List); #endif #endif } }