TMP_SpriteGlyph.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.TextCore;
  4. namespace TMPro
  5. {
  6. /// <summary>
  7. /// The visual representation of the sprite character using this glyph.
  8. /// </summary>
  9. [Serializable]
  10. public class TMP_SpriteGlyph : Glyph
  11. {
  12. /// <summary>
  13. /// An optional reference to the underlying sprite used to create this glyph.
  14. /// </summary>
  15. public Sprite sprite;
  16. // ********************
  17. // CONSTRUCTORS
  18. // ********************
  19. public TMP_SpriteGlyph() { }
  20. /// <summary>
  21. /// Constructor for new sprite glyph.
  22. /// </summary>
  23. /// <param name="index">Index of the sprite glyph.</param>
  24. /// <param name="metrics">Metrics which define the position of the glyph in the context of text layout.</param>
  25. /// <param name="glyphRect">GlyphRect which defines the coordinates of the glyph in the atlas texture.</param>
  26. /// <param name="scale">Scale of the glyph.</param>
  27. /// <param name="atlasIndex">Index of the atlas texture that contains the glyph.</param>
  28. public TMP_SpriteGlyph(uint index, GlyphMetrics metrics, GlyphRect glyphRect, float scale, int atlasIndex)
  29. {
  30. this.index = index;
  31. this.metrics = metrics;
  32. this.glyphRect = glyphRect;
  33. this.scale = scale;
  34. this.atlasIndex = atlasIndex;
  35. }
  36. /// <summary>
  37. /// Constructor for new sprite glyph.
  38. /// </summary>
  39. /// <param name="index">>Index of the sprite glyph.</param>
  40. /// <param name="metrics">Metrics which define the position of the glyph in the context of text layout.</param>
  41. /// <param name="glyphRect">GlyphRect which defines the coordinates of the glyph in the atlas texture.</param>
  42. /// <param name="scale">Scale of the glyph.</param>
  43. /// <param name="atlasIndex">Index of the atlas texture that contains the glyph.</param>
  44. /// <param name="sprite">A reference to the Unity Sprite representing this sprite glyph.</param>
  45. public TMP_SpriteGlyph(uint index, GlyphMetrics metrics, GlyphRect glyphRect, float scale, int atlasIndex, Sprite sprite)
  46. {
  47. this.index = index;
  48. this.metrics = metrics;
  49. this.glyphRect = glyphRect;
  50. this.scale = scale;
  51. this.atlasIndex = atlasIndex;
  52. this.sprite = sprite;
  53. }
  54. }
  55. }