TMP_TextElement.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 glyph used by this text element.
  27. /// </summary>
  28. public Glyph glyph { get { return m_Glyph; } set { m_Glyph = value; } }
  29. /// <summary>
  30. /// The index of the glyph used by this text element.
  31. /// </summary>
  32. public uint glyphIndex { get { return m_GlyphIndex; } set { m_GlyphIndex = value; } }
  33. /// <summary>
  34. /// The relative scale of the character.
  35. /// </summary>
  36. public float scale { get { return m_Scale; } set { m_Scale = value; } }
  37. // =============================================
  38. // Private backing fields for public properties.
  39. // =============================================
  40. [SerializeField]
  41. protected TextElementType m_ElementType;
  42. [SerializeField]
  43. private uint m_Unicode;
  44. private Glyph m_Glyph;
  45. [SerializeField]
  46. private uint m_GlyphIndex;
  47. [SerializeField]
  48. private float m_Scale;
  49. }
  50. }