TMP_TextElement.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.TextCore;
  4. namespace TMPro
  5. {
  6. public enum TextElementType : byte
  7. {
  8. Character = 0x1,
  9. Sprite = 0x2,
  10. }
  11. /// <summary>
  12. /// Base class for all text elements like Character and SpriteCharacter.
  13. /// </summary>
  14. [Serializable]
  15. public class TMP_TextElement
  16. {
  17. /// <summary>
  18. /// The type of text element which can be a character or sprite.
  19. /// </summary>
  20. public TextElementType elementType { get { return m_ElementType; } }
  21. /// <summary>
  22. /// The unicode value (code point) of the character.
  23. /// </summary>
  24. public uint unicode { get { return m_Unicode; } set { m_Unicode = value; } }
  25. /// <summary>
  26. /// The Text Asset to which this Text Element belongs.
  27. /// </summary>
  28. public TMP_Asset textAsset { get { return m_TextAsset; } set { m_TextAsset = value; } }
  29. /// <summary>
  30. /// The glyph used by this text element.
  31. /// </summary>
  32. public Glyph glyph { get { return m_Glyph; } set { m_Glyph = value; } }
  33. /// <summary>
  34. /// The index of the glyph used by this text element.
  35. /// </summary>
  36. public uint glyphIndex { get { return m_GlyphIndex; } set { m_GlyphIndex = value; } }
  37. /// <summary>
  38. /// The relative scale of the character.
  39. /// </summary>
  40. public float scale { get { return m_Scale; } set { m_Scale = value; } }
  41. // =============================================
  42. // Private backing fields for public properties.
  43. // =============================================
  44. [SerializeField]
  45. protected TextElementType m_ElementType;
  46. [SerializeField]
  47. internal uint m_Unicode;
  48. internal TMP_Asset m_TextAsset;
  49. internal Glyph m_Glyph;
  50. [SerializeField]
  51. internal uint m_GlyphIndex;
  52. [SerializeField]
  53. internal float m_Scale;
  54. }
  55. }