- // OnPopulateMesh
- if (this.FontToUse == null || this.m_DisableFontTextureChangedCallback) {
- return;
- }
- this.m_DisableFontTextureChangedCallback = true;
- Rect rect = base.rectTransform.rect;
- base.cachedTextGenerator.Populate(this.PostprocessText(), this.GetGenerationSettings(rect.size));
- Vector2 textAnchorPivot = Text.GetTextAnchorPivot(base.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 lhs = base.PixelAdjustPoint(zero) - zero;
- base.cachedTextGenerator.GetVertices(this.m_UIVertices);
- float d = 1f / this.pixelsPerUnit;
- if (this.m_UIVertices.Count > 0) {
- this.m_UIVertices.RemoveRange(this.m_UIVertices.Count - 4, 4);
- }
- if (lhs != Vector2.zero) {
- for (int i = 0; i < this.m_UIVertices.Count; i++) {
- UIVertex value = this.m_UIVertices[i];
- value.position *= d;
- value.position.x = value.position.x + lhs.x;
- value.position.y = value.position.y + lhs.y;
- this.m_UIVertices[i] = value;
- }
- } else {
- for (int j = 0; j < this.m_UIVertices.Count; j++) {
- UIVertex value = this.m_UIVertices[j];
- value.position *= d;
- this.m_UIVertices[j] = value;
- }
- }