TMP_Character.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using UnityEngine.TextCore;
  3. namespace TMPro
  4. {
  5. /// <summary>
  6. /// A basic element of text.
  7. /// </summary>
  8. [Serializable]
  9. public class TMP_Character : TMP_TextElement
  10. {
  11. /// <summary>
  12. /// Default constructor.
  13. /// </summary>
  14. public TMP_Character()
  15. {
  16. m_ElementType = TextElementType.Character;
  17. this.scale = 1.0f;
  18. }
  19. /// <summary>
  20. /// Constructor for new character
  21. /// </summary>
  22. /// <param name="unicode">Unicode value.</param>
  23. /// <param name="glyph">Glyph</param>
  24. public TMP_Character(uint unicode, Glyph glyph)
  25. {
  26. m_ElementType = TextElementType.Character;
  27. this.unicode = unicode;
  28. this.textAsset = null;
  29. this.glyph = glyph;
  30. this.glyphIndex = glyph.index;
  31. this.scale = 1.0f;
  32. }
  33. /// <summary>
  34. /// Constructor for new character
  35. /// </summary>
  36. /// <param name="unicode">Unicode value.</param>
  37. /// <param name="fontAsset">The font asset to which this character belongs.</param>
  38. /// <param name="glyph">Glyph</param>
  39. public TMP_Character(uint unicode, TMP_FontAsset fontAsset, Glyph glyph)
  40. {
  41. m_ElementType = TextElementType.Character;
  42. this.unicode = unicode;
  43. this.textAsset = fontAsset;
  44. this.glyph = glyph;
  45. this.glyphIndex = glyph.index;
  46. this.scale = 1.0f;
  47. }
  48. /// <summary>
  49. /// Constructor for new character
  50. /// </summary>
  51. /// <param name="unicode">Unicode value.</param>
  52. /// <param name="glyphIndex">Glyph index.</param>
  53. internal TMP_Character(uint unicode, uint glyphIndex)
  54. {
  55. m_ElementType = TextElementType.Character;
  56. this.unicode = unicode;
  57. this.textAsset = null;
  58. this.glyph = null;
  59. this.glyphIndex = glyphIndex;
  60. this.scale = 1.0f;
  61. }
  62. }
  63. }