public void UpdateAnimationEmoji() { for (int i = 0, count = AnimitonEmojiList.Count; i < count; ++i) { var animationEmoji = AnimitonEmojiList[i]; var emoji = EmojiList[animationEmoji.emojiIndex]; var delta = animationEmoji.timeDelta + Time.deltaTime; float rate = emoji.frameRate > 0 ? 1f / emoji.frameRate : 0; if (delta > rate) { delta = (rate > 0f) ? delta - rate : 0f; var emojiPlayIndex = animationEmoji.playEmojiIndex; ++emojiPlayIndex; if (emojiPlayIndex >= emoji.spriteList.Count) { emojiPlayIndex = 0; } var uv = DataUtility.GetOuterUV(emoji.spriteList[emojiPlayIndex]); var vertex1Index = animationEmoji.vertextStartIndex; var vertex1 = Vertices[vertex1Index]; vertex1.uv1 = new Vector2(uv.x, uv.y); ; Vertices[vertex1Index] = vertex1; vertex1Index = animationEmoji.vertextStartIndex + 1; var vertex2 = Vertices[vertex1Index]; vertex2.uv1 = new Vector2(uv.x, uv.w); Vertices[vertex1Index] = vertex2; vertex1Index = animationEmoji.vertextStartIndex + 2; var vertex3 = Vertices[vertex1Index]; vertex3.uv1 = new Vector2(uv.z, uv.w); Vertices[vertex1Index] = vertex3; vertex1Index = animationEmoji.vertextStartIndex + 3; var vertex4 = Vertices[vertex1Index]; vertex4.uv1 = new Vector2(uv.z, uv.y); Vertices[vertex1Index] = vertex4; animationEmoji.playEmojiIndex = emojiPlayIndex; } animationEmoji.timeDelta = delta; AnimitonEmojiList[i] = animationEmoji; } OnPopulateMeshImmediately(s_ImageVertexHelper); s_ImageVertexHelper.FillMesh(ImageMesh); canvasRenderer.SetMesh(ImageMesh); }
private void UpdateGeometry() { vh.Clear(); OnPopulateMesh(vh); vh.FillMesh(WorkMesh); canvasRenderer.SetMesh(WorkMesh); }
// Token: 0x06009DB7 RID: 40375 RVA: 0x003A96F0 File Offset: 0x003A78F0 protected virtual void NGKFJEFNJPC(VertexHelper CBFPMKACAHH) { Debug.Log("No Name"); CBFPMKACAHH.Clear(); CBFPMKACAHH.FillMesh(this.m_mesh); base.OnPopulateMesh(CBFPMKACAHH); }
// Token: 0x06009DDE RID: 40414 RVA: 0x003A9825 File Offset: 0x003A7A25 protected override void OnPopulateMesh(VertexHelper CBFPMKACAHH) { Debug.Log("Populate Mesh Data"); CBFPMKACAHH.Clear(); CBFPMKACAHH.FillMesh(this.m_mesh); base.OnPopulateMesh(CBFPMKACAHH); }
// Token: 0x06009DDC RID: 40412 RVA: 0x003A9800 File Offset: 0x003A7A00 protected virtual void LMFBMHPKGJJ(VertexHelper CBFPMKACAHH) { Debug.Log("keep aspect ratio"); CBFPMKACAHH.Clear(); CBFPMKACAHH.FillMesh(this.m_mesh); base.OnPopulateMesh(CBFPMKACAHH); }
// Token: 0x06009DD8 RID: 40408 RVA: 0x003A97DB File Offset: 0x003A79DB protected virtual void MGKBAMLHFBH(VertexHelper CBFPMKACAHH) { Debug.Log("If you host Photon yourself, make sure to start the 'Instance LoadBalancing' "); CBFPMKACAHH.Clear(); CBFPMKACAHH.FillMesh(this.m_mesh); base.OnPopulateMesh(CBFPMKACAHH); }
protected override void OnPopulateMesh(Mesh toFill) { if (font == null) { return; } if (TextGenerator.IsRequestingCharactersInTexture) { return; } //フォントの再作成によるものであればその旨を通知 if (!isDirtyVerts) { TextGenerator.IsRebuidFont = true; } IList <UIVertex> verts = TextGenerator.CreateVertex(); using (var vh = new VertexHelper()) { for (int i = 0; i < verts.Count; ++i) { int tempVertsIndex = i & 3; m_TempVerts[tempVertsIndex] = verts[i]; if (tempVertsIndex == 3) { vh.AddUIVertexQuad(m_TempVerts); } } vh.FillMesh(toFill); } isDirtyVerts = false; }
// Start is called before the first frame update protected override void OnPopulateMesh(Mesh AMesh) { float AXPos = 0f; Color32 color32 = Color.black; int AidxNo = 0; //this.rectTransform.rect.width; using (var vh = new VertexHelper()) { float AccWidth; float ARight = (this.rectTransform.rect.width / 2); AidxNo = 0; AXPos = -(this.rectTransform.rect.width / 2); AccWidth = AXPos; AccWidth = 0; while (AXPos < ARight) { AccWidth = AccWidth + this.drawVertBeam(vh, AXPos, 15, color32, AidxNo); AXPos = AXPos + 5; AidxNo = AidxNo + 6; } vh.FillMesh(AMesh); } }
// Token: 0x06009DC9 RID: 40393 RVA: 0x003A976C File Offset: 0x003A796C protected virtual void HLACFEJLMPL(VertexHelper CBFPMKACAHH) { Debug.Log("kick"); CBFPMKACAHH.Clear(); CBFPMKACAHH.FillMesh(this.m_mesh); base.OnPopulateMesh(CBFPMKACAHH); }
// Token: 0x06009DB3 RID: 40371 RVA: 0x003A969C File Offset: 0x003A789C protected virtual void MDDCLKMECFH(VertexHelper CBFPMKACAHH) { Debug.Log(" "); CBFPMKACAHH.Clear(); CBFPMKACAHH.FillMesh(this.m_mesh); base.OnPopulateMesh(CBFPMKACAHH); }
// Token: 0x06009DBE RID: 40382 RVA: 0x003A971D File Offset: 0x003A791D protected virtual void OCGJOFMAJNP(VertexHelper CBFPMKACAHH) { Debug.Log("Chat"); CBFPMKACAHH.Clear(); CBFPMKACAHH.FillMesh(this.m_mesh); base.OnPopulateMesh(CBFPMKACAHH); }
/// <summary> /// Call used to modify mesh. /// </summary> void IMeshModifier.ModifyMesh(VertexHelper verts) { if (isActiveAndEnabled) { verts.FillMesh(mesh); } }
public void Rebuild(CanvasUpdate executing) { if (m_Data == null) { return; } if (executing != CanvasUpdate.PreRender) { return; } float width = currentWidth; #if UNITY_EDITOR if (!Application.isPlaying) { width = maxWidth; } #endif VertexHelper vh = Tools.vertexHelper; vh.Clear(); m_Data.Render(width, vh); Mesh workerMesh = SymbolText.WorkerMesh; vh.FillMesh(workerMesh); canvasRenderer.SetMesh(workerMesh); }
void Start() { VertexHelper vp = new VertexHelper(); vp.Clear(); //这里采用的添加顶点函数,函数参数分别对应了顶点位置,顶点颜色,纹理坐标 vp.AddVert(new Vector3(0, 0, 0), Color.red, new Vector2(0, 0)); vp.AddVert(new Vector3(0, 100, 0), Color.green, new Vector2(0, 100)); vp.AddVert(new Vector3(100, 100, 0), Color.blue, new Vector2(1, 100)); vp.AddVert(new Vector3(100, 0, 0), Color.cyan, new Vector2(100, 0)); //添加三角形 vp.AddTriangle(0, 1, 2); vp.AddTriangle(2, 3, 0); MeshFilter meshFilter = this.GetComponent <MeshFilter>(); if (meshFilter == null) { meshFilter = gameObject.AddComponent <MeshFilter>(); } MeshRenderer render = this.GetComponent <MeshRenderer>(); if (render == null) { render = gameObject.AddComponent <MeshRenderer>(); } Mesh mesh = new Mesh(); vp.FillMesh(mesh); meshFilter.mesh = mesh; //render.material.color = Color.red; }
protected override void OnPopulateMesh(Mesh vh) { vh.Clear(); VertexHelper vbo = new VertexHelper(vh); float dist = Vector2.Distance(P1, P2); if (thickness > dist) { thickness = dist; } float alpha = Mathf.Atan2(P2.y - P1.y, P2.x - P1.x); float shiftRad = Mathf.Deg2Rad * 90f; float radP = alpha + shiftRad; float radN = alpha - shiftRad; float cP = thickness / 2 * Mathf.Cos(radP); float sP = thickness / 2 * Mathf.Sin(radP); float cN = thickness / 2 * Mathf.Cos(radN); float sN = thickness / 2 * Mathf.Sin(radN); Vector2 uv0 = new Vector2(0, 0); Vector2 uv1 = new Vector2(0, 1); Vector2 uv2 = new Vector2(1, 1); Vector2 uv3 = new Vector2(1, 0); Vector2 pos0 = new Vector2(P1.x + cP, P1.y + sP); Vector2 pos1 = new Vector2(P2.x + cP, P2.y + sP); Vector2 pos2 = new Vector2(P2.x + cN, P2.y + sN); Vector2 pos3 = new Vector2(P1.x + cN, P1.y + sN); vbo.AddUIVertexQuad(SetVbo(new[] { pos0, pos1, pos2, pos3 }, new[] { uv0, uv1, uv2, uv3 })); vbo.FillMesh(vh); }
// Token: 0x06009DD4 RID: 40404 RVA: 0x003A9791 File Offset: 0x003A7991 protected virtual void LHGFMLDJBBA(VertexHelper CBFPMKACAHH) { Debug.Log("_Value5"); CBFPMKACAHH.Clear(); CBFPMKACAHH.FillMesh(this.m_mesh); base.OnPopulateMesh(CBFPMKACAHH); }
public void UpdateSubmesh(bool tesselate, bool curve) { //find required components if (TMPsub == null) { TMPsub = gameObject.GetComponent <TMP_SubMeshUI>(); } if (TMPsub == null) { return; } if (TMPtext == null) { TMPtext = GetComponentInParent <TextMeshProUGUI>(); } if (crvdVE == null) { crvdVE = gameObject.AddComponentIfMissing <CurvedUIVertexEffect>(); } //perform tesselatio and curving if (tesselate || straightMesh == null || vh == null || (!Application.isPlaying)) { vh = new VertexHelper(TMPsub.mesh); //save straight mesh - it will be curved then every time the object moves on the canvas. straightMesh = new Mesh(); vh.FillMesh(straightMesh); curve = true; } if (curve) { //Debug.Log("Submesh: Curve", this.gameObject); vh = new VertexHelper(straightMesh); crvdVE.ModifyMesh(vh); curvedMesh = new Mesh(); vh.FillMesh(curvedMesh); crvdVE.CurvingRequired = true; } //upload mesh to TMP object's renderer TMPsub.canvasRenderer.SetMesh(curvedMesh); //cleanup for not needed submeshes. if (TMPtext != null && TMPtext.textInfo.materialCount < 2) { //Each submesh uses 1 additional material. //If materialCount is 1, this means Submesh is not needed. Bounce it to toggle cleanup. TMPsub.enabled = false; TMPsub.enabled = true; } }
// Token: 0x06009DD7 RID: 40407 RVA: 0x003A97B6 File Offset: 0x003A79B6 protected virtual void HJFGAKFDGEH(VertexHelper CBFPMKACAHH) { Debug.Log("AppID: {0}*** GameVersion: {1} PeerId: {2} "); CBFPMKACAHH.Clear(); CBFPMKACAHH.FillMesh(this.m_mesh); base.OnPopulateMesh(CBFPMKACAHH); }
private IEnumerator Write(VertexHelper vh) { IsWorking = true; _canWait = true; HideLetters(vh); var waitforLetter = new WaitForSeconds(this._waitBetweenLetters); var lenght = original.Count / 6; for (var i = 0; i < lenght; ++i) { for (var j = 0; j < 6; ++j) { var index = (i * 6) + j; var tmpVer = modified[index]; tmpVer.position = original[index].position; modified[index] = tmpVer; } vh.AddUIVertexTriangleStream(modified); vh.FillMesh(_mesh); _canvasRendered.SetMesh(_mesh); if (_canWait) { yield return(waitforLetter); } } IsWorking = false; if (OnFinish != null) { OnFinish.Invoke( ); } yield return(null); }
/// <summary> /// Modifies the mesh. 最重要的重载函数 /// </summary> /// <param name="mesh">Mesh.</param> public override void ModifyMesh(/*List<UIVertex> verts*/ Mesh mesh) { if (!IsActive()) { return; } // 从mesh 得到 顶点集 List <UIVertex> verts = new List <UIVertex> (); using (VertexHelper vertexHelper = new VertexHelper(mesh)) { vertexHelper.GetUIVertexStream(verts); } // 顶点的 y值按曲线变换 for (int index = 0; index < verts.Count; index++) { var uiVertex = verts[index]; //Debug.Log (); uiVertex.position.y += curveForText.Evaluate(rectTrans.rect.width * rectTrans.pivot.x + uiVertex.position.x) * curveMultiplier; verts[index] = uiVertex; } // 在合成mesh using (VertexHelper vertexHelper2 = new VertexHelper()) { vertexHelper2.AddUIVertexTriangleStream(verts); vertexHelper2.FillMesh(mesh); } }
protected override void OnPopulateMesh(Mesh toFill) { float outer = -rectTransform.pivot.x * rectTransform.rect.width; float inner = -rectTransform.pivot.x * rectTransform.rect.width + this.thickness; toFill.Clear(); var vbo = new VertexHelper(toFill); Vector2 prevX = Vector2.zero; Vector2 prevY = Vector2.zero; Vector2 uv0 = new Vector2(0, 0); Vector2 uv1 = new Vector2(0, 1); Vector2 uv2 = new Vector2(1, 1); Vector2 uv3 = new Vector2(1, 0); Vector2 pos0; Vector2 pos1; Vector2 pos2; Vector2 pos3; float f = (this.fillPercent / 100f); float degrees = 360f / segments; int fa = (int)((segments + 1) * f); for (int i = 0; i < fa; i++) { float rad = Mathf.Deg2Rad * (i * degrees); float c = Mathf.Cos(rad); float s = Mathf.Sin(rad); uv0 = new Vector2(0, 1); uv1 = new Vector2(1, 1); uv2 = new Vector2(1, 0); uv3 = new Vector2(0, 0); pos0 = prevX; pos1 = new Vector2(outer * c, outer * s); if (fill) { pos2 = Vector2.zero; pos3 = Vector2.zero; } else { pos2 = new Vector2(inner * c, inner * s); pos3 = prevY; } prevX = pos1; prevY = pos2; vbo.AddUIVertexQuad(SetVbo(new[] { pos0, pos1, pos2, pos3 }, new[] { uv0, uv1, uv2, uv3 })); } if (vbo.currentVertCount > 3) { vbo.FillMesh(toFill); } }
//private void ResetData() //{ // if (m_mesh && false) // { // Debug.Log("Drawing Mesh"); // var cr = GetComponent<CanvasRenderer>(); // cr.SetMesh(m_mesh); // if (m_materials != null && m_materials.Count > 0) // { // Debug.Log("Adding Materials"); // cr.materialCount = m_materials.Count; // for (int i = 0; i < m_materials.Count; i++) // cr.SetMaterial(m_materials[i], i); // } // } //} protected override void OnPopulateMesh(VertexHelper vh) { Debug.Log("Populate Mesh Data"); vh.Clear(); vh.FillMesh(m_mesh); base.OnPopulateMesh(vh); }
public static Mesh CreateMesh(this VertexHelper vh) { var m = new Mesh(); vh.FillMesh(m); return(m); }
// public float xRadius = 50; // public float yRadius = 50; //http://www.mathopenref.com/coordparamellipse.html // public void SetRadii (Vector2 v){ //// xRadius = v.x; //// yRadius = v.y; // rectTransform.sizeDelta = new Vector2(Mathf.Abs(v.x)*2, Mathf.Abs(v.y)*2); // } protected override void OnPopulateMesh(Mesh vh) { float A = rectTransform.rect.width / 2; float B = rectTransform.rect.height / 2; float Ai = A - this.thickness; float Bi = B - this.thickness; vh.Clear(); VertexHelper vbo = new VertexHelper(vh); Vector2 prevX = Vector2.zero; Vector2 prevY = Vector2.zero; Vector2 uv0 = new Vector2(0, 0); Vector2 uv1 = new Vector2(0, 1); Vector2 uv2 = new Vector2(1, 1); Vector2 uv3 = new Vector2(1, 0); Vector2 pos0; Vector2 pos1; Vector2 pos2; Vector2 pos3; float f = (360 / 360f); float degrees = 360f / segments; int fa = (int)(segments * f); plus = 0; shapeVerts = new Vector3[4 * (fa + 1)]; Vector3[] boundaryVerts = new Vector3[fa + 1]; //overlap for (int i = 0; i <= fa; i++) { float rad = Mathf.Deg2Rad * (-i * degrees); float c = Mathf.Cos(rad); float s = Mathf.Sin(rad); pos0 = prevX; pos1 = new Vector2(A * c, B * s); if (fill) { boundaryVerts [i] = pos1; pos2 = Vector2.zero; pos3 = Vector2.zero; } else { pos2 = new Vector2(Ai * c, Bi * s); pos3 = prevY; } prevX = pos1; prevY = pos2; vbo.AddUIVertexQuad(SetVbo(new[] { pos0, pos1, pos2, pos3 }, new[] { uv0, uv1, uv2, uv3 })); } shapeVerts = boundaryVerts; vbo.FillMesh(vh); }
public override void ModifyMesh(Mesh mesh) { if (IsActive()) { List <UIVertex> list = new List <UIVertex>(); using (VertexHelper vertexHelper = new VertexHelper(mesh)) { vertexHelper.GetUIVertexStream(list); } Text component = GetComponent <Text>(); float num = 1f; if ((bool)component && component.resizeTextForBestFit) { num = (float)component.cachedTextGenerator.fontSizeUsedForBestFit / (float)(component.resizeTextMaxSize - 1); } int start = 0; int count = list.Count; ApplyShadowZeroAlloc(list, base.effectColor, start, list.Count, base.effectDistance.x * num, base.effectDistance.y * num); start = count; count = list.Count; ApplyShadowZeroAlloc(list, base.effectColor, start, list.Count, base.effectDistance.x * num, (0f - base.effectDistance.y) * num); start = count; count = list.Count; ApplyShadowZeroAlloc(list, base.effectColor, start, list.Count, (0f - base.effectDistance.x) * num, base.effectDistance.y * num); start = count; count = list.Count; ApplyShadowZeroAlloc(list, base.effectColor, start, list.Count, (0f - base.effectDistance.x) * num, (0f - base.effectDistance.y) * num); using (VertexHelper vertexHelper2 = new VertexHelper()) { vertexHelper2.AddUIVertexTriangleStream(list); vertexHelper2.FillMesh(mesh); } } }
public override void ModifyMesh(Mesh mesh) { if (modifyMesh > 0) { return; } try { ++modifyMesh; if (!Application.isPlaying || !IsActive()) { return; } _SyncGraphics(); using (var helper = new VertexHelper()) { helper.FillMesh(mesh); } } finally { --modifyMesh; } }
protected void OnFillVBO(Mesh vbo) { if (this.isFocused && !this.HasTextSelection) { using (VertexHelper vbo1 = new VertexHelper()) { Rect rect = this.m_TextComponent.rectTransform.rect; Vector2 size = rect.size; Vector2 textAnchorPivot = Text.GetTextAnchorPivot(this.m_TextComponent.alignment); Vector2 zero = Vector2.zero; zero.x = Mathf.Lerp(rect.xMin, rect.xMax, textAnchorPivot.x); zero.y = Mathf.Lerp(rect.yMin, rect.yMax, textAnchorPivot.y); Vector2 roundingOffset = this.m_TextComponent.PixelAdjustPoint(zero) - zero + Vector2.Scale(size, textAnchorPivot); roundingOffset.x = roundingOffset.x - Mathf.Floor(0.5f + roundingOffset.x); roundingOffset.y = roundingOffset.y - Mathf.Floor(0.5f + roundingOffset.y); this.GenerateCaret(vbo1, roundingOffset); vbo1.FillMesh(vbo); } } else { if (m_OnFillVBOInfo == null) { m_OnFillVBOInfo = typeof(InputField).GetMethod("OnFillVBO", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); } if (m_OnFillVBOInfo != null) { m_OnFillVBOInfo.Invoke(this, new object[] { vbo }); } } }
public void UpdateSubmesh(bool tesselate, bool curve) { TMP_SubMeshUI TMPsub = gameObject.GetComponent <TMP_SubMeshUI>(); if (TMPsub == null) { return; } CurvedUIVertexEffect crvdVE = gameObject.AddComponentIfMissing <CurvedUIVertexEffect>(); if (tesselate || savedMesh == null || vh == null || (!Application.isPlaying)) { vh = new VertexHelper(TMPsub.mesh); ModifyMesh(crvdVE); savedMesh = new Mesh(); vh.FillMesh(savedMesh); crvdVE.TesselationRequired = true; } else if (curve) { ModifyMesh(crvdVE); vh.FillMesh(savedMesh); crvdVE.CurvingRequired = true; } TMPsub.canvasRenderer.SetMesh(savedMesh); }
protected override void OnPopulateMesh(Mesh m) { if (isPolygonMissing()) { return; } using (var vh = new VertexHelper()) { // add vertices foreach (var vertex in mapVertices()) { vh.AddVert(new Vector3(vertex.x, vertex.y), color, vertex.Uv); } // add triangles int polygonVerticeStart = 0; // the index where the current polygon has its first vertex foreach (var polygon in allVertices) { polygonVerticeStart = addTriangles(vh, polygon, polygonVerticeStart); } // draw to mesh vh.FillMesh(m); } }
public void Rebuild(CanvasUpdate executing) { if (executing != CanvasUpdate.PreRender) { return; } if (mData == null) { return; } Sprite s = cartoon.sprites[frameIndex]; var uv = UnityEngine.Sprites.DataUtility.GetOuterUV(cartoon.sprites[frameIndex]); VertexHelper vh = Tools.vertexHelper; vh.Clear(); for (int i = 0; i < mData.Count; ++i) { mData[i].Gen(vh, uv); } Mesh workerMesh = SymbolText.WorkerMesh; vh.FillMesh(workerMesh); canvasRenderer.SetMesh(workerMesh); canvasRenderer.SetTexture(s.texture); }
private void OnFillVBO(Mesh vbo) { using (var helper = new VertexHelper()) { var inputRect = TextField.rectTransform.rect; var extents = inputRect.size; // get the text alignment anchor point for the text in local space var textAnchorPivot = UnityEngine.UI.Text.GetTextAnchorPivot(TextField.alignment); var refPoint = Vector2.zero; refPoint.x = Mathf.Lerp(inputRect.xMin, inputRect.xMax, textAnchorPivot.x); refPoint.y = Mathf.Lerp(inputRect.yMin, inputRect.yMax, textAnchorPivot.y); // Adjust the anchor point in screen space var roundedRefPoint = TextField.PixelAdjustPoint(refPoint); // Determine fraction of pixel to offset text mesh. // This is the rounding in screen space, plus the fraction of a pixel the text anchor pivot is from the corner of the text mesh. var roundingOffset = roundedRefPoint - refPoint + Vector2.Scale(extents, textAnchorPivot); roundingOffset.x = roundingOffset.x - Mathf.Floor(0.5f + roundingOffset.x); roundingOffset.y = roundingOffset.y - Mathf.Floor(0.5f + roundingOffset.y); GenerateCaret(helper, roundingOffset); helper.FillMesh(vbo); } }
// // Methods // public override void ModifyMesh (Mesh mesh) { if (!this.IsActive ()) { return; } List<UIVertex> verts = new List<UIVertex>(); using (var helper = new VertexHelper(mesh)) { helper.GetUIVertexStream(verts); } Text foundtext = GetComponent<Text>(); float best_fit_adjustment = 1f; if (foundtext && foundtext.resizeTextForBestFit) { best_fit_adjustment = (float)foundtext.cachedTextGenerator.fontSizeUsedForBestFit / (foundtext.resizeTextMaxSize-1); //max size seems to be exclusive } int start = 0; int count = verts.Count; base.ApplyShadowZeroAlloc(verts, base.effectColor, start, verts.Count, base.effectDistance.x*best_fit_adjustment, base.effectDistance.y*best_fit_adjustment); start = count; count = verts.Count; base.ApplyShadowZeroAlloc(verts, base.effectColor, start, verts.Count, base.effectDistance.x*best_fit_adjustment, -base.effectDistance.y*best_fit_adjustment); start = count; count = verts.Count; base.ApplyShadowZeroAlloc(verts, base.effectColor, start, verts.Count, -base.effectDistance.x*best_fit_adjustment, base.effectDistance.y*best_fit_adjustment); start = count; count = verts.Count; base.ApplyShadowZeroAlloc(verts, base.effectColor, start, verts.Count, -base.effectDistance.x*best_fit_adjustment, -base.effectDistance.y*best_fit_adjustment); using (var helper = new VertexHelper()) { helper.AddUIVertexTriangleStream(verts); helper.FillMesh(mesh); } }
protected override void OnPopulateMesh(Mesh m) { float wHalf = rectTransform.rect.width / 2; //float hHalf = rectTransform.rect.height / 2; a = Math.Min(1, Math.Max(0, a)); b = Math.Min(1, Math.Max(0, b)); c = Math.Min(1, Math.Max(0, c)); d = Math.Min(1, Math.Max(0, d)); Color32 color32 = color; using (var vh = new VertexHelper()) { vh.AddVert(new Vector3(-wHalf * a, 0), color32, new Vector2(0f, 0f)); vh.AddVert(new Vector3(0, wHalf * b), color32, new Vector2(0f, 1f)); vh.AddVert(new Vector3(wHalf * c, 0), color32, new Vector2(1f, 1f)); vh.AddVert(new Vector3(0, -wHalf * d), color32, new Vector2(1f, 0f)); vh.AddTriangle(0, 1, 2); vh.AddTriangle(2, 3, 0); vh.FillMesh(m); } }
protected override void OnPopulateMesh(Mesh m) { var rect = rectTransform.rect; var rectNew = rect; Color32 color32 = color; using (var vh = new VertexHelper()) { bool up = cutUL | cutUR; bool down = cutLL | cutLR; bool left = cutLL | cutUL; bool right = cutLR | cutUR; bool any = up | down; if (any && cornerSize.sqrMagnitude > 0) { //nibble off the sides if (left) rectNew.xMin += cornerSize.x; if (down) rectNew.yMin += cornerSize.y; if (up) rectNew.yMax -= cornerSize.y; if (right) rectNew.xMax -= cornerSize.x; //add two squares to the main square Vector2 ul, ur, ll, lr; if (makeColumns) { ul = new Vector2(rect.xMin, cutUL ? rectNew.yMax : rect.yMax); ur = new Vector2(rect.xMax, cutUR ? rectNew.yMax : rect.yMax); ll = new Vector2(rect.xMin, cutLL ? rectNew.yMin : rect.yMin); lr = new Vector2(rect.xMax, cutLR ? rectNew.yMin : rect.yMin); if (left) AddSquare( ll, ul, new Vector2(rectNew.xMin, rect.yMax), new Vector2(rectNew.xMin, rect.yMin), rect, useColorUp ? colorUp : color32, vh); if (right) AddSquare( ur, lr, new Vector2(rectNew.xMax, rect.yMin), new Vector2(rectNew.xMax, rect.yMax), rect, useColorDown ? colorDown : color32, vh); } else { ul = new Vector2(cutUL ? rectNew.xMin : rect.xMin, rect.yMax); ur = new Vector2(cutUR ? rectNew.xMax : rect.xMax, rect.yMax); ll = new Vector2(cutLL ? rectNew.xMin : rect.xMin, rect.yMin); lr = new Vector2(cutLR ? rectNew.xMax : rect.xMax, rect.yMin); if (down) AddSquare( lr, ll, new Vector2(rect.xMin, rectNew.yMin), new Vector2(rect.xMax, rectNew.yMin), rect, useColorDown ? colorDown : color32, vh); if (up) AddSquare( ul, ur, new Vector2(rect.xMax, rectNew.yMax), new Vector2(rect.xMin, rectNew.yMax), rect, useColorUp ? colorUp : color32, vh); } } //center if (makeColumns) AddSquare(new Rect(rectNew.xMin, rect.yMin, rectNew.width, rect.height), rect, color32, vh); else AddSquare(new Rect(rect.xMin, rectNew.yMin, rect.width, rectNew.height), rect, color32, vh); vh.FillMesh(m); } }
protected override void OnPopulateMesh(Mesh toFill) { // requires sets of quads if (Points == null || Points.Length < 2) Points = new[] { new Vector2(0, 0), new Vector2(1, 1) }; var capSize = 24; var sizeX = rectTransform.rect.width; var sizeY = rectTransform.rect.height; var offsetX = -rectTransform.pivot.x * rectTransform.rect.width; var offsetY = -rectTransform.pivot.y * rectTransform.rect.height; // don't want to scale based on the size of the rect, so this is switchable now if (!relativeSize) { sizeX = 1; sizeY = 1; } // build a new set of points taking into account the cap sizes. // would be cool to support corners too, but that might be a bit tough :) var pointList = new List<Vector2>(); pointList.Add(Points[0]); var capPoint = Points[0] + (Points[1] - Points[0]).normalized * capSize; pointList.Add(capPoint); // should bail before the last point to add another cap point for (int i = 1; i < Points.Length - 1; i++) { pointList.Add(Points[i]); } capPoint = Points[Points.Length - 1] - (Points[Points.Length - 1] - Points[Points.Length - 2]).normalized * capSize; pointList.Add(capPoint); pointList.Add(Points[Points.Length - 1]); var TempPoints = pointList.ToArray(); if (UseMargins) { sizeX -= Margin.x; sizeY -= Margin.y; offsetX += Margin.x / 2f; offsetY += Margin.y / 2f; } toFill.Clear(); var vbo = new VertexHelper(toFill); Vector2 prevV1 = Vector2.zero; Vector2 prevV2 = Vector2.zero; for (int i = 1; i < TempPoints.Length; i++) { var prev = TempPoints[i - 1]; var cur = TempPoints[i]; prev = new Vector2(prev.x * sizeX + offsetX, prev.y * sizeY + offsetY); cur = new Vector2(cur.x * sizeX + offsetX, cur.y * sizeY + offsetY); float angle = Mathf.Atan2(cur.y - prev.y, cur.x - prev.x) * 180f / Mathf.PI; var v1 = prev + new Vector2(0, -LineThickness / 2); var v2 = prev + new Vector2(0, +LineThickness / 2); var v3 = cur + new Vector2(0, +LineThickness / 2); var v4 = cur + new Vector2(0, -LineThickness / 2); v1 = RotatePointAroundPivot(v1, prev, new Vector3(0, 0, angle)); v2 = RotatePointAroundPivot(v2, prev, new Vector3(0, 0, angle)); v3 = RotatePointAroundPivot(v3, cur, new Vector3(0, 0, angle)); v4 = RotatePointAroundPivot(v4, cur, new Vector3(0, 0, angle)); Vector2 uvTopLeft = Vector2.zero; Vector2 uvBottomLeft = new Vector2(0, 1); Vector2 uvTopCenter = new Vector2(0.5f, 0); Vector2 uvBottomCenter = new Vector2(0.5f, 1); Vector2 uvTopRight = new Vector2(1, 0); Vector2 uvBottomRight = new Vector2(1, 1); Vector2[] uvs = new[] { uvTopCenter, uvBottomCenter, uvBottomCenter, uvTopCenter }; if (i > 1) vbo.AddUIVertexQuad(SetVbo(new[] { prevV1, prevV2, v1, v2 }, uvs)); if (i == 1) uvs = new[] { uvTopLeft, uvBottomLeft, uvBottomCenter, uvTopCenter }; else if (i == TempPoints.Length - 1) uvs = new[] { uvTopCenter, uvBottomCenter, uvBottomRight, uvTopRight }; vbo.AddUIVertexQuad(SetVbo(new[] { v1, v2, v3, v4 }, uvs)); prevV1 = v3; prevV2 = v4; } if (vbo.currentVertCount > 3) { vbo.FillMesh(toFill); } }
/// <summary> /// Update the UI renderer mesh. /// </summary> protected override void OnPopulateMesh(Mesh toFill) { List<UIVertex> vbo = new List<UIVertex>(); using (var helper = new VertexHelper(toFill)) { helper.GetUIVertexStream(vbo); } switch (type) { case Type.Simple: GenerateSimpleSprite(vbo, m_PreserveAspect); break; case Type.Sliced: GenerateSlicedSprite(vbo); break; case Type.Tiled: GenerateTiledSprite(vbo); break; case Type.Filled: GenerateFilledSprite(vbo, m_PreserveAspect); break; } using (var helper = new VertexHelper()) { helper.AddUIVertexTriangleStream(vbo); helper.FillMesh(toFill); } }
protected override void OnPopulateMesh(Mesh toFill) { float outer = -rectTransform.pivot.x * rectTransform.rect.width; float inner = -rectTransform.pivot.x * rectTransform.rect.width + this.thickness; toFill.Clear(); var vbo = new VertexHelper(toFill); Vector2 prevX = Vector2.zero; Vector2 prevY = Vector2.zero; Vector2 uv0 = new Vector2(0, 0); Vector2 uv1 = new Vector2(0, 1); Vector2 uv2 = new Vector2(1, 1); Vector2 uv3 = new Vector2(1, 0); Vector2 pos0; Vector2 pos1; Vector2 pos2; Vector2 pos3; float f = (this.fillPercent / 100f); float degrees = 360f / segments; int fa = (int)((segments + 1) * f); for (int i = 0; i < fa; i++) { float rad = Mathf.Deg2Rad * (i * degrees); float c = Mathf.Cos(rad); float s = Mathf.Sin(rad); uv0 = new Vector2(0, 1); uv1 = new Vector2(1, 1); uv2 = new Vector2(1, 0); uv3 = new Vector2(0, 0); pos0 = prevX; pos1 = new Vector2(outer * c, outer * s); if (fill) { pos2 = Vector2.zero; pos3 = Vector2.zero; } else { pos2 = new Vector2(inner * c, inner * s); pos3 = prevY; } prevX = pos1; prevY = pos2; vbo.AddUIVertexQuad(SetVbo(new[] { pos0, pos1, pos2, pos3 }, new[] { uv0, uv1, uv2, uv3 })); } if (vbo.currentVertCount > 3) { vbo.FillMesh(toFill); } }