spacepaste

  1.  
  2. // OnPopulateMesh
  3. if (this.FontToUse == null || this.m_DisableFontTextureChangedCallback) {
  4. return;
  5. }
  6. this.m_DisableFontTextureChangedCallback = true;
  7. Rect rect = base.rectTransform.rect;
  8. base.cachedTextGenerator.Populate(this.PostprocessText(), this.GetGenerationSettings(rect.size));
  9. Vector2 textAnchorPivot = Text.GetTextAnchorPivot(base.alignment);
  10. Vector2 zero = Vector2.zero;
  11. zero.x = Mathf.Lerp(rect.xMin, rect.xMax, textAnchorPivot.x);
  12. zero.y = Mathf.Lerp(rect.yMin, rect.yMax, textAnchorPivot.y);
  13. Vector2 lhs = base.PixelAdjustPoint(zero) - zero;
  14. base.cachedTextGenerator.GetVertices(this.m_UIVertices);
  15. float d = 1f / this.pixelsPerUnit;
  16. if (this.m_UIVertices.Count > 0) {
  17. this.m_UIVertices.RemoveRange(this.m_UIVertices.Count - 4, 4);
  18. }
  19. if (lhs != Vector2.zero) {
  20. for (int i = 0; i < this.m_UIVertices.Count; i++) {
  21. UIVertex value = this.m_UIVertices[i];
  22. value.position *= d;
  23. value.position.x = value.position.x + lhs.x;
  24. value.position.y = value.position.y + lhs.y;
  25. this.m_UIVertices[i] = value;
  26. }
  27. } else {
  28. for (int j = 0; j < this.m_UIVertices.Count; j++) {
  29. UIVertex value = this.m_UIVertices[j];
  30. value.position *= d;
  31. this.m_UIVertices[j] = value;
  32. }
  33. }
  34.