9 using System.Collections;
10 using System.Collections.Generic;
17 Material sharedMaterial {
get; }
19 void Rebuild(CanvasUpdate update);
23 public enum TextAlignmentOptions
73 Left = 0x1, Center = 0x2, Right = 0x4, Justified = 0x8, Flush = 0x10, Geometry = 0x20
81 Top = 0x100, Middle = 0x200, Bottom = 0x400, Baseline = 0x800, Geometry = 0x1000, Capline = 0x2000,
94 public enum TMP_TextElementType { Character, Sprite };
95 public enum MaskingTypes { MaskOff = 0, MaskHard = 1, MaskSoft = 2 };
96 public enum TextOverflowModes { Overflow = 0, Ellipsis = 1, Masking = 2, Truncate = 3, ScrollRect = 4, Page = 5, Linked = 6 };
97 public enum MaskingOffsetMode { Percentage = 0, Pixel = 1 };
98 public enum TextureMappingOptions { Character = 0, Line = 1, Paragraph = 2, MatchAspect = 3 };
100 public enum FontStyles { Normal = 0x0, Bold = 0x1, Italic = 0x2, Underline = 0x4, LowerCase = 0x8, UpperCase = 0x10, SmallCaps = 0x20, Strikethrough = 0x40, Superscript = 0x80, Subscript = 0x100, Highlight = 0x200 };
101 public enum FontWeights { Thin = 100, ExtraLight = 200, Light = 300, Normal = 400, Medium = 500, SemiBold = 600, Bold = 700, Heavy = 800, Black = 900 };
103 public enum TagUnits { Pixels = 0, FontUnits = 1, Percentage = 2 };
104 public enum TagType { None = 0x0, NumericalValue = 0x1, StringValue = 0x2, ColorValue = 0x4 };
117 get {
return m_text; }
118 set {
if (m_text == value)
return; m_text = old_text = value; m_inputSource = TextInputSources.String; m_havePropertiesChanged =
true; m_isCalculateSizeRequired =
true; m_isInputParsingRequired =
true; SetVerticesDirty(); SetLayoutDirty(); }
122 protected string m_text;
130 get {
return m_isRightToLeft; }
131 set {
if (m_isRightToLeft == value)
return; m_isRightToLeft = value; m_havePropertiesChanged =
true; m_isCalculateSizeRequired =
true; m_isInputParsingRequired =
true; SetVerticesDirty(); SetLayoutDirty(); }
134 protected bool m_isRightToLeft =
false;
142 get {
return m_fontAsset; }
143 set {
if (m_fontAsset == value)
return; m_fontAsset = value;
LoadFontAsset(); m_havePropertiesChanged =
true; m_isCalculateSizeRequired =
true; m_isInputParsingRequired =
true; SetVerticesDirty(); SetLayoutDirty(); }
148 protected bool m_isSDFShader;
156 get {
return m_sharedMaterial; }
157 set {
if (m_sharedMaterial == value)
return;
SetSharedMaterial(value); m_havePropertiesChanged =
true; m_isInputParsingRequired =
true; SetVerticesDirty(); SetMaterialDirty(); }
160 protected Material m_sharedMaterial;
161 protected Material m_currentMaterial;
163 protected Dictionary<int, int> m_materialReferenceIndexLookup =
new Dictionary<int, int>();
166 protected int m_currentMaterialIndex;
176 set {
SetSharedMaterials(value); m_havePropertiesChanged =
true; m_isInputParsingRequired =
true; SetVerticesDirty(); SetMaterialDirty(); }
179 protected Material[] m_fontSharedMaterials;
193 if (m_sharedMaterial !=
null && m_sharedMaterial.GetInstanceID() == value.GetInstanceID())
return;
195 m_sharedMaterial = value;
198 m_havePropertiesChanged =
true;
199 m_isInputParsingRequired =
true;
206 protected Material m_fontMaterial;
216 set {
SetSharedMaterials(value); m_havePropertiesChanged =
true; m_isInputParsingRequired =
true; SetVerticesDirty(); SetMaterialDirty(); }
219 protected Material[] m_fontMaterials;
221 protected bool m_isMaterialDirty;
227 public override Color
color 229 get {
return m_fontColor; }
230 set {
if (m_fontColor == value)
return; m_havePropertiesChanged =
true; m_fontColor = value; SetVerticesDirty(); }
234 protected Color32 m_fontColor32 = Color.white;
236 protected Color m_fontColor = Color.white;
237 protected static Color32 s_colorWhite =
new Color32(255, 255, 255, 255);
238 protected Color32 m_underlineColor = s_colorWhite;
239 protected Color32 m_strikethroughColor = s_colorWhite;
240 protected Color32 m_highlightColor = s_colorWhite;
248 get {
return m_fontColor.a; }
249 set {
if (m_fontColor.a == value)
return; m_fontColor.a = value; m_havePropertiesChanged =
true; SetVerticesDirty(); }
259 get {
return m_enableVertexGradient; }
260 set {
if (m_enableVertexGradient == value)
return; m_havePropertiesChanged =
true; m_enableVertexGradient = value; SetVerticesDirty(); }
263 protected bool m_enableVertexGradient;
266 protected ColorMode m_colorMode = ColorMode.FourCornersGradient;
274 get {
return m_fontColorGradient; }
275 set { m_havePropertiesChanged =
true; m_fontColorGradient = value; SetVerticesDirty(); }
286 get {
return m_fontColorGradientPreset; }
287 set { m_havePropertiesChanged =
true; m_fontColorGradientPreset = value; SetVerticesDirty(); }
298 get {
return m_spriteAsset; }
299 set { m_spriteAsset = value; m_havePropertiesChanged =
true; m_isInputParsingRequired =
true; m_isCalculateSizeRequired =
true; SetVerticesDirty(); SetLayoutDirty(); }
310 get {
return m_tintAllSprites; }
311 set {
if (m_tintAllSprites == value)
return; m_tintAllSprites = value; m_havePropertiesChanged =
true; SetVerticesDirty(); }
314 protected bool m_tintAllSprites;
315 protected bool m_tintSprite;
316 protected Color32 m_spriteColor;
324 get {
return m_overrideHtmlColors; }
325 set {
if (m_overrideHtmlColors == value)
return; m_havePropertiesChanged =
true; m_overrideHtmlColors = value; SetVerticesDirty(); }
328 protected bool m_overrideHtmlColors =
false;
338 if (m_sharedMaterial ==
null)
return m_faceColor;
340 m_faceColor = m_sharedMaterial.GetColor(ShaderUtilities.ID_FaceColor);
344 set {
if (m_faceColor.Compare(value))
return;
SetFaceColor(value); m_havePropertiesChanged =
true; m_faceColor = value; SetVerticesDirty(); SetMaterialDirty(); }
347 protected Color32 m_faceColor = Color.white;
357 if (m_sharedMaterial ==
null)
return m_outlineColor;
359 m_outlineColor = m_sharedMaterial.GetColor(ShaderUtilities.ID_OutlineColor);
360 return m_outlineColor;
363 set {
if (m_outlineColor.Compare(value))
return;
SetOutlineColor(value); m_havePropertiesChanged =
true; m_outlineColor = value; SetVerticesDirty(); }
366 protected Color32 m_outlineColor = Color.black;
376 if (m_sharedMaterial ==
null)
return m_outlineWidth;
378 m_outlineWidth = m_sharedMaterial.GetFloat(ShaderUtilities.ID_OutlineWidth);
379 return m_outlineWidth;
381 set {
if (m_outlineWidth == value)
return;
SetOutlineThickness(value); m_havePropertiesChanged =
true; m_outlineWidth = value; SetVerticesDirty(); }
383 protected float m_outlineWidth = 0.0f;
391 get {
return m_fontSize; }
392 set {
if (m_fontSize == value)
return; m_havePropertiesChanged =
true; m_isCalculateSizeRequired =
true; m_fontSize = value;
if (!m_enableAutoSizing) m_fontSizeBase = m_fontSize; SetVerticesDirty(); SetLayoutDirty(); }
395 protected float m_fontSize = 36;
396 protected float m_currentFontSize;
398 protected float m_fontSizeBase = 36;
407 get {
return m_fontScale; }
416 get {
return m_fontWeight; }
417 set {
if (m_fontWeight == value)
return; m_fontWeight = value; m_havePropertiesChanged =
true; m_isCalculateSizeRequired =
true; m_isInputParsingRequired =
true; SetVerticesDirty(); SetLayoutDirty(); }
420 protected int m_fontWeight = 400;
421 protected int m_fontWeightInternal;
431 var localCanvas = canvas;
436 return localCanvas.scaleFactor;
438 if (m_currentFontAsset ==
null || m_currentFontAsset.
fontInfo.PointSize <= 0 || m_fontSize <= 0)
440 return m_fontSize / m_currentFontAsset.
fontInfo.PointSize;
450 get {
return m_enableAutoSizing; }
451 set {
if (m_enableAutoSizing == value)
return; m_enableAutoSizing = value; SetVerticesDirty(); SetLayoutDirty(); }
454 protected bool m_enableAutoSizing;
455 protected float m_maxFontSize;
456 protected float m_minFontSize;
464 get {
return m_fontSizeMin; }
465 set {
if (m_fontSizeMin == value)
return; m_fontSizeMin = value; SetVerticesDirty(); SetLayoutDirty(); }
468 protected float m_fontSizeMin = 0;
476 get {
return m_fontSizeMax; }
477 set {
if (m_fontSizeMax == value)
return; m_fontSizeMax = value; SetVerticesDirty(); SetLayoutDirty(); }
480 protected float m_fontSizeMax = 0;
488 get {
return m_fontStyle; }
489 set {
if (m_fontStyle == value)
return; m_fontStyle = value; m_havePropertiesChanged =
true; m_isCalculateSizeRequired =
true; m_isInputParsingRequired =
true; SetVerticesDirty(); SetLayoutDirty(); }
492 protected FontStyles m_fontStyle = FontStyles.Normal;
493 protected FontStyles m_style = FontStyles.Normal;
500 protected bool m_isUsingBold =
false;
508 get {
return m_textAlignment; }
509 set {
if (m_textAlignment == value)
return; m_havePropertiesChanged =
true; m_textAlignment = value; SetVerticesDirty(); }
512 [
UnityEngine.Serialization.FormerlySerializedAs(
"m_lineJustification")]
513 protected TextAlignmentOptions m_textAlignment = TextAlignmentOptions.TopLeft;
514 protected TextAlignmentOptions m_lineJustification;
516 protected Vector3[] m_textContainerLocalCorners =
new Vector3[4];
518 protected bool m_isAlignmentEnumConverted;
537 get {
return m_characterSpacing; }
538 set {
if (m_characterSpacing == value)
return; m_havePropertiesChanged =
true; m_isCalculateSizeRequired =
true; m_characterSpacing = value; SetVerticesDirty(); SetLayoutDirty(); }
541 protected float m_characterSpacing = 0;
542 protected float m_cSpacing = 0;
543 protected float m_monoSpacing = 0;
550 get {
return m_wordSpacing; }
551 set {
if (m_wordSpacing == value)
return; m_havePropertiesChanged =
true; m_isCalculateSizeRequired =
true; m_wordSpacing = value; SetVerticesDirty(); SetLayoutDirty(); }
554 protected float m_wordSpacing = 0;
561 get {
return m_lineSpacing; }
562 set {
if (m_lineSpacing == value)
return; m_havePropertiesChanged =
true; m_isCalculateSizeRequired =
true; m_lineSpacing = value; SetVerticesDirty(); SetLayoutDirty(); }
565 protected float m_lineSpacing = 0;
566 protected float m_lineSpacingDelta = 0;
567 protected float m_lineHeight = TMP_Math.FLOAT_UNSET;
575 get {
return m_lineSpacingMax; }
576 set {
if (m_lineSpacingMax == value)
return; m_havePropertiesChanged =
true; m_isCalculateSizeRequired =
true; m_lineSpacingMax = value; SetVerticesDirty(); SetLayoutDirty(); }
579 protected float m_lineSpacingMax = 0;
587 get {
return m_paragraphSpacing; }
588 set {
if (m_paragraphSpacing == value)
return; m_havePropertiesChanged =
true; m_isCalculateSizeRequired =
true; m_paragraphSpacing = value; SetVerticesDirty(); SetLayoutDirty(); }
591 protected float m_paragraphSpacing = 0;
599 get {
return m_charWidthMaxAdj; }
600 set {
if (m_charWidthMaxAdj == value)
return; m_havePropertiesChanged =
true; m_isCalculateSizeRequired =
true; m_charWidthMaxAdj = value; SetVerticesDirty(); SetLayoutDirty(); }
603 protected float m_charWidthMaxAdj = 0f;
604 protected float m_charWidthAdjDelta = 0;
612 get {
return m_enableWordWrapping; }
613 set {
if (m_enableWordWrapping == value)
return; m_havePropertiesChanged =
true; m_isInputParsingRequired =
true; m_isCalculateSizeRequired =
true; m_enableWordWrapping = value; SetVerticesDirty(); SetLayoutDirty(); }
616 protected bool m_enableWordWrapping =
false;
617 protected bool m_isCharacterWrappingEnabled =
false;
618 protected bool m_isNonBreakingSpace =
false;
619 protected bool m_isIgnoringAlignment;
626 get {
return m_wordWrappingRatios; }
627 set {
if (m_wordWrappingRatios == value)
return; m_wordWrappingRatios = value; m_havePropertiesChanged =
true; m_isCalculateSizeRequired =
true; SetVerticesDirty(); SetLayoutDirty(); }
630 protected float m_wordWrappingRatios = 0.4f;
651 get {
return m_overflowMode; }
652 set {
if (m_overflowMode == value)
return; m_overflowMode = value; m_havePropertiesChanged =
true; m_isCalculateSizeRequired =
true; SetVerticesDirty(); SetLayoutDirty(); }
655 protected TextOverflowModes m_overflowMode = TextOverflowModes.Overflow;
663 get {
if (m_firstOverflowCharacterIndex != -1)
return true;
return false; }
672 get {
return m_firstOverflowCharacterIndex; }
675 protected int m_firstOverflowCharacterIndex = -1;
683 get {
return m_linkedTextComponent; }
687 if (m_linkedTextComponent != value)
690 if (m_linkedTextComponent !=
null)
692 m_linkedTextComponent.
overflowMode = TextOverflowModes.Overflow;
697 m_linkedTextComponent = value;
699 if (m_linkedTextComponent !=
null)
703 m_havePropertiesChanged =
true;
704 m_isCalculateSizeRequired =
true;
710 protected TMP_Text m_linkedTextComponent;
718 get {
return m_isLinkedTextComponent; }
722 m_isLinkedTextComponent = value;
724 if (m_isLinkedTextComponent ==
false)
725 m_firstVisibleCharacter = 0;
727 m_havePropertiesChanged =
true;
728 m_isCalculateSizeRequired =
true;
734 protected bool m_isLinkedTextComponent;
742 protected bool m_isTextTruncated;
750 get {
return m_enableKerning; }
751 set {
if (m_enableKerning == value)
return; m_havePropertiesChanged =
true; m_isCalculateSizeRequired =
true; m_enableKerning = value; SetVerticesDirty(); SetLayoutDirty(); }
754 protected bool m_enableKerning;
762 get {
return m_enableExtraPadding; }
763 set {
if (m_enableExtraPadding == value)
return; m_havePropertiesChanged =
true; m_enableExtraPadding = value;
UpdateMeshPadding(); SetVerticesDirty(); }
766 protected bool m_enableExtraPadding =
false;
768 protected bool checkPaddingRequired;
776 get {
return m_isRichText; }
777 set {
if (m_isRichText == value)
return; m_isRichText = value; m_havePropertiesChanged =
true; m_isCalculateSizeRequired =
true; m_isInputParsingRequired =
true; SetVerticesDirty(); SetLayoutDirty(); }
780 protected bool m_isRichText =
true;
788 get {
return m_parseCtrlCharacters; }
789 set {
if (m_parseCtrlCharacters == value)
return; m_parseCtrlCharacters = value; m_havePropertiesChanged =
true; m_isCalculateSizeRequired =
true; m_isInputParsingRequired =
true; SetVerticesDirty(); SetLayoutDirty(); }
792 protected bool m_parseCtrlCharacters =
true;
800 get {
return m_isOverlay; }
801 set {
if (m_isOverlay == value)
return; m_isOverlay = value;
SetShaderDepth(); m_havePropertiesChanged =
true; SetVerticesDirty(); }
803 protected bool m_isOverlay =
false;
811 get {
return m_isOrthographic; }
812 set {
if (m_isOrthographic == value)
return; m_havePropertiesChanged =
true; m_isOrthographic = value; SetVerticesDirty(); }
815 protected bool m_isOrthographic =
false;
823 get {
return m_isCullingEnabled; }
824 set {
if (m_isCullingEnabled == value)
return; m_isCullingEnabled = value;
SetCulling(); m_havePropertiesChanged =
true; }
827 protected bool m_isCullingEnabled =
false;
834 get {
return m_ignoreRectMaskCulling; }
835 set {
if (m_ignoreRectMaskCulling == value)
return; m_ignoreRectMaskCulling = value; m_havePropertiesChanged =
true; }
838 protected bool m_ignoreRectMaskCulling;
846 get {
return m_ignoreCulling; }
847 set {
if (m_ignoreCulling == value)
return; m_havePropertiesChanged =
true; m_ignoreCulling = value; }
850 protected bool m_ignoreCulling =
true;
858 get {
return m_horizontalMapping; }
859 set {
if (m_horizontalMapping == value)
return; m_havePropertiesChanged =
true; m_horizontalMapping = value; SetVerticesDirty(); }
862 protected TextureMappingOptions m_horizontalMapping = TextureMappingOptions.Character;
870 get {
return m_verticalMapping; }
871 set {
if (m_verticalMapping == value)
return; m_havePropertiesChanged =
true; m_verticalMapping = value; SetVerticesDirty(); }
874 protected TextureMappingOptions m_verticalMapping = TextureMappingOptions.Character;
894 get {
return m_uvLineOffset; }
895 set {
if (m_uvLineOffset == value)
return; m_havePropertiesChanged =
true; m_uvLineOffset = value; SetVerticesDirty(); }
898 protected float m_uvLineOffset = 0.0f;
906 get {
return m_renderMode; }
907 set {
if (m_renderMode == value)
return; m_renderMode = value; m_havePropertiesChanged =
true; }
917 get {
return m_geometrySortingOrder; }
919 set { m_geometrySortingOrder = value; m_havePropertiesChanged =
true; SetVerticesDirty(); }
923 protected VertexSortingOrder m_geometrySortingOrder;
930 get {
return m_firstVisibleCharacter; }
931 set {
if (m_firstVisibleCharacter == value)
return; m_havePropertiesChanged =
true; m_firstVisibleCharacter = value; SetVerticesDirty(); }
934 protected int m_firstVisibleCharacter;
941 get {
return m_maxVisibleCharacters; }
942 set {
if (m_maxVisibleCharacters == value)
return; m_havePropertiesChanged =
true; m_maxVisibleCharacters = value; SetVerticesDirty(); }
944 protected int m_maxVisibleCharacters = 99999;
952 get {
return m_maxVisibleWords; }
953 set {
if (m_maxVisibleWords == value)
return; m_havePropertiesChanged =
true; m_maxVisibleWords = value; SetVerticesDirty(); }
955 protected int m_maxVisibleWords = 99999;
963 get {
return m_maxVisibleLines; }
964 set {
if (m_maxVisibleLines == value)
return; m_havePropertiesChanged =
true; m_isInputParsingRequired =
true; m_maxVisibleLines = value; SetVerticesDirty(); }
966 protected int m_maxVisibleLines = 99999;
974 get {
return m_useMaxVisibleDescender; }
975 set {
if (m_useMaxVisibleDescender == value)
return; m_havePropertiesChanged =
true; m_isInputParsingRequired =
true; SetVerticesDirty(); }
978 protected bool m_useMaxVisibleDescender =
true;
986 get {
return m_pageToDisplay; }
987 set {
if (m_pageToDisplay == value)
return; m_havePropertiesChanged =
true; m_pageToDisplay = value; SetVerticesDirty(); }
990 protected int m_pageToDisplay = 1;
991 protected bool m_isNewPage =
false;
996 public virtual Vector4
margin 998 get {
return m_margin; }
999 set {
if (m_margin == value)
return; m_margin = value;
ComputeMarginSize(); m_havePropertiesChanged =
true; SetVerticesDirty(); }
1002 protected Vector4 m_margin =
new Vector4(0, 0, 0, 0);
1003 protected float m_marginLeft;
1004 protected float m_marginRight;
1005 protected float m_marginWidth;
1006 protected float m_marginHeight;
1007 protected float m_width = -1;
1015 get {
return m_textInfo; }
1025 get {
return m_havePropertiesChanged; }
1026 set {
if (m_havePropertiesChanged == value)
return; m_havePropertiesChanged = value; m_isInputParsingRequired =
true; SetAllDirty(); }
1029 protected bool m_havePropertiesChanged;
1037 get {
return m_isUsingLegacyAnimationComponent; }
1038 set { m_isUsingLegacyAnimationComponent = value; }
1041 protected bool m_isUsingLegacyAnimationComponent;
1051 if (m_transform ==
null)
1052 m_transform = GetComponent<Transform>();
1056 protected Transform m_transform;
1066 if (m_rectTransform ==
null)
1067 m_rectTransform = GetComponent<RectTransform>();
1068 return m_rectTransform;
1071 protected RectTransform m_rectTransform;
1082 protected bool m_autoSizeTextContainer;
1088 public virtual Mesh
mesh 1090 get {
return m_mesh; }
1092 protected Mesh m_mesh;
1100 get {
return m_isVolumetricText; }
1101 set {
if (m_isVolumetricText == value)
return; m_havePropertiesChanged = value; m_textInfo.
ResetVertexLayout(value); m_isInputParsingRequired =
true; SetVerticesDirty(); SetLayoutDirty(); }
1104 protected bool m_isVolumetricText;
1113 if (m_mesh ==
null)
return new Bounds();
1126 if (m_textInfo ==
null)
return new Bounds();
1180 if (m_spriteAnimator ==
null)
1182 m_spriteAnimator = GetComponent<TMP_SpriteAnimator>();
1183 if (m_spriteAnimator ==
null) m_spriteAnimator = gameObject.AddComponent<
TMP_SpriteAnimator>();
1186 return m_spriteAnimator;
1215 protected float m_flexibleHeight = -1f;
1221 protected float m_flexibleWidth = -1f;
1227 protected float m_minWidth;
1233 protected float m_minHeight;
1239 protected float m_maxWidth;
1245 protected float m_maxHeight;
1254 if (m_LayoutElement ==
null)
1256 m_LayoutElement = GetComponent<LayoutElement>();
1259 return m_LayoutElement;
1262 protected LayoutElement m_LayoutElement;
1268 protected float m_preferredWidth;
1269 protected float m_renderedWidth;
1270 protected bool m_isPreferredWidthDirty;
1276 protected float m_preferredHeight;
1277 protected float m_renderedHeight;
1278 protected bool m_isPreferredHeightDirty;
1280 protected bool m_isCalculatingPreferredValues;
1281 private int m_recursiveCount;
1299 protected int m_layoutPriority = 0;
1301 protected bool m_isCalculateSizeRequired =
false;
1302 protected bool m_isLayoutDirty;
1304 protected bool m_verticesAlreadyDirty;
1305 protected bool m_layoutAlreadyDirty;
1307 protected bool m_isAwake;
1308 protected bool m_isWaitingOnResourceLoad;
1311 protected bool m_isInputParsingRequired =
false;
1316 protected TextInputSources m_inputSource;
1317 protected string old_text;
1321 protected float m_fontScale;
1322 protected float m_fontScaleMultiplier;
1324 protected char[] m_htmlTag =
new char[128];
1325 protected XML_TagAttribute[] m_xmlAttribute =
new XML_TagAttribute[8];
1327 protected float[] m_attributeParameterValues =
new float[16];
1329 protected float tag_LineIndent = 0;
1330 protected float tag_Indent = 0;
1331 protected TMP_XmlTagStack<float> m_indentStack =
new TMP_XmlTagStack<float>(
new float[16]);
1332 protected bool tag_NoParsing;
1335 protected bool m_isParsingText;
1336 protected Matrix4x4 m_FXMatrix;
1337 protected bool m_isFXMatrixSet;
1340 protected int[] m_char_buffer;
1341 private TMP_CharacterInfo[] m_internalCharacterInfo;
1342 protected char[] m_input_CharArray =
new char[256];
1343 private int m_charArray_Length = 0;
1344 protected int m_totalCharacterCount;
1347 protected WordWrapState m_SavedWordWrapState =
new WordWrapState();
1348 protected WordWrapState m_SavedLineState =
new WordWrapState();
1353 protected int m_characterCount;
1356 protected int m_firstCharacterOfLine;
1357 protected int m_firstVisibleCharacterOfLine;
1358 protected int m_lastCharacterOfLine;
1359 protected int m_lastVisibleCharacterOfLine;
1360 protected int m_lineNumber;
1361 protected int m_lineVisibleCharacterCount;
1362 protected int m_pageNumber;
1363 protected float m_maxAscender;
1364 protected float m_maxCapHeight;
1365 protected float m_maxDescender;
1366 protected float m_maxLineAscender;
1367 protected float m_maxLineDescender;
1368 protected float m_startOfLineAscender;
1370 protected float m_lineOffset;
1371 protected Extents m_meshExtents;
1375 protected Color32 m_htmlColor =
new Color(255, 255, 255, 128);
1376 protected TMP_XmlTagStack<Color32> m_colorStack =
new TMP_XmlTagStack<Color32>(
new Color32[16]);
1377 protected TMP_XmlTagStack<Color32> m_underlineColorStack =
new TMP_XmlTagStack<Color32>(
new Color32[16]);
1378 protected TMP_XmlTagStack<Color32> m_strikethroughColorStack =
new TMP_XmlTagStack<Color32>(
new Color32[16]);
1379 protected TMP_XmlTagStack<Color32> m_highlightColorStack =
new TMP_XmlTagStack<Color32>(
new Color32[16]);
1381 protected TMP_ColorGradient m_colorGradientPreset;
1382 protected TMP_XmlTagStack<TMP_ColorGradient> m_colorGradientStack =
new TMP_XmlTagStack<TMP_ColorGradient>(
new TMP_ColorGradient[16]);
1384 protected float m_tabSpacing = 0;
1385 protected float m_spacing = 0;
1392 protected TMP_XmlTagStack<int> m_styleStack =
new TMP_XmlTagStack<int>(
new int[16]);
1393 protected TMP_XmlTagStack<int> m_actionStack =
new TMP_XmlTagStack<int>(
new int[16]);
1395 protected float m_padding = 0;
1396 protected float m_baselineOffset;
1397 protected TMP_XmlTagStack<float> m_baselineOffsetStack =
new TMP_XmlTagStack<float>(
new float[16]);
1398 protected float m_xAdvance;
1400 protected TMP_TextElementType m_textElementType;
1401 protected TMP_TextElement m_cached_TextElement;
1402 protected TMP_Glyph m_cached_Underline_GlyphInfo;
1403 protected TMP_Glyph m_cached_Ellipsis_GlyphInfo;
1405 protected TMP_SpriteAsset m_defaultSpriteAsset;
1406 protected TMP_SpriteAsset m_currentSpriteAsset;
1407 protected int m_spriteCount = 0;
1408 protected int m_spriteIndex;
1409 protected int m_spriteAnimationID;
1450 protected virtual Material[]
GetMaterials(Material[] mats) {
return null; }
1465 Material mat =
new Material(source);
1466 mat.shaderKeywords = source.shaderKeywords;
1467 mat.name +=
" (Instance)";
1474 if (gradient ==
null)
return;
1476 m_fontColorGradient.bottomLeft = gradient.bottomLeft;
1477 m_fontColorGradient.bottomRight = gradient.bottomRight;
1478 m_fontColorGradient.topLeft = gradient.topLeft;
1479 m_fontColorGradient.topRight = gradient.topRight;
1551 protected bool m_ignoreActiveState;
1579 m_isInputParsingRequired =
true;
1637 public override void CrossFadeColor(Color targetColor,
float duration,
bool ignoreTimeScale,
bool useAlpha)
1639 base.CrossFadeColor(targetColor, duration, ignoreTimeScale, useAlpha);
1652 base.CrossFadeAlpha(
alpha, duration, ignoreTimeScale);
1685 m_isInputParsingRequired =
false;
1687 switch (m_inputSource)
1689 case TextInputSources.String:
1690 case TextInputSources.Text:
1693 case TextInputSources.SetText:
1696 case TextInputSources.SetCharArray:
1725 m_inputSource = TextInputSources.SetCharArray;
1732 if (syncTextInputBox)
1736 m_isInputParsingRequired =
true;
1737 m_havePropertiesChanged =
true;
1738 m_isCalculateSizeRequired =
true;
1791 int decimalPrecision = 0;
1794 for (
int i = 0; i <
text.Length; i++)
1801 if (
text[i + 2] == 58)
1803 decimalPrecision =
text[i + 3] - 48;
1806 switch (
text[i + 1] - 48)
1822 if (
text[i + 2] == 58)
1829 m_input_CharArray[index] = c;
1833 m_input_CharArray[index] = (char)0;
1834 m_charArray_Length = index;
1838 m_text =
new string(m_input_CharArray, 0, index);
1841 m_inputSource = TextInputSources.SetText;
1842 m_isInputParsingRequired =
true;
1843 m_havePropertiesChanged =
true;
1844 m_isCalculateSizeRequired =
true;
1860 m_inputSource = TextInputSources.SetCharArray;
1864 m_text =
text.ToString();
1869 m_isInputParsingRequired =
true;
1870 m_havePropertiesChanged =
true;
1871 m_isCalculateSizeRequired =
true;
1885 if (m_char_buffer ==
null) m_char_buffer =
new int[8];
1889 if (sourceText ==
null || sourceText.Length == 0)
1890 m_text =
string.Empty;
1892 m_text =
new string(sourceText);
1896 m_styleStack.Clear();
1900 for (
int i = 0; sourceText !=
null && i < sourceText.Length; i++)
1902 if (sourceText[i] == 92 && i < sourceText.Length - 1)
1904 switch ((
int)sourceText[i + 1])
1907 if (writeIndex == m_char_buffer.Length) ResizeInternalArray(ref m_char_buffer);
1909 m_char_buffer[writeIndex] = (char)10;
1914 if (writeIndex == m_char_buffer.Length) ResizeInternalArray(ref m_char_buffer);
1916 m_char_buffer[writeIndex] = (char)13;
1921 if (writeIndex == m_char_buffer.Length) ResizeInternalArray(ref m_char_buffer);
1923 m_char_buffer[writeIndex] = (char)9;
1931 if (sourceText[i] == 60)
1933 if (
IsTagName(ref sourceText,
"<BR>", i))
1935 if (writeIndex == m_char_buffer.Length) ResizeInternalArray(ref m_char_buffer);
1937 m_char_buffer[writeIndex] = 10; ;
1943 else if (
IsTagName(ref sourceText,
"<STYLE=", i))
1952 else if (
IsTagName(ref sourceText,
"</STYLE>", i))
1962 if (writeIndex == m_char_buffer.Length) ResizeInternalArray(ref m_char_buffer);
1964 m_char_buffer[writeIndex] = sourceText[i];
1968 if (writeIndex == m_char_buffer.Length) ResizeInternalArray(ref m_char_buffer);
1970 m_char_buffer[writeIndex] = (char)0;
1972 m_inputSource = TextInputSources.SetCharArray;
1973 m_isInputParsingRequired =
true;
1974 m_havePropertiesChanged =
true;
1975 m_isCalculateSizeRequired =
true;
1989 if (m_char_buffer ==
null) m_char_buffer =
new int[8];
1993 if (sourceText ==
null || sourceText.Length == 0 || length == 0)
1995 m_text =
string.Empty;
2002 m_text =
new string(sourceText, start, length);
2007 m_styleStack.Clear();
2012 int end = start + length;
2013 for (; i < end; i++)
2015 if (sourceText[i] == 92 && i < length - 1)
2017 switch ((
int)sourceText[i + 1])
2020 if (writeIndex == m_char_buffer.Length) ResizeInternalArray(ref m_char_buffer);
2022 m_char_buffer[writeIndex] = (char)10;
2027 if (writeIndex == m_char_buffer.Length) ResizeInternalArray(ref m_char_buffer);
2029 m_char_buffer[writeIndex] = (char)13;
2034 if (writeIndex == m_char_buffer.Length) ResizeInternalArray(ref m_char_buffer);
2036 m_char_buffer[writeIndex] = (char)9;
2044 if (sourceText[i] == 60)
2046 if (
IsTagName(ref sourceText,
"<BR>", i))
2048 if (writeIndex == m_char_buffer.Length) ResizeInternalArray(ref m_char_buffer);
2050 m_char_buffer[writeIndex] = 10; ;
2056 else if (
IsTagName(ref sourceText,
"<STYLE=", i))
2065 else if (
IsTagName(ref sourceText,
"</STYLE>", i))
2075 if (writeIndex == m_char_buffer.Length) ResizeInternalArray(ref m_char_buffer);
2077 m_char_buffer[writeIndex] = sourceText[i];
2081 if (writeIndex == m_char_buffer.Length) ResizeInternalArray(ref m_char_buffer);
2083 m_char_buffer[writeIndex] = (char)0;
2085 m_inputSource = TextInputSources.SetCharArray;
2086 m_havePropertiesChanged =
true;
2087 m_isInputParsingRequired =
true;
2088 m_isCalculateSizeRequired =
true;
2102 if (m_char_buffer ==
null) m_char_buffer =
new int[8];
2106 if (sourceText ==
null || sourceText.Length == 0 || length == 0)
2108 m_text =
string.Empty;
2114 m_text = sourceText.IntToString(start, length);
2119 m_styleStack.Clear();
2123 int end = start + length;
2124 for (
int i = start; i < end; i++)
2126 if (sourceText[i] == 92 && i < length - 1)
2128 switch ((
int)sourceText[i + 1])
2131 if (writeIndex == m_char_buffer.Length) ResizeInternalArray(ref m_char_buffer);
2133 m_char_buffer[writeIndex] = (char)10;
2138 if (writeIndex == m_char_buffer.Length) ResizeInternalArray(ref m_char_buffer);
2140 m_char_buffer[writeIndex] = (char)13;
2145 if (writeIndex == m_char_buffer.Length) ResizeInternalArray(ref m_char_buffer);
2147 m_char_buffer[writeIndex] = (char)9;
2155 if (sourceText[i] == 60)
2157 if (
IsTagName(ref sourceText,
"<BR>", i))
2159 if (writeIndex == m_char_buffer.Length) ResizeInternalArray(ref m_char_buffer);
2161 m_char_buffer[writeIndex] = 10; ;
2167 else if (
IsTagName(ref sourceText,
"<STYLE=", i))
2176 else if (
IsTagName(ref sourceText,
"</STYLE>", i))
2186 if (writeIndex == m_char_buffer.Length) ResizeInternalArray(ref m_char_buffer);
2188 m_char_buffer[writeIndex] = sourceText[i];
2192 if (writeIndex == m_char_buffer.Length) ResizeInternalArray(ref m_char_buffer);
2194 m_char_buffer[writeIndex] = (char)0;
2196 m_inputSource = TextInputSources.SetCharArray;
2197 m_havePropertiesChanged =
true;
2198 m_isInputParsingRequired =
true;
2199 m_isCalculateSizeRequired =
true;
2214 if (sourceText ==
null || m_charArray_Length == 0)
2217 if (charBuffer ==
null) charBuffer =
new int[8];
2220 m_styleStack.Clear();
2224 for (
int i = 0; i < m_charArray_Length; i++)
2227 if (
char.IsHighSurrogate(sourceText[i]) &&
char.IsLowSurrogate(sourceText[i + 1]))
2229 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2231 charBuffer[writeIndex] =
char.ConvertToUtf32(sourceText[i], sourceText[i + 1]);
2238 if (sourceText[i] == 60)
2240 if (
IsTagName(ref sourceText,
"<BR>", i))
2242 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2244 charBuffer[writeIndex] = 10;
2250 else if (
IsTagName(ref sourceText,
"<STYLE=", i))
2259 else if (
IsTagName(ref sourceText,
"</STYLE>", i))
2269 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2271 charBuffer[writeIndex] = sourceText[i];
2275 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2277 charBuffer[writeIndex] = 0;
2288 if (sourceText ==
null)
2294 if (charBuffer ==
null) charBuffer =
new int[8];
2297 m_styleStack.SetDefault(0);
2301 for (
int i = 0; i < sourceText.Length; i++)
2303 if (m_inputSource == TextInputSources.Text && sourceText[i] == 92 && sourceText.Length > i + 1)
2305 switch ((
int)sourceText[i + 1])
2308 if (sourceText.Length > i + 9)
2310 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2312 charBuffer[writeIndex] =
GetUTF32(sourceText, i + 2);
2319 if (!m_parseCtrlCharacters)
break;
2321 if (sourceText.Length <= i + 2)
break;
2323 if (writeIndex + 2 > charBuffer.Length) ResizeInternalArray(ref charBuffer);
2325 charBuffer[writeIndex] = sourceText[i + 1];
2326 charBuffer[writeIndex + 1] = sourceText[i + 2];
2331 if (!m_parseCtrlCharacters)
break;
2333 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2335 charBuffer[writeIndex] = (char)10;
2340 if (!m_parseCtrlCharacters)
break;
2342 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2344 charBuffer[writeIndex] = (char)13;
2349 if (!m_parseCtrlCharacters)
break;
2351 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2353 charBuffer[writeIndex] = (char)9;
2358 if (sourceText.Length > i + 5)
2360 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2362 charBuffer[writeIndex] = (char)
GetUTF16(sourceText, i + 2);
2372 if (
char.IsHighSurrogate(sourceText[i]) &&
char.IsLowSurrogate(sourceText[i + 1]))
2374 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2376 charBuffer[writeIndex] =
char.ConvertToUtf32(sourceText[i], sourceText[i + 1]);
2383 if (sourceText[i] == 60 && m_isRichText)
2385 if (
IsTagName(ref sourceText,
"<BR>", i))
2387 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2389 charBuffer[writeIndex] = 10; ;
2395 else if (
IsTagName(ref sourceText,
"<STYLE=", i))
2404 else if (
IsTagName(ref sourceText,
"</STYLE>", i))
2414 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2416 charBuffer[writeIndex] = sourceText[i];
2420 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2422 charBuffer[writeIndex] = (char)0;
2433 if (sourceText ==
null)
2439 if (charBuffer ==
null) charBuffer =
new int[8];
2442 m_styleStack.Clear();
2446 m_text = sourceText.ToString();
2451 for (
int i = 0; i < sourceText.Length; i++)
2453 if (m_parseCtrlCharacters && sourceText[i] == 92 && sourceText.Length > i + 1)
2455 switch ((
int)sourceText[i + 1])
2458 if (sourceText.Length > i + 9)
2460 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2462 charBuffer[writeIndex] =
GetUTF32(sourceText, i + 2);
2469 if (sourceText.Length <= i + 2)
break;
2471 if (writeIndex + 2 > charBuffer.Length) ResizeInternalArray(ref charBuffer);
2473 charBuffer[writeIndex] = sourceText[i + 1];
2474 charBuffer[writeIndex + 1] = sourceText[i + 2];
2479 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2481 charBuffer[writeIndex] = (char)10;
2486 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2488 charBuffer[writeIndex] = (char)13;
2493 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2495 charBuffer[writeIndex] = (char)9;
2500 if (sourceText.Length > i + 5)
2502 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2504 charBuffer[writeIndex] = (char)
GetUTF16(sourceText, i + 2);
2514 if (
char.IsHighSurrogate(sourceText[i]) &&
char.IsLowSurrogate(sourceText[i + 1]))
2516 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2518 charBuffer[writeIndex] =
char.ConvertToUtf32(sourceText[i], sourceText[i + 1]);
2525 if (sourceText[i] == 60)
2527 if (
IsTagName(ref sourceText,
"<BR>", i))
2529 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2531 charBuffer[writeIndex] = 10;
2537 else if (
IsTagName(ref sourceText,
"<STYLE=", i))
2546 else if (
IsTagName(ref sourceText,
"</STYLE>", i))
2556 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2558 charBuffer[writeIndex] = sourceText[i];
2562 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2564 charBuffer[writeIndex] = (char)0;
2577 bool ReplaceOpeningStyleTag(ref
string sourceText,
int srcIndex, out
int srcOffset, ref
int[] charBuffer, ref
int writeIndex)
2580 int hashCode =
GetTagHashCode(ref sourceText, srcIndex + 7, out srcOffset);
2585 if (style ==
null || srcOffset == 0)
return false;
2589 int styleLength = style.styleOpeningTagArray.Length;
2592 int[] openingTagArray = style.styleOpeningTagArray;
2594 for (
int i = 0; i < styleLength; i++)
2596 int c = openingTagArray[i];
2600 if (
IsTagName(ref openingTagArray,
"<BR>", i))
2602 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2604 charBuffer[writeIndex] = 10;
2610 else if (
IsTagName(ref openingTagArray,
"<STYLE=", i))
2619 else if (
IsTagName(ref openingTagArray,
"</STYLE>", i))
2629 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2631 charBuffer[writeIndex] = c;
2651 int hashCode =
GetTagHashCode(ref sourceText, srcIndex + 7, out srcOffset);
2656 if (style ==
null || srcOffset == 0)
return false;
2660 int styleLength = style.styleOpeningTagArray.Length;
2663 int[] openingTagArray = style.styleOpeningTagArray;
2665 for (
int i = 0; i < styleLength; i++)
2667 int c = openingTagArray[i];
2671 if (
IsTagName(ref openingTagArray,
"<BR>", i))
2673 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2675 charBuffer[writeIndex] = 10;
2681 else if (
IsTagName(ref openingTagArray,
"<STYLE=", i))
2690 else if (
IsTagName(ref openingTagArray,
"</STYLE>", i))
2700 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2702 charBuffer[writeIndex] = c;
2719 bool ReplaceOpeningStyleTag(ref
char[] sourceText,
int srcIndex, out
int srcOffset, ref
int[] charBuffer, ref
int writeIndex)
2722 int hashCode =
GetTagHashCode(ref sourceText, srcIndex + 7, out srcOffset);
2727 if (style ==
null || srcOffset == 0)
return false;
2731 int styleLength = style.styleOpeningTagArray.Length;
2734 int[] openingTagArray = style.styleOpeningTagArray;
2736 for (
int i = 0; i < styleLength; i++)
2738 int c = openingTagArray[i];
2742 if (
IsTagName(ref openingTagArray,
"<BR>", i))
2744 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2746 charBuffer[writeIndex] = 10;
2752 else if (
IsTagName(ref openingTagArray,
"<STYLE=", i))
2761 else if (
IsTagName(ref openingTagArray,
"</STYLE>", i))
2771 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2773 charBuffer[writeIndex] = c;
2790 bool ReplaceOpeningStyleTag(ref StringBuilder sourceText,
int srcIndex, out
int srcOffset, ref
int[] charBuffer, ref
int writeIndex)
2793 int hashCode =
GetTagHashCode(ref sourceText, srcIndex + 7, out srcOffset);
2798 if (style ==
null || srcOffset == 0)
return false;
2802 int styleLength = style.styleOpeningTagArray.Length;
2805 int[] openingTagArray = style.styleOpeningTagArray;
2807 for (
int i = 0; i < styleLength; i++)
2809 int c = openingTagArray[i];
2813 if (
IsTagName(ref openingTagArray,
"<BR>", i))
2815 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2817 charBuffer[writeIndex] = 10;
2823 else if (
IsTagName(ref openingTagArray,
"<STYLE=", i))
2832 else if (
IsTagName(ref openingTagArray,
"</STYLE>", i))
2842 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2844 charBuffer[writeIndex] = c;
2863 int hashCode = m_styleStack.CurrentItem();
2866 m_styleStack.Remove();
2869 if (style ==
null)
return false;
2871 int styleLength = style.styleClosingTagArray.Length;
2874 int[] closingTagArray = style.styleClosingTagArray;
2876 for (
int i = 0; i < styleLength; i++)
2878 int c = closingTagArray[i];
2882 if (
IsTagName(ref closingTagArray,
"<BR>", i))
2884 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2886 charBuffer[writeIndex] = 10;
2892 else if (
IsTagName(ref closingTagArray,
"<STYLE=", i))
2901 else if (
IsTagName(ref closingTagArray,
"</STYLE>", i))
2911 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2913 charBuffer[writeIndex] = c;
2932 int hashCode = m_styleStack.CurrentItem();
2935 m_styleStack.Remove();
2938 if (style ==
null)
return false;
2940 int styleLength = style.styleClosingTagArray.Length;
2943 int[] closingTagArray = style.styleClosingTagArray;
2945 for (
int i = 0; i < styleLength; i++)
2947 int c = closingTagArray[i];
2951 if (
IsTagName(ref closingTagArray,
"<BR>", i))
2953 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2955 charBuffer[writeIndex] = 10;
2961 else if (
IsTagName(ref closingTagArray,
"<STYLE=", i))
2970 else if (
IsTagName(ref closingTagArray,
"</STYLE>", i))
2980 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
2982 charBuffer[writeIndex] = c;
3001 int hashCode = m_styleStack.CurrentItem();
3004 m_styleStack.Remove();
3007 if (style ==
null)
return false;
3009 int styleLength = style.styleClosingTagArray.Length;
3012 int[] closingTagArray = style.styleClosingTagArray;
3014 for (
int i = 0; i < styleLength; i++)
3016 int c = closingTagArray[i];
3020 if (
IsTagName(ref closingTagArray,
"<BR>", i))
3022 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
3024 charBuffer[writeIndex] = 10;
3030 else if (
IsTagName(ref closingTagArray,
"<STYLE=", i))
3039 else if (
IsTagName(ref closingTagArray,
"</STYLE>", i))
3049 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
3051 charBuffer[writeIndex] = c;
3069 int hashCode = m_styleStack.CurrentItem();
3072 m_styleStack.Remove();
3075 if (style ==
null)
return false;
3077 int styleLength = style.styleClosingTagArray.Length;
3080 int[] closingTagArray = style.styleClosingTagArray;
3082 for (
int i = 0; i < styleLength; i++)
3084 int c = closingTagArray[i];
3088 if (
IsTagName(ref closingTagArray,
"<BR>", i))
3090 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
3092 charBuffer[writeIndex] = 10;
3098 else if (
IsTagName(ref closingTagArray,
"<STYLE=", i))
3107 else if (
IsTagName(ref closingTagArray,
"</STYLE>", i))
3117 if (writeIndex == charBuffer.Length) ResizeInternalArray(ref charBuffer);
3119 charBuffer[writeIndex] = c;
3136 if (
text.Length < index + tag.Length)
return false;
3138 for (
int i = 0; i < tag.Length; i++)
3140 if (TMP_TextUtilities.ToUpperFast(
text[index + i]) != tag[i])
return false;
3155 if (
text.Length < index + tag.Length)
return false;
3157 for (
int i = 0; i < tag.Length; i++)
3159 if (TMP_TextUtilities.ToUpperFast(
text[index + i]) != tag[i])
return false;
3174 if (
text.Length < index + tag.Length)
return false;
3176 for (
int i = 0; i < tag.Length; i++)
3178 if (TMP_TextUtilities.ToUpperFast((
char)
text[index + i]) != tag[i])
return false;
3193 if (
text.Length < index + tag.Length)
return false;
3195 for (
int i = 0; i < tag.Length; i++)
3197 if (TMP_TextUtilities.ToUpperFast(
text[index + i]) != tag[i])
return false;
3215 for (
int i = index; i <
text.Length; i++)
3218 if (
text[i] == 34)
continue;
3221 if (
text[i] == 62) { closeIndex = i;
break; }
3223 hashCode = (hashCode << 5) + hashCode ^
text[i];
3241 for (
int i = index; i <
text.Length; i++)
3244 if (
text[i] == 34)
continue;
3247 if (
text[i] == 62) { closeIndex = i;
break; }
3249 hashCode = (hashCode << 5) + hashCode ^
text[i];
3267 for (
int i = index; i <
text.Length; i++)
3270 if (
text[i] == 34)
continue;
3273 if (
text[i] == 62) { closeIndex = i;
break; }
3275 hashCode = (hashCode << 5) + hashCode ^
text[i];
3293 for (
int i = index; i <
text.Length; i++)
3296 if (
text[i] == 34)
continue;
3299 if (
text[i] == 62) { closeIndex = i;
break; }
3301 hashCode = (hashCode << 5) + hashCode ^
text[i];
3312 int size = Mathf.NextPowerOfTwo(array.Length + 1);
3314 System.Array.Resize(ref array, size);
3318 private readonly
float[] k_Power = { 5e-1f, 5e-2f, 5e-3f, 5e-4f, 5e-5f, 5e-6f, 5e-7f, 5e-8f, 5e-9f, 5e-10f };
3330 m_input_CharArray[index++] =
'-';
3334 number += k_Power[Mathf.Min(9, precision)];
3336 int integer = (int)number;
3342 m_input_CharArray[index++] =
'.';
3345 for (
int p = 0; p < precision; p++)
3348 int d = (int)(number);
3350 m_input_CharArray[index++] = (char)(d + 48);
3367 m_input_CharArray[index++] =
'-';
3374 m_input_CharArray[i++] = (char)(number % 10 + 48);
3376 }
while (number > 0);
3381 while (index + 1 < i)
3384 char t = m_input_CharArray[index];
3385 m_input_CharArray[index] = m_input_CharArray[i];
3386 m_input_CharArray[i] = t;
3413 if (m_isInputParsingRequired || m_isTextTruncated)
3415 m_isCalculatingPreferredValues =
true;
3435 if (m_isInputParsingRequired || m_isTextTruncated)
3437 m_isCalculatingPreferredValues =
true;
3441 Vector2
margin =
new Vector2(width, height);
3460 m_isCalculatingPreferredValues =
true;
3465 Vector2
margin = k_LargePositiveVector2;
3484 m_isCalculatingPreferredValues =
true;
3489 Vector2
margin =
new Vector2(width, height);
3509 float fontSize = m_enableAutoSizing ? m_fontSizeMax : m_fontSize;
3512 m_minFontSize = m_fontSizeMin;
3513 m_maxFontSize = m_fontSizeMax;
3514 m_charWidthAdjDelta = 0;
3517 Vector2
margin = k_LargePositiveVector2;
3519 if (m_isInputParsingRequired || m_isTextTruncated)
3521 m_isCalculatingPreferredValues =
true;
3525 m_recursiveCount = 0;
3528 m_isPreferredWidthDirty =
false;
3543 float fontSize = m_enableAutoSizing ? m_fontSizeMax : m_fontSize;
3546 m_minFontSize = m_fontSizeMin;
3547 m_maxFontSize = m_fontSizeMax;
3548 m_charWidthAdjDelta = 0;
3550 m_recursiveCount = 0;
3567 float fontSize = m_enableAutoSizing ? m_fontSizeMax : m_fontSize;
3570 m_minFontSize = m_fontSizeMin;
3571 m_maxFontSize = m_fontSizeMax;
3572 m_charWidthAdjDelta = 0;
3574 Vector2
margin =
new Vector2(m_marginWidth != 0 ? m_marginWidth : k_LargePositiveFloat, k_LargePositiveFloat);
3576 if (m_isInputParsingRequired || m_isTextTruncated)
3578 m_isCalculatingPreferredValues =
true;
3582 m_recursiveCount = 0;
3585 m_isPreferredHeightDirty =
false;
3600 float fontSize = m_enableAutoSizing ? m_fontSizeMax : m_fontSize;
3603 m_minFontSize = m_fontSizeMin;
3604 m_maxFontSize = m_fontSizeMax;
3605 m_charWidthAdjDelta = 0;
3607 m_recursiveCount = 0;
3684 if (m_fontAsset ==
null || m_fontAsset.characterDictionary ==
null)
3686 Debug.LogWarning(
"Can't Generate Mesh! No Font Asset has been assigned to Object ID: " + this.GetInstanceID());
3688 return Vector2.zero;
3692 if (m_char_buffer ==
null || m_char_buffer.Length == 0 || m_char_buffer[0] == (
char)0)
3694 return Vector2.zero;
3697 m_currentFontAsset = m_fontAsset;
3698 m_currentMaterial = m_sharedMaterial;
3699 m_currentMaterialIndex = 0;
3703 int totalCharacterCount = m_totalCharacterCount;
3705 if (m_internalCharacterInfo ==
null || totalCharacterCount > m_internalCharacterInfo.Length)
3707 m_internalCharacterInfo =
new TMP_CharacterInfo[totalCharacterCount > 1024 ? totalCharacterCount + 256 : Mathf.NextPowerOfTwo(totalCharacterCount)];
3712 float baseScale = m_fontScale = (defaultFontSize / m_fontAsset.
fontInfo.PointSize * m_fontAsset.
fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f));
3713 float currentElementScale = baseScale;
3714 m_fontScaleMultiplier = 1;
3716 m_currentFontSize = defaultFontSize;
3718 float fontSizeDelta = 0;
3722 m_style = m_fontStyle;
3724 m_lineJustification = m_textAlignment;
3725 m_lineJustificationStack.
SetDefault(m_lineJustification);
3727 float bold_xAdvance_multiplier = 1;
3729 m_baselineOffset = 0;
3730 m_baselineOffsetStack.Clear();
3733 m_lineHeight = TMP_Math.FLOAT_UNSET;
3734 float lineGap = m_currentFontAsset.
fontInfo.LineHeight - (m_currentFontAsset.
fontInfo.Ascender - m_currentFontAsset.
fontInfo.Descender);
3738 float lineOffsetDelta = 0;
3740 float maxXAdvance = 0;
3744 m_indentStack.SetDefault(0);
3745 tag_NoParsing =
false;
3748 m_characterCount = 0;
3752 m_firstCharacterOfLine = 0;
3753 m_maxLineAscender = k_LargeNegativeFloat;
3754 m_maxLineDescender = k_LargePositiveFloat;
3757 float marginWidth = marginSize.x;
3766 float linebreakingWidth = 0;
3767 m_isCalculatingPreferredValues =
true;
3775 bool isFirstWord =
true;
3776 bool isLastBreakingChar =
false;
3780 int wrappingIndex = 0;
3783 m_recursiveCount += 1;
3785 int endTagIndex = 0;
3787 for (
int i = 0; m_char_buffer[i] != 0; i++)
3789 charCode = m_char_buffer[i];
3792 #region Parse Rich Text Tag 3793 if (m_isRichText && charCode == 60)
3795 m_isParsingText =
true;
3796 m_textElementType = TMP_TextElementType.Character;
3804 if (m_textElementType == TMP_TextElementType.Character)
3810 m_textElementType = m_textInfo.characterInfo[m_characterCount].elementType;
3811 m_currentMaterialIndex = m_textInfo.characterInfo[m_characterCount].materialReferenceIndex;
3812 m_currentFontAsset = m_textInfo.characterInfo[m_characterCount].fontAsset;
3814 #endregion End Parse Rich Text Tag 3816 int prev_MaterialIndex = m_currentMaterialIndex;
3817 bool isUsingAltTypeface = m_textInfo.characterInfo[m_characterCount].isUsingAlternateTypeface;
3819 m_isParsingText =
false;
3822 #region Handling of LowerCase, UpperCase and SmallCaps Font Styles 3824 float smallCapsMultiplier = 1.0f;
3826 if (m_textElementType == TMP_TextElementType.Character)
3828 if ((m_style & FontStyles.UpperCase) == FontStyles.UpperCase)
3831 if (
char.IsLower((
char)charCode))
3832 charCode =
char.ToUpper((
char)charCode);
3835 else if ((m_style & FontStyles.LowerCase) == FontStyles.LowerCase)
3838 if (
char.IsUpper((
char)charCode))
3839 charCode =
char.ToLower((
char)charCode);
3841 else if ((m_fontStyle & FontStyles.SmallCaps) == FontStyles.SmallCaps || (m_style & FontStyles.SmallCaps) == FontStyles.SmallCaps)
3843 if (
char.IsLower((
char)charCode))
3845 smallCapsMultiplier = 0.8f;
3846 charCode =
char.ToUpper((
char)charCode);
3854 #region Look up Character Data 3855 if (m_textElementType == TMP_TextElementType.Sprite)
3858 m_currentSpriteAsset = m_textInfo.characterInfo[m_characterCount].spriteAsset;
3859 m_spriteIndex = m_textInfo.characterInfo[m_characterCount].spriteIndex;
3861 TMP_Sprite sprite = m_currentSpriteAsset.spriteInfoList[m_spriteIndex];
3862 if (sprite ==
null)
continue;
3866 charCode = 57344 + m_spriteIndex;
3868 m_currentFontAsset = m_fontAsset;
3873 float spriteScale = (m_currentFontSize / m_fontAsset.
fontInfo.PointSize * m_fontAsset.
fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f));
3874 currentElementScale = m_fontAsset.
fontInfo.Ascender / sprite.height * sprite.scale * spriteScale;
3876 m_cached_TextElement = sprite;
3878 m_internalCharacterInfo[m_characterCount].elementType = TMP_TextElementType.Sprite;
3879 m_internalCharacterInfo[m_characterCount].scale = spriteScale;
3884 m_currentMaterialIndex = prev_MaterialIndex;
3886 else if (m_textElementType == TMP_TextElementType.Character)
3888 m_cached_TextElement = m_textInfo.characterInfo[m_characterCount].textElement;
3889 if (m_cached_TextElement ==
null)
continue;
3893 m_currentMaterialIndex = m_textInfo.characterInfo[m_characterCount].materialReferenceIndex;
3896 m_fontScale = m_currentFontSize * smallCapsMultiplier / m_currentFontAsset.
fontInfo.PointSize * m_currentFontAsset.
fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f);
3898 currentElementScale = m_fontScale * m_fontScaleMultiplier * m_cached_TextElement.scale;
3900 m_internalCharacterInfo[m_characterCount].elementType = TMP_TextElementType.Character;
3907 #region Handle Soft Hyphen 3908 float old_scale = currentElementScale;
3909 if (charCode == 0xAD)
3911 currentElementScale = 0;
3917 m_internalCharacterInfo[m_characterCount].character = (char)charCode;
3921 #region Handle Kerning 3923 if (m_enableKerning)
3927 if (m_characterCount < totalCharacterCount - 1)
3929 uint nextGlyph = m_textInfo.characterInfo[m_characterCount + 1].character;
3932 m_currentFontAsset.
kerningDictionary.TryGetValue((
int)keyValue.key, out adjustmentPair);
3933 if (adjustmentPair !=
null)
3934 glyphAdjustments = adjustmentPair.firstGlyphAdjustments;
3937 if (m_characterCount >= 1)
3939 uint previousGlyph = m_textInfo.characterInfo[m_characterCount - 1].character;
3942 m_currentFontAsset.
kerningDictionary.TryGetValue((
int)keyValue.key, out adjustmentPair);
3943 if (adjustmentPair !=
null)
3944 glyphAdjustments += adjustmentPair.secondGlyphAdjustments;
3951 #region Handle Right-to-Left 3963 #region Handle Mono Spacing 3964 float monoAdvance = 0;
3965 if (m_monoSpacing != 0)
3967 monoAdvance = (m_monoSpacing / 2 - (m_cached_TextElement.width / 2 + m_cached_TextElement.xOffset) * currentElementScale);
3968 m_xAdvance += monoAdvance;
3974 #region Handle Style Padding 3975 if (m_textElementType == TMP_TextElementType.Character && !isUsingAltTypeface && ((m_style & FontStyles.Bold) == FontStyles.Bold || (m_fontStyle & FontStyles.Bold) == FontStyles.Bold))
3978 bold_xAdvance_multiplier = 1 + m_currentFontAsset.boldSpacing * 0.01f;
3983 bold_xAdvance_multiplier = 1.0f;
3985 #endregion Handle Style Padding 3987 m_internalCharacterInfo[m_characterCount].baseLine = 0 - m_lineOffset + m_baselineOffset;
3991 float elementAscender = m_currentFontAsset.
fontInfo.Ascender * (m_textElementType == TMP_TextElementType.Character ? currentElementScale / smallCapsMultiplier : m_internalCharacterInfo[m_characterCount].scale) + m_baselineOffset;
3992 m_internalCharacterInfo[m_characterCount].ascender = elementAscender - m_lineOffset;
3993 m_maxLineAscender = elementAscender > m_maxLineAscender ? elementAscender : m_maxLineAscender;
3996 float elementDescender = m_currentFontAsset.
fontInfo.Descender * (m_textElementType == TMP_TextElementType.Character ? currentElementScale / smallCapsMultiplier: m_internalCharacterInfo[m_characterCount].scale) + m_baselineOffset;
3997 float elementDescenderII = m_internalCharacterInfo[m_characterCount].descender = elementDescender - m_lineOffset;
3998 m_maxLineDescender = elementDescender < m_maxLineDescender ? elementDescender : m_maxLineDescender;
4001 if ((m_style & FontStyles.Subscript) == FontStyles.Subscript || (m_style & FontStyles.Superscript) == FontStyles.Superscript)
4003 float baseAscender = (elementAscender - m_baselineOffset) / m_currentFontAsset.
fontInfo.SubSize;
4004 elementAscender = m_maxLineAscender;
4005 m_maxLineAscender = baseAscender > m_maxLineAscender ? baseAscender : m_maxLineAscender;
4007 float baseDescender = (elementDescender - m_baselineOffset) / m_currentFontAsset.
fontInfo.SubSize;
4008 elementDescender = m_maxLineDescender;
4009 m_maxLineDescender = baseDescender < m_maxLineDescender ? baseDescender : m_maxLineDescender;
4012 if (m_lineNumber == 0) m_maxAscender = m_maxAscender > elementAscender ? m_maxAscender : elementAscender;
4016 #region Handle Visible Characters 4017 if (charCode == 9 || charCode == 0xA0 || charCode == 0x2007 || (!
char.IsWhiteSpace((
char)charCode) && charCode != 0x200B) || m_textElementType == TMP_TextElementType.Sprite)
4020 #region Handle Line Breaking, Text Auto-Sizing and Horizontal Overflow 4021 float width = m_width != -1 ? Mathf.Min(marginWidth + 0.0001f - m_marginLeft - m_marginRight, m_width) : marginWidth + 0.0001f - m_marginLeft - m_marginRight;
4026 linebreakingWidth = m_xAdvance + m_cached_TextElement.xAdvance * (1 - m_charWidthAdjDelta) * (charCode != 0xAD ? currentElementScale : old_scale);
4029 if (linebreakingWidth > width * (isJustifiedOrFlush ? 1.05f : 1.0f))
4032 #region Handle Word Wrapping 4036 #region Line Breaking Check 4037 if (wrappingIndex == savedWordWrapState.previous_WordBreak || isFirstWord)
4040 #region Text Auto-Sizing 4041 if (ignoreTextAutoSizing ==
false && m_currentFontSize > m_fontSizeMin)
4044 #region Character Width Adjustments 4045 if (m_charWidthAdjDelta < m_charWidthMaxAdj / 100)
4047 m_recursiveCount = 0;
4048 m_charWidthAdjDelta += 0.01f;
4054 m_maxFontSize = defaultFontSize;
4056 defaultFontSize -= Mathf.Max((defaultFontSize - m_minFontSize) / 2, 0.05f);
4057 defaultFontSize = (int)(Mathf.Max(defaultFontSize, m_fontSizeMin) * 20 + 0.5f) / 20f;
4065 if (m_isCharacterWrappingEnabled ==
false)
4067 m_isCharacterWrappingEnabled =
true;
4070 isLastBreakingChar =
true;
4079 if (m_char_buffer[i] == 0xAD)
4081 m_isTextTruncated =
true;
4082 m_char_buffer[i] = 0x2D;
4087 if (m_lineNumber > 0 && !TMP_Math.Approximately(m_maxLineAscender, m_startOfLineAscender) && m_lineHeight == TMP_Math.FLOAT_UNSET)
4090 float offsetDelta = m_maxLineAscender - m_startOfLineAscender;
4092 m_lineOffset += offsetDelta;
4093 savedWordWrapState.lineOffset = m_lineOffset;
4094 savedWordWrapState.previousLineAscender = m_maxLineAscender;
4101 float lineAscender = m_maxLineAscender - m_lineOffset;
4102 float lineDescender = m_maxLineDescender - m_lineOffset;
4106 m_maxDescender = m_maxDescender < lineDescender ? m_maxDescender : lineDescender;
4109 m_firstCharacterOfLine = m_characterCount;
4114 if (m_enableWordWrapping)
4131 if (m_lineHeight == TMP_Math.FLOAT_UNSET)
4133 float ascender = m_internalCharacterInfo[m_characterCount].ascender - m_internalCharacterInfo[m_characterCount].baseLine;
4134 lineOffsetDelta = 0 - m_maxLineDescender + ascender + (lineGap + m_lineSpacing + m_lineSpacingDelta) * baseScale;
4135 m_lineOffset += lineOffsetDelta;
4137 m_startOfLineAscender = ascender;
4140 m_lineOffset += m_lineHeight + m_lineSpacing * baseScale;
4142 m_maxLineAscender = k_LargeNegativeFloat;
4143 m_maxLineDescender = k_LargePositiveFloat;
4145 m_xAdvance = 0 + tag_Indent;
4149 #endregion End Word Wrapping 4152 #region Handle Text Auto-Sizing 4153 if (ignoreTextAutoSizing ==
false && defaultFontSize > m_fontSizeMin)
4156 #region Character Width Adjustments 4157 if (m_charWidthAdjDelta < m_charWidthMaxAdj / 100)
4159 m_recursiveCount = 0;
4160 m_charWidthAdjDelta += 0.01f;
4166 m_maxFontSize = defaultFontSize;
4168 defaultFontSize -= Mathf.Max((defaultFontSize - m_minFontSize) / 2, 0.05f);
4169 defaultFontSize = (int)(Mathf.Max(defaultFontSize, m_fontSizeMin) * 20 + 0.5f) / 20f;
4174 #endregion End Text Auto-Sizing 4176 #endregion End Check for Characters Exceeding Width of Text Container 4179 #endregion Handle Visible Characters 4183 #region Adjust Line Spacing 4184 if (m_lineNumber > 0 && !TMP_Math.Approximately(m_maxLineAscender, m_startOfLineAscender) && m_lineHeight == TMP_Math.FLOAT_UNSET && !m_isNewPage)
4189 float offsetDelta = m_maxLineAscender - m_startOfLineAscender;
4191 elementDescenderII -= offsetDelta;
4192 m_lineOffset += offsetDelta;
4194 m_startOfLineAscender += offsetDelta;
4195 savedWordWrapState.lineOffset = m_lineOffset;
4196 savedWordWrapState.previousLineAscender = m_startOfLineAscender;
4202 #region Check Vertical Bounds & Auto-Sizing 4236 #endregion Check Vertical Bounds 4240 #region XAdvance, Tabulation & Stops 4243 float tabSize = m_currentFontAsset.
fontInfo.TabWidth * currentElementScale;
4244 float tabs = Mathf.Ceil(m_xAdvance / tabSize) * tabSize;
4245 m_xAdvance = tabs > m_xAdvance ? tabs : m_xAdvance + tabSize;
4247 else if (m_monoSpacing != 0)
4249 m_xAdvance += (m_monoSpacing - monoAdvance + ((m_characterSpacing + m_currentFontAsset.normalSpacingOffset) * currentElementScale) + m_cSpacing) * (1 - m_charWidthAdjDelta);
4251 if (
char.IsWhiteSpace((
char)charCode) || charCode == 0x200B)
4252 m_xAdvance += m_wordSpacing * currentElementScale;
4256 m_xAdvance += ((m_cached_TextElement.xAdvance * bold_xAdvance_multiplier + m_characterSpacing + m_currentFontAsset.normalSpacingOffset + glyphAdjustments.xAdvance) * currentElementScale + m_cSpacing) * (1 - m_charWidthAdjDelta);
4258 if (
char.IsWhiteSpace((
char)charCode) || charCode == 0x200B)
4259 m_xAdvance += m_wordSpacing * currentElementScale;
4263 #endregion Tabulation & Stops 4267 #region Carriage Return 4270 maxXAdvance = Mathf.Max(maxXAdvance,
renderedWidth + m_xAdvance);
4272 m_xAdvance = 0 + tag_Indent;
4274 #endregion Carriage Return 4278 #region Check for Line Feed and Last Character 4279 if (charCode == 10 || m_characterCount == totalCharacterCount - 1)
4282 if (m_lineNumber > 0 && !TMP_Math.Approximately(m_maxLineAscender, m_startOfLineAscender) && m_lineHeight == TMP_Math.FLOAT_UNSET)
4285 float offsetDelta = m_maxLineAscender - m_startOfLineAscender;
4287 elementDescenderII -= offsetDelta;
4288 m_lineOffset += offsetDelta;
4293 float lineDescender = m_maxLineDescender - m_lineOffset;
4296 m_maxDescender = m_maxDescender < lineDescender ? m_maxDescender : lineDescender;
4298 m_firstCharacterOfLine = m_characterCount + 1;
4301 if (charCode == 10 && m_characterCount != totalCharacterCount - 1)
4303 maxXAdvance = Mathf.Max(maxXAdvance,
renderedWidth + linebreakingWidth);
4324 if (m_lineHeight == TMP_Math.FLOAT_UNSET)
4326 lineOffsetDelta = 0 - m_maxLineDescender + elementAscender + (lineGap + m_lineSpacing + m_paragraphSpacing + m_lineSpacingDelta) * baseScale;
4327 m_lineOffset += lineOffsetDelta;
4330 m_lineOffset += m_lineHeight + (m_lineSpacing + m_paragraphSpacing) * baseScale;
4332 m_maxLineAscender = k_LargeNegativeFloat;
4333 m_maxLineDescender = k_LargePositiveFloat;
4334 m_startOfLineAscender = elementAscender;
4336 m_xAdvance = 0 + tag_LineIndent + tag_Indent;
4338 m_characterCount += 1;
4342 #endregion Check for Linefeed or Last Character 4346 #region Save Word Wrapping State 4347 if (m_enableWordWrapping || m_overflowMode == TextOverflowModes.Truncate || m_overflowMode == TextOverflowModes.Ellipsis)
4349 if ((
char.IsWhiteSpace((
char)charCode) || charCode == 0x200B || charCode == 0x2D || charCode == 0xAD) && !m_isNonBreakingSpace && charCode != 0xA0 && charCode != 0x2011 && charCode != 0x202F && charCode != 0x2060)
4354 m_isCharacterWrappingEnabled =
false;
4355 isFirstWord =
false;
4358 else if ((charCode > 0x1100 && charCode < 0x11ff ||
4359 charCode > 0x2E80 && charCode < 0x9FFF ||
4360 charCode > 0xA960 && charCode < 0xA97F ||
4361 charCode > 0xAC00 && charCode < 0xD7FF ||
4362 charCode > 0xF900 && charCode < 0xFAFF ||
4363 charCode > 0xFE30 && charCode < 0xFE4F ||
4364 charCode > 0xFF00 && charCode < 0xFFEF)
4365 && !m_isNonBreakingSpace)
4368 (m_characterCount < totalCharacterCount - 1 &&
4372 m_isCharacterWrappingEnabled =
false;
4373 isFirstWord =
false;
4376 else if ((isFirstWord || m_isCharacterWrappingEnabled ==
true || isLastBreakingChar))
4379 #endregion Save Word Wrapping State 4381 m_characterCount += 1;
4385 #region Check Auto-Sizing (Upper Font Size Bounds) 4386 fontSizeDelta = m_maxFontSize - m_minFontSize;
4387 if (!m_isCharacterWrappingEnabled && ignoreTextAutoSizing ==
false && fontSizeDelta > 0.051f && defaultFontSize < m_fontSizeMax)
4389 m_minFontSize = defaultFontSize;
4390 defaultFontSize += Mathf.Max((m_maxFontSize - defaultFontSize) / 2, 0.05f);
4391 defaultFontSize = (int)(Mathf.Min(defaultFontSize, m_fontSizeMax) * 20 + 0.5f) / 20f;
4396 #endregion End Auto-sizing Check 4399 m_isCharacterWrappingEnabled =
false;
4400 m_isCalculatingPreferredValues =
false;
4433 if (m_textInfo ==
null || m_textInfo.characterCount > m_textInfo.characterInfo.Length)
return new Bounds();
4435 Extents extent =
new Extents(k_LargePositiveVector2, k_LargeNegativeVector2);
4437 for (
int i = 0; i < m_textInfo.characterCount && i < m_textInfo.characterInfo.Length; i++)
4439 if (!m_textInfo.characterInfo[i].isVisible)
continue;
4441 extent.min.x = Mathf.Min(extent.min.x, m_textInfo.characterInfo[i].bottomLeft.x);
4442 extent.min.y = Mathf.Min(extent.min.y, m_textInfo.characterInfo[i].descender);
4444 extent.max.x = Mathf.Max(extent.max.x, m_textInfo.characterInfo[i].xAdvance);
4445 extent.max.y = Mathf.Max(extent.max.y, m_textInfo.characterInfo[i].ascender);
4449 size.x = extent.max.x - extent.min.x;
4450 size.y = extent.max.y - extent.min.y;
4452 Vector3 center = (extent.min + extent.max) / 2;
4454 return new Bounds(center, size);
4465 if (m_textInfo ==
null)
return new Bounds();
4467 Extents extent =
new Extents(k_LargePositiveVector2, k_LargeNegativeVector2);
4469 for (
int i = 0; i < m_textInfo.characterCount; i++)
4471 if ((i >
maxVisibleCharacters || m_textInfo.characterInfo[i].lineNumber > m_maxVisibleLines) && onlyVisibleCharacters)
break;
4473 if (onlyVisibleCharacters && !m_textInfo.characterInfo[i].isVisible)
continue;
4475 extent.min.x = Mathf.Min(extent.min.x, m_textInfo.characterInfo[i].origin);
4476 extent.min.y = Mathf.Min(extent.min.y, m_textInfo.characterInfo[i].descender);
4478 extent.max.x = Mathf.Max(extent.max.x, m_textInfo.characterInfo[i].xAdvance);
4479 extent.max.y = Mathf.Max(extent.max.y, m_textInfo.characterInfo[i].ascender);
4483 size.x = extent.max.x - extent.min.x;
4484 size.y = extent.max.y - extent.min.y;
4486 Vector2 center = (extent.min + extent.max) / 2;
4488 return new Bounds(center, size);
4507 size = size > 1024 ? size + 256 : Mathf.NextPowerOfTwo(size + 1);
4510 for (
int i = 0; i < size; i++)
4512 if (i < m_textInfo.lineInfo.Length)
4513 temp_lineInfo[i] = m_textInfo.lineInfo[i];
4516 temp_lineInfo[i].lineExtents.min = k_LargePositiveVector2;
4517 temp_lineInfo[i].lineExtents.max = k_LargeNegativeVector2;
4519 temp_lineInfo[i].ascender = k_LargeNegativeFloat;
4520 temp_lineInfo[i].descender = k_LargePositiveFloat;
4524 m_textInfo.lineInfo = temp_lineInfo;
4526 protected static Vector2 k_LargePositiveVector2 =
new Vector2(TMP_Math.INT_MAX, TMP_Math.INT_MAX);
4527 protected static Vector2 k_LargeNegativeVector2 =
new Vector2(TMP_Math.INT_MIN, TMP_Math.INT_MIN);
4528 protected static float k_LargePositiveFloat = TMP_Math.FLOAT_MAX;
4529 protected static float k_LargeNegativeFloat = TMP_Math.FLOAT_MIN;
4530 protected static int k_LargePositiveInt = TMP_Math.INT_MAX;
4531 protected static int k_LargeNegativeInt = TMP_Math.INT_MIN;
4607 state.currentFontAsset = m_currentFontAsset;
4608 state.currentSpriteAsset = m_currentSpriteAsset;
4609 state.currentMaterial = m_currentMaterial;
4610 state.currentMaterialIndex = m_currentMaterialIndex;
4612 state.previous_WordBreak = index;
4613 state.total_CharacterCount = count;
4614 state.visible_CharacterCount = m_lineVisibleCharacterCount;
4617 state.visible_LinkCount = m_textInfo.linkCount;
4619 state.firstCharacterIndex = m_firstCharacterOfLine;
4620 state.firstVisibleCharacterIndex = m_firstVisibleCharacterOfLine;
4621 state.lastVisibleCharIndex = m_lastVisibleCharacterOfLine;
4623 state.fontStyle = m_style;
4624 state.fontScale = m_fontScale;
4626 state.fontScaleMultiplier = m_fontScaleMultiplier;
4627 state.currentFontSize = m_currentFontSize;
4629 state.xAdvance = m_xAdvance;
4630 state.maxCapHeight = m_maxCapHeight;
4631 state.maxAscender = m_maxAscender;
4632 state.maxDescender = m_maxDescender;
4633 state.maxLineAscender = m_maxLineAscender;
4634 state.maxLineDescender = m_maxLineDescender;
4635 state.previousLineAscender = m_startOfLineAscender;
4636 state.preferredWidth = m_preferredWidth;
4637 state.preferredHeight = m_preferredHeight;
4638 state.meshExtents = m_meshExtents;
4640 state.lineNumber = m_lineNumber;
4641 state.lineOffset = m_lineOffset;
4642 state.baselineOffset = m_baselineOffset;
4645 state.vertexColor = m_htmlColor;
4646 state.underlineColor = m_underlineColor;
4647 state.strikethroughColor = m_strikethroughColor;
4648 state.highlightColor = m_highlightColor;
4650 state.isNonBreakingSpace = m_isNonBreakingSpace;
4651 state.tagNoParsing = tag_NoParsing;
4654 state.basicStyleStack = m_fontStyleStack;
4655 state.colorStack = m_colorStack;
4656 state.underlineColorStack = m_underlineColorStack;
4657 state.strikethroughColorStack = m_strikethroughColorStack;
4658 state.highlightColorStack = m_highlightColorStack;
4659 state.colorGradientStack = m_colorGradientStack;
4660 state.sizeStack = m_sizeStack;
4661 state.indentStack = m_indentStack;
4662 state.fontWeightStack = m_fontWeightStack;
4663 state.styleStack = m_styleStack;
4664 state.baselineStack = m_baselineOffsetStack;
4665 state.actionStack = m_actionStack;
4666 state.materialReferenceStack = m_materialReferenceStack;
4667 state.lineJustificationStack = m_lineJustificationStack;
4670 state.spriteAnimationID = m_spriteAnimationID;
4672 if (m_lineNumber < m_textInfo.lineInfo.Length)
4673 state.lineInfo = m_textInfo.lineInfo[m_lineNumber];
4684 int index = state.previous_WordBreak;
4687 m_currentFontAsset = state.currentFontAsset;
4688 m_currentSpriteAsset = state.currentSpriteAsset;
4689 m_currentMaterial = state.currentMaterial;
4690 m_currentMaterialIndex = state.currentMaterialIndex;
4692 m_characterCount = state.total_CharacterCount + 1;
4693 m_lineVisibleCharacterCount = state.visible_CharacterCount;
4696 m_textInfo.linkCount = state.visible_LinkCount;
4698 m_firstCharacterOfLine = state.firstCharacterIndex;
4699 m_firstVisibleCharacterOfLine = state.firstVisibleCharacterIndex;
4700 m_lastVisibleCharacterOfLine = state.lastVisibleCharIndex;
4702 m_style = state.fontStyle;
4703 m_fontScale = state.fontScale;
4704 m_fontScaleMultiplier = state.fontScaleMultiplier;
4706 m_currentFontSize = state.currentFontSize;
4708 m_xAdvance = state.xAdvance;
4709 m_maxCapHeight = state.maxCapHeight;
4710 m_maxAscender = state.maxAscender;
4711 m_maxDescender = state.maxDescender;
4712 m_maxLineAscender = state.maxLineAscender;
4713 m_maxLineDescender = state.maxLineDescender;
4714 m_startOfLineAscender = state.previousLineAscender;
4715 m_preferredWidth = state.preferredWidth;
4716 m_preferredHeight = state.preferredHeight;
4717 m_meshExtents = state.meshExtents;
4719 m_lineNumber = state.lineNumber;
4720 m_lineOffset = state.lineOffset;
4721 m_baselineOffset = state.baselineOffset;
4724 m_htmlColor = state.vertexColor;
4725 m_underlineColor = state.underlineColor;
4726 m_strikethroughColor = state.strikethroughColor;
4727 m_highlightColor = state.highlightColor;
4729 m_isNonBreakingSpace = state.isNonBreakingSpace;
4730 tag_NoParsing = state.tagNoParsing;
4733 m_fontStyleStack = state.basicStyleStack;
4734 m_colorStack = state.colorStack;
4735 m_underlineColorStack = state.underlineColorStack;
4736 m_strikethroughColorStack = state.strikethroughColorStack;
4737 m_highlightColorStack = state.highlightColorStack;
4738 m_colorGradientStack = state.colorGradientStack;
4739 m_sizeStack = state.sizeStack;
4740 m_indentStack = state.indentStack;
4741 m_fontWeightStack = state.fontWeightStack;
4742 m_styleStack = state.styleStack;
4743 m_baselineOffsetStack = state.baselineStack;
4744 m_actionStack = state.actionStack;
4745 m_materialReferenceStack = state.materialReferenceStack;
4746 m_lineJustificationStack = state.lineJustificationStack;
4749 m_spriteAnimationID = state.spriteAnimationID;
4751 if (m_lineNumber < m_textInfo.lineInfo.Length)
4752 m_textInfo.lineInfo[m_lineNumber] = state.lineInfo;
4766 #region Setup Mesh Vertices 4767 m_textInfo.characterInfo[m_characterCount].vertex_BL.position = m_textInfo.characterInfo[m_characterCount].bottomLeft;
4768 m_textInfo.characterInfo[m_characterCount].vertex_TL.position = m_textInfo.characterInfo[m_characterCount].topLeft;
4769 m_textInfo.characterInfo[m_characterCount].vertex_TR.position = m_textInfo.characterInfo[m_characterCount].topRight;
4770 m_textInfo.characterInfo[m_characterCount].vertex_BR.position = m_textInfo.characterInfo[m_characterCount].bottomRight;
4774 #region Setup Vertex Colors 4776 vertexColor.a = m_fontColor32.a < vertexColor.a ? (byte)(m_fontColor32.a) : (byte)(vertexColor.a);
4779 if (!m_enableVertexGradient)
4781 m_textInfo.characterInfo[m_characterCount].vertex_BL.color = vertexColor;
4782 m_textInfo.characterInfo[m_characterCount].vertex_TL.color = vertexColor;
4783 m_textInfo.characterInfo[m_characterCount].vertex_TR.color = vertexColor;
4784 m_textInfo.characterInfo[m_characterCount].vertex_BR.color = vertexColor;
4788 if (!m_overrideHtmlColors && m_colorStack.index > 1)
4790 m_textInfo.characterInfo[m_characterCount].vertex_BL.color = vertexColor;
4791 m_textInfo.characterInfo[m_characterCount].vertex_TL.color = vertexColor;
4792 m_textInfo.characterInfo[m_characterCount].vertex_TR.color = vertexColor;
4793 m_textInfo.characterInfo[m_characterCount].vertex_BR.color = vertexColor;
4798 if (m_fontColorGradientPreset !=
null)
4800 m_textInfo.characterInfo[m_characterCount].vertex_BL.color = m_fontColorGradientPreset.bottomLeft * vertexColor;
4801 m_textInfo.characterInfo[m_characterCount].vertex_TL.color = m_fontColorGradientPreset.topLeft * vertexColor;
4802 m_textInfo.characterInfo[m_characterCount].vertex_TR.color = m_fontColorGradientPreset.topRight * vertexColor;
4803 m_textInfo.characterInfo[m_characterCount].vertex_BR.color = m_fontColorGradientPreset.bottomRight * vertexColor;
4807 m_textInfo.characterInfo[m_characterCount].vertex_BL.color = m_fontColorGradient.bottomLeft * vertexColor;
4808 m_textInfo.characterInfo[m_characterCount].vertex_TL.color = m_fontColorGradient.topLeft * vertexColor;
4809 m_textInfo.characterInfo[m_characterCount].vertex_TR.color = m_fontColorGradient.topRight * vertexColor;
4810 m_textInfo.characterInfo[m_characterCount].vertex_BR.color = m_fontColorGradient.bottomRight * vertexColor;
4815 if (m_colorGradientPreset !=
null)
4817 m_textInfo.characterInfo[m_characterCount].vertex_BL.color *= m_colorGradientPreset.bottomLeft;
4818 m_textInfo.characterInfo[m_characterCount].vertex_TL.color *= m_colorGradientPreset.topLeft;
4819 m_textInfo.characterInfo[m_characterCount].vertex_TR.color *= m_colorGradientPreset.topRight;
4820 m_textInfo.characterInfo[m_characterCount].vertex_BR.color *= m_colorGradientPreset.bottomRight;
4834 uv0.x = (m_cached_TextElement.x - padding - style_padding) / faceInfo.AtlasWidth;
4835 uv0.y = 1 - (m_cached_TextElement.y + padding + style_padding + m_cached_TextElement.height) / faceInfo.AtlasHeight;
4839 uv1.y = 1 - (m_cached_TextElement.y - padding - style_padding) / faceInfo.AtlasHeight;
4842 uv2.x = (m_cached_TextElement.x + padding + style_padding + m_cached_TextElement.width) / faceInfo.AtlasWidth;
4855 m_textInfo.characterInfo[m_characterCount].vertex_BL.uv = uv0;
4856 m_textInfo.characterInfo[m_characterCount].vertex_TL.uv = uv1;
4857 m_textInfo.characterInfo[m_characterCount].vertex_TR.uv = uv2;
4858 m_textInfo.characterInfo[m_characterCount].vertex_BR.uv = uv3;
4859 #endregion Setup UVs 4863 #region Setup Normals & Tangents 4876 #endregion end Normals & Tangents 4889 #region Setup Mesh Vertices 4890 m_textInfo.characterInfo[m_characterCount].vertex_BL.position = m_textInfo.characterInfo[m_characterCount].bottomLeft;
4891 m_textInfo.characterInfo[m_characterCount].vertex_TL.position = m_textInfo.characterInfo[m_characterCount].topLeft;
4892 m_textInfo.characterInfo[m_characterCount].vertex_TR.position = m_textInfo.characterInfo[m_characterCount].topRight;
4893 m_textInfo.characterInfo[m_characterCount].vertex_BR.position = m_textInfo.characterInfo[m_characterCount].bottomRight;
4897 if (m_tintAllSprites) m_tintSprite =
true;
4898 Color32 spriteColor = m_tintSprite ? m_spriteColor.Multiply(vertexColor) : m_spriteColor;
4899 spriteColor.a = spriteColor.a < m_fontColor32.a ? spriteColor.a = spriteColor.a < vertexColor.a ? spriteColor.a : vertexColor.a : m_fontColor32.a;
4901 Color32 c0 = spriteColor;
4902 Color32 c1 = spriteColor;
4903 Color32 c2 = spriteColor;
4904 Color32 c3 = spriteColor;
4906 if (m_enableVertexGradient)
4908 if (m_fontColorGradientPreset !=
null)
4910 c0 = m_tintSprite ? c0.Multiply(m_fontColorGradientPreset.bottomLeft) : c0;
4911 c1 = m_tintSprite ? c1.Multiply(m_fontColorGradientPreset.topLeft) : c1;
4912 c2 = m_tintSprite ? c2.Multiply(m_fontColorGradientPreset.topRight) : c2;
4913 c3 = m_tintSprite ? c3.Multiply(m_fontColorGradientPreset.bottomRight) : c3;
4917 c0 = m_tintSprite ? c0.Multiply(m_fontColorGradient.bottomLeft) : c0;
4918 c1 = m_tintSprite ? c1.Multiply(m_fontColorGradient.topLeft) : c1;
4919 c2 = m_tintSprite ? c2.Multiply(m_fontColorGradient.topRight) : c2;
4920 c3 = m_tintSprite ? c3.Multiply(m_fontColorGradient.bottomRight) : c3;
4924 if (m_colorGradientPreset !=
null)
4926 c0 = m_tintSprite ? c0.Multiply(m_colorGradientPreset.bottomLeft) : c0;
4927 c1 = m_tintSprite ? c1.Multiply(m_colorGradientPreset.topLeft) : c1;
4928 c2 = m_tintSprite ? c2.Multiply(m_colorGradientPreset.topRight) : c2;
4929 c3 = m_tintSprite ? c3.Multiply(m_colorGradientPreset.bottomRight) : c3;
4932 m_textInfo.characterInfo[m_characterCount].vertex_BL.color = c0;
4933 m_textInfo.characterInfo[m_characterCount].vertex_TL.color = c1;
4934 m_textInfo.characterInfo[m_characterCount].vertex_TR.color = c2;
4935 m_textInfo.characterInfo[m_characterCount].vertex_BR.color = c3;
4940 Vector2 uv0 =
new Vector2(m_cached_TextElement.x / m_currentSpriteAsset.spriteSheet.width, m_cached_TextElement.y / m_currentSpriteAsset.spriteSheet.height);
4941 Vector2 uv1 =
new Vector2(uv0.x, (m_cached_TextElement.y + m_cached_TextElement.height) / m_currentSpriteAsset.spriteSheet.height);
4942 Vector2 uv2 =
new Vector2((m_cached_TextElement.x + m_cached_TextElement.width) / m_currentSpriteAsset.spriteSheet.width, uv1.y);
4943 Vector2 uv3 =
new Vector2(uv2.x, uv0.y);
4946 m_textInfo.characterInfo[m_characterCount].vertex_BL.uv = uv0;
4947 m_textInfo.characterInfo[m_characterCount].vertex_TL.uv = uv1;
4948 m_textInfo.characterInfo[m_characterCount].vertex_TR.uv = uv2;
4949 m_textInfo.characterInfo[m_characterCount].vertex_BR.uv = uv3;
4950 #endregion Setup UVs 4954 #region Setup Normals & Tangents 4967 #endregion end Normals & Tangents 4979 int materialIndex = m_textInfo.characterInfo[i].materialReferenceIndex;
4980 index_X4 = m_textInfo.meshInfo[materialIndex].vertexCount;
4988 m_textInfo.characterInfo[i].vertexIndex = index_X4;
4991 m_textInfo.meshInfo[materialIndex].vertices[0 + index_X4] = characterInfoArray[i].vertex_BL.position;
4992 m_textInfo.meshInfo[materialIndex].vertices[1 + index_X4] = characterInfoArray[i].vertex_TL.position;
4993 m_textInfo.meshInfo[materialIndex].vertices[2 + index_X4] = characterInfoArray[i].vertex_TR.position;
4994 m_textInfo.meshInfo[materialIndex].vertices[3 + index_X4] = characterInfoArray[i].vertex_BR.position;
4998 m_textInfo.meshInfo[materialIndex].uvs0[0 + index_X4] = characterInfoArray[i].vertex_BL.uv;
4999 m_textInfo.meshInfo[materialIndex].uvs0[1 + index_X4] = characterInfoArray[i].vertex_TL.uv;
5000 m_textInfo.meshInfo[materialIndex].uvs0[2 + index_X4] = characterInfoArray[i].vertex_TR.uv;
5001 m_textInfo.meshInfo[materialIndex].uvs0[3 + index_X4] = characterInfoArray[i].vertex_BR.uv;
5005 m_textInfo.meshInfo[materialIndex].uvs2[0 + index_X4] = characterInfoArray[i].vertex_BL.uv2;
5006 m_textInfo.meshInfo[materialIndex].uvs2[1 + index_X4] = characterInfoArray[i].vertex_TL.uv2;
5007 m_textInfo.meshInfo[materialIndex].uvs2[2 + index_X4] = characterInfoArray[i].vertex_TR.uv2;
5008 m_textInfo.meshInfo[materialIndex].uvs2[3 + index_X4] = characterInfoArray[i].vertex_BR.uv2;
5019 m_textInfo.meshInfo[materialIndex].colors32[0 + index_X4] = characterInfoArray[i].vertex_BL.color;
5020 m_textInfo.meshInfo[materialIndex].colors32[1 + index_X4] = characterInfoArray[i].vertex_TL.color;
5021 m_textInfo.meshInfo[materialIndex].colors32[2 + index_X4] = characterInfoArray[i].vertex_TR.color;
5022 m_textInfo.meshInfo[materialIndex].colors32[3 + index_X4] = characterInfoArray[i].vertex_BR.color;
5024 m_textInfo.meshInfo[materialIndex].vertexCount = index_X4 + 4;
5030 int materialIndex = m_textInfo.characterInfo[i].materialReferenceIndex;
5031 index_X4 = m_textInfo.meshInfo[materialIndex].vertexCount;
5034 m_textInfo.characterInfo[i].vertexIndex = index_X4;
5037 m_textInfo.meshInfo[materialIndex].vertices[0 + index_X4] = characterInfoArray[i].vertex_BL.position;
5038 m_textInfo.meshInfo[materialIndex].vertices[1 + index_X4] = characterInfoArray[i].vertex_TL.position;
5039 m_textInfo.meshInfo[materialIndex].vertices[2 + index_X4] = characterInfoArray[i].vertex_TR.position;
5040 m_textInfo.meshInfo[materialIndex].vertices[3 + index_X4] = characterInfoArray[i].vertex_BR.position;
5044 Vector3 depth =
new Vector3(0, 0, m_fontSize * m_fontScale);
5045 m_textInfo.meshInfo[materialIndex].vertices[4 + index_X4] = characterInfoArray[i].vertex_BL.position + depth;
5046 m_textInfo.meshInfo[materialIndex].vertices[5 + index_X4] = characterInfoArray[i].vertex_TL.position + depth;
5047 m_textInfo.meshInfo[materialIndex].vertices[6 + index_X4] = characterInfoArray[i].vertex_TR.position + depth;
5048 m_textInfo.meshInfo[materialIndex].vertices[7 + index_X4] = characterInfoArray[i].vertex_BR.position + depth;
5052 m_textInfo.meshInfo[materialIndex].uvs0[0 + index_X4] = characterInfoArray[i].vertex_BL.uv;
5053 m_textInfo.meshInfo[materialIndex].uvs0[1 + index_X4] = characterInfoArray[i].vertex_TL.uv;
5054 m_textInfo.meshInfo[materialIndex].uvs0[2 + index_X4] = characterInfoArray[i].vertex_TR.uv;
5055 m_textInfo.meshInfo[materialIndex].uvs0[3 + index_X4] = characterInfoArray[i].vertex_BR.uv;
5059 m_textInfo.meshInfo[materialIndex].uvs0[4 + index_X4] = characterInfoArray[i].vertex_BL.uv;
5060 m_textInfo.meshInfo[materialIndex].uvs0[5 + index_X4] = characterInfoArray[i].vertex_TL.uv;
5061 m_textInfo.meshInfo[materialIndex].uvs0[6 + index_X4] = characterInfoArray[i].vertex_TR.uv;
5062 m_textInfo.meshInfo[materialIndex].uvs0[7 + index_X4] = characterInfoArray[i].vertex_BR.uv;
5067 m_textInfo.meshInfo[materialIndex].uvs2[0 + index_X4] = characterInfoArray[i].vertex_BL.uv2;
5068 m_textInfo.meshInfo[materialIndex].uvs2[1 + index_X4] = characterInfoArray[i].vertex_TL.uv2;
5069 m_textInfo.meshInfo[materialIndex].uvs2[2 + index_X4] = characterInfoArray[i].vertex_TR.uv2;
5070 m_textInfo.meshInfo[materialIndex].uvs2[3 + index_X4] = characterInfoArray[i].vertex_BR.uv2;
5074 m_textInfo.meshInfo[materialIndex].uvs2[4 + index_X4] = characterInfoArray[i].vertex_BL.uv2;
5075 m_textInfo.meshInfo[materialIndex].uvs2[5 + index_X4] = characterInfoArray[i].vertex_TL.uv2;
5076 m_textInfo.meshInfo[materialIndex].uvs2[6 + index_X4] = characterInfoArray[i].vertex_TR.uv2;
5077 m_textInfo.meshInfo[materialIndex].uvs2[7 + index_X4] = characterInfoArray[i].vertex_BR.uv2;
5089 m_textInfo.meshInfo[materialIndex].colors32[0 + index_X4] = characterInfoArray[i].vertex_BL.color;
5090 m_textInfo.meshInfo[materialIndex].colors32[1 + index_X4] = characterInfoArray[i].vertex_TL.color;
5091 m_textInfo.meshInfo[materialIndex].colors32[2 + index_X4] = characterInfoArray[i].vertex_TR.color;
5092 m_textInfo.meshInfo[materialIndex].colors32[3 + index_X4] = characterInfoArray[i].vertex_BR.color;
5096 Color32 backColor =
new Color32(255, 255, 128, 255);
5097 m_textInfo.meshInfo[materialIndex].colors32[4 + index_X4] = backColor;
5098 m_textInfo.meshInfo[materialIndex].colors32[5 + index_X4] = backColor;
5099 m_textInfo.meshInfo[materialIndex].colors32[6 + index_X4] = backColor;
5100 m_textInfo.meshInfo[materialIndex].colors32[7 + index_X4] = backColor;
5103 m_textInfo.meshInfo[materialIndex].vertexCount = index_X4 + (!isVolumetric ? 4 : 8);
5114 int materialIndex = m_textInfo.characterInfo[i].materialReferenceIndex;
5115 index_X4 = m_textInfo.meshInfo[materialIndex].vertexCount;
5118 m_textInfo.characterInfo[i].vertexIndex = index_X4;
5121 m_textInfo.meshInfo[materialIndex].vertices[0 + index_X4] = characterInfoArray[i].vertex_BL.position;
5122 m_textInfo.meshInfo[materialIndex].vertices[1 + index_X4] = characterInfoArray[i].vertex_TL.position;
5123 m_textInfo.meshInfo[materialIndex].vertices[2 + index_X4] = characterInfoArray[i].vertex_TR.position;
5124 m_textInfo.meshInfo[materialIndex].vertices[3 + index_X4] = characterInfoArray[i].vertex_BR.position;
5128 m_textInfo.meshInfo[materialIndex].uvs0[0 + index_X4] = characterInfoArray[i].vertex_BL.uv;
5129 m_textInfo.meshInfo[materialIndex].uvs0[1 + index_X4] = characterInfoArray[i].vertex_TL.uv;
5130 m_textInfo.meshInfo[materialIndex].uvs0[2 + index_X4] = characterInfoArray[i].vertex_TR.uv;
5131 m_textInfo.meshInfo[materialIndex].uvs0[3 + index_X4] = characterInfoArray[i].vertex_BR.uv;
5135 m_textInfo.meshInfo[materialIndex].uvs2[0 + index_X4] = characterInfoArray[i].vertex_BL.uv2;
5136 m_textInfo.meshInfo[materialIndex].uvs2[1 + index_X4] = characterInfoArray[i].vertex_TL.uv2;
5137 m_textInfo.meshInfo[materialIndex].uvs2[2 + index_X4] = characterInfoArray[i].vertex_TR.uv2;
5138 m_textInfo.meshInfo[materialIndex].uvs2[3 + index_X4] = characterInfoArray[i].vertex_BR.uv2;
5149 m_textInfo.meshInfo[materialIndex].colors32[0 + index_X4] = characterInfoArray[i].vertex_BL.color;
5150 m_textInfo.meshInfo[materialIndex].colors32[1 + index_X4] = characterInfoArray[i].vertex_TL.color;
5151 m_textInfo.meshInfo[materialIndex].colors32[2 + index_X4] = characterInfoArray[i].vertex_TR.color;
5152 m_textInfo.meshInfo[materialIndex].colors32[3 + index_X4] = characterInfoArray[i].vertex_BR.color;
5154 m_textInfo.meshInfo[materialIndex].vertexCount = index_X4 + 4;
5167 protected virtual void DrawUnderlineMesh(Vector3 start, Vector3 end, ref
int index,
float startScale,
float endScale,
float maxScale,
float sdfScale, Color32 underlineColor)
5169 if (m_cached_Underline_GlyphInfo ==
null)
5171 if (!
TMP_Settings.
warningsDisabled) Debug.LogWarning(
"Unable to add underline since the Font Asset doesn't contain the underline character.",
this);
5175 int verticesCount = index + 12;
5177 if (verticesCount > m_textInfo.meshInfo[0].vertices.Length)
5184 start.y = Mathf.Min(start.y, end.y);
5185 end.y = Mathf.Min(start.y, end.y);
5187 float segmentWidth = m_cached_Underline_GlyphInfo.width / 2 * maxScale;
5189 if (end.x - start.x < m_cached_Underline_GlyphInfo.width * maxScale)
5191 segmentWidth = (end.x - start.x) / 2f;
5194 float startPadding = m_padding * startScale / maxScale;
5195 float endPadding = m_padding * endScale / maxScale;
5197 float underlineThickness = m_cached_Underline_GlyphInfo.height;
5200 #region UNDERLINE VERTICES 5201 Vector3[] vertices = m_textInfo.meshInfo[0].vertices;
5204 vertices[index + 0] = start +
new Vector3(0, 0 - (underlineThickness + m_padding) * maxScale, 0);
5205 vertices[index + 1] = start +
new Vector3(0, m_padding * maxScale, 0);
5206 vertices[index + 2] = vertices[index + 1] +
new Vector3(segmentWidth, 0, 0);
5207 vertices[index + 3] = vertices[index + 0] +
new Vector3(segmentWidth, 0, 0);
5210 vertices[index + 4] = vertices[index + 3];
5211 vertices[index + 5] = vertices[index + 2];
5212 vertices[index + 6] = end +
new Vector3(-segmentWidth, m_padding * maxScale, 0);
5213 vertices[index + 7] = end +
new Vector3(-segmentWidth, -(underlineThickness + m_padding) * maxScale, 0);
5216 vertices[index + 8] = vertices[index + 7];
5217 vertices[index + 9] = vertices[index + 6];
5218 vertices[index + 10] = end +
new Vector3(0, m_padding * maxScale, 0);
5219 vertices[index + 11] = end +
new Vector3(0, -(underlineThickness + m_padding) * maxScale, 0);
5224 Vector2[] uvs0 = m_textInfo.meshInfo[0].uvs0;
5227 Vector2 uv0 =
new Vector2((m_cached_Underline_GlyphInfo.x - startPadding) / m_fontAsset.
fontInfo.AtlasWidth, 1 - (m_cached_Underline_GlyphInfo.y + m_padding + m_cached_Underline_GlyphInfo.height) / m_fontAsset.
fontInfo.AtlasHeight);
5228 Vector2 uv1 =
new Vector2(uv0.x, 1 - (m_cached_Underline_GlyphInfo.y - m_padding) / m_fontAsset.
fontInfo.AtlasHeight);
5229 Vector2 uv2 =
new Vector2((m_cached_Underline_GlyphInfo.x - startPadding + m_cached_Underline_GlyphInfo.width / 2) / m_fontAsset.
fontInfo.AtlasWidth, uv1.y);
5230 Vector2 uv3 =
new Vector2(uv2.x, uv0.y);
5231 Vector2 uv4 =
new Vector2((m_cached_Underline_GlyphInfo.x + endPadding + m_cached_Underline_GlyphInfo.width / 2) / m_fontAsset.
fontInfo.AtlasWidth, uv1.y);
5232 Vector2 uv5 =
new Vector2(uv4.x, uv0.y);
5233 Vector2 uv6 =
new Vector2((m_cached_Underline_GlyphInfo.x + endPadding + m_cached_Underline_GlyphInfo.width) / m_fontAsset.
fontInfo.AtlasWidth, uv1.y);
5234 Vector2 uv7 =
new Vector2(uv6.x, uv0.y);
5237 uvs0[0 + index] = uv0;
5238 uvs0[1 + index] = uv1;
5239 uvs0[2 + index] = uv2;
5240 uvs0[3 + index] = uv3;
5243 uvs0[4 + index] =
new Vector2(uv2.x - uv2.x * 0.001f, uv0.y);
5244 uvs0[5 + index] =
new Vector2(uv2.x - uv2.x * 0.001f, uv1.y);
5245 uvs0[6 + index] =
new Vector2(uv2.x + uv2.x * 0.001f, uv1.y);
5246 uvs0[7 + index] =
new Vector2(uv2.x + uv2.x * 0.001f, uv0.y);
5249 uvs0[8 + index] = uv5;
5250 uvs0[9 + index] = uv4;
5251 uvs0[10 + index] = uv6;
5252 uvs0[11 + index] = uv7;
5256 #region HANDLE UV2 - SDF SCALE 5259 float max_UvX = (vertices[index + 2].x - start.x) / (end.x - start.x);
5262 float xScale = Mathf.Abs(sdfScale);
5264 Vector2[] uvs2 = m_textInfo.meshInfo[0].uvs2;
5266 uvs2[0 + index] =
PackUV(0, 0, xScale);
5267 uvs2[1 + index] =
PackUV(0, 1, xScale);
5268 uvs2[2 + index] =
PackUV(max_UvX, 1, xScale);
5269 uvs2[3 + index] =
PackUV(max_UvX, 0, xScale);
5271 min_UvX = (vertices[index + 4].x - start.x) / (end.x - start.x);
5272 max_UvX = (vertices[index + 6].x - start.x) / (end.x - start.x);
5274 uvs2[4 + index] =
PackUV(min_UvX, 0, xScale);
5275 uvs2[5 + index] =
PackUV(min_UvX, 1, xScale);
5276 uvs2[6 + index] =
PackUV(max_UvX, 1, xScale);
5277 uvs2[7 + index] =
PackUV(max_UvX, 0, xScale);
5279 min_UvX = (vertices[index + 8].x - start.x) / (end.x - start.x);
5280 max_UvX = (vertices[index + 6].x - start.x) / (end.x - start.x);
5282 uvs2[8 + index] =
PackUV(min_UvX, 0, xScale);
5283 uvs2[9 + index] =
PackUV(min_UvX, 1, xScale);
5284 uvs2[10 + index] =
PackUV(1, 1, xScale);
5285 uvs2[11 + index] =
PackUV(1, 0, xScale);
5291 underlineColor.a = m_fontColor32.a < underlineColor.a ? (byte)(m_fontColor32.a) : (byte)(underlineColor.a);
5293 Color32[] colors32 = m_textInfo.meshInfo[0].colors32;
5294 colors32[0 + index] = underlineColor;
5295 colors32[1 + index] = underlineColor;
5296 colors32[2 + index] = underlineColor;
5297 colors32[3 + index] = underlineColor;
5299 colors32[4 + index] = underlineColor;
5300 colors32[5 + index] = underlineColor;
5301 colors32[6 + index] = underlineColor;
5302 colors32[7 + index] = underlineColor;
5304 colors32[8 + index] = underlineColor;
5305 colors32[9 + index] = underlineColor;
5306 colors32[10 + index] = underlineColor;
5307 colors32[11 + index] = underlineColor;
5314 protected virtual void DrawTextHighlight(Vector3 start, Vector3 end, ref
int index, Color32 highlightColor)
5316 if (m_cached_Underline_GlyphInfo ==
null)
5318 if (!
TMP_Settings.
warningsDisabled) Debug.LogWarning(
"Unable to add underline since the Font Asset doesn't contain the underline character.",
this);
5322 int verticesCount = index + 4;
5324 if (verticesCount > m_textInfo.meshInfo[0].vertices.Length)
5331 #region HIGHLIGHT VERTICES 5332 Vector3[] vertices = m_textInfo.meshInfo[0].vertices;
5335 vertices[index + 0] = start;
5336 vertices[index + 1] =
new Vector3(start.x, end.y, 0);
5337 vertices[index + 2] = end;
5338 vertices[index + 3] =
new Vector3(end.x, start.y, 0);
5343 Vector2[] uvs0 = m_textInfo.meshInfo[0].uvs0;
5346 Vector2 uv0 =
new Vector2((m_cached_Underline_GlyphInfo.x + m_cached_Underline_GlyphInfo.width / 2) / m_fontAsset.
fontInfo.AtlasWidth, 1 - (m_cached_Underline_GlyphInfo.y + m_cached_Underline_GlyphInfo.height / 2) / m_fontAsset.
fontInfo.AtlasHeight);
5352 uvs0[0 + index] = uv0;
5353 uvs0[1 + index] = uv0;
5354 uvs0[2 + index] = uv0;
5355 uvs0[3 + index] = uv0;
5359 #region HANDLE UV2 - SDF SCALE 5367 Vector2[] uvs2 = m_textInfo.meshInfo[0].uvs2;
5368 Vector2 customUV =
new Vector2(0, 1);
5369 uvs2[0 + index] = customUV;
5370 uvs2[1 + index] = customUV;
5371 uvs2[2 + index] = customUV;
5372 uvs2[3 + index] = customUV;
5378 highlightColor.a = m_fontColor32.a < highlightColor.a ? m_fontColor32.a : highlightColor.a;
5380 Color32[] colors32 = m_textInfo.meshInfo[0].colors32;
5381 colors32[0 + index] = highlightColor;
5382 colors32[1 + index] = highlightColor;
5383 colors32[2 + index] = highlightColor;
5384 colors32[3 + index] = highlightColor;
5396 if (m_text ==
null || m_isWaitingOnResourceLoad)
5418 m_isAlignmentEnumConverted =
true;
5419 m_isWaitingOnResourceLoad =
false;
5421 else if (m_isAlignmentEnumConverted ==
false)
5424 m_isAlignmentEnumConverted =
true;
5425 m_textAlignment = TMP_Compatibility.ConvertTextAlignmentEnumValues(m_textAlignment);
5437 if (!fontAsset.characterDictionary.TryGetValue(95, out m_cached_Underline_GlyphInfo))
5444 if (!fontAsset.characterDictionary.TryGetValue(8230, out m_cached_Ellipsis_GlyphInfo))
5461 chars[insertionIndex] = c;
5463 for (
int i = insertionIndex + tagLength; i < chars.Length; i++)
5465 chars[i - 3] = chars[i];
5490 bool isItalic = (m_style & FontStyles.Italic) == FontStyles.Italic || (m_fontStyle & FontStyles.Italic) == FontStyles.Italic;
5497 fontAsset = m_currentFontAsset.fontWeights[weightIndex].italicTypeface;
5499 fontAsset = m_currentFontAsset.fontWeights[weightIndex].regularTypeface;
5536 if (m_textInfo ==
null)
5537 return string.Empty;
5539 int characterCount = m_textInfo.characterCount;
5542 char[] buffer =
new char[characterCount];
5544 for (
int i = 0; i < characterCount && i < m_textInfo.characterInfo.Length; i++)
5546 buffer[i] = m_textInfo.characterInfo[i].character;
5549 return new string(buffer);
5580 protected Vector2
PackUV(
float x,
float y,
float scale)
5584 output.x = (int)(x * 511);
5585 output.y = (int)(y * 511);
5587 output.x = (output.x * 4096) + output.y;
5602 double x0 = (int)(x * 511);
5603 double y0 = (int)(y * 511);
5605 return (
float)((x0 * 4096) + y0);
5661 case 'A':
return 10;
5662 case 'B':
return 11;
5663 case 'C':
return 12;
5664 case 'D':
return 13;
5665 case 'E':
return 14;
5666 case 'F':
return 15;
5667 case 'a':
return 10;
5668 case 'b':
return 11;
5669 case 'c':
return 12;
5670 case 'd':
return 13;
5671 case 'e':
return 14;
5672 case 'f':
return 15;
5762 return new Color32(r, g, b, 255);
5764 else if (tagCount == 5)
5771 return new Color32(r, g, b, a);
5773 else if (tagCount == 7)
5779 return new Color32(r, g, b, 255);
5781 else if (tagCount == 9)
5788 return new Color32(r, g, b, a);
5790 else if (tagCount == 10)
5796 return new Color32(r, g, b, 255);
5798 else if (tagCount == 11)
5805 return new Color32(r, g, b, a);
5807 else if (tagCount == 13)
5813 return new Color32(r, g, b, 255);
5815 else if (tagCount == 15)
5822 return new Color32(r, g, b, a);
5825 return new Color32(255, 255, 255, 255);
5840 byte r = (byte)(
HexToInt(hexChars[startIndex + 1]) * 16 +
HexToInt(hexChars[startIndex + 2]));
5841 byte g = (byte)(
HexToInt(hexChars[startIndex + 3]) * 16 +
HexToInt(hexChars[startIndex + 4]));
5842 byte b = (byte)(
HexToInt(hexChars[startIndex + 5]) * 16 +
HexToInt(hexChars[startIndex + 6]));
5844 return new Color32(r, g, b, 255);
5846 else if (length == 9)
5848 byte r = (byte)(
HexToInt(hexChars[startIndex + 1]) * 16 +
HexToInt(hexChars[startIndex + 2]));
5849 byte g = (byte)(
HexToInt(hexChars[startIndex + 3]) * 16 +
HexToInt(hexChars[startIndex + 4]));
5850 byte b = (byte)(
HexToInt(hexChars[startIndex + 5]) * 16 +
HexToInt(hexChars[startIndex + 6]));
5851 byte a = (byte)(
HexToInt(hexChars[startIndex + 7]) * 16 +
HexToInt(hexChars[startIndex + 8]));
5853 return new Color32(r, g, b, a);
5856 return s_colorWhite;
5870 int endIndex = startIndex;
5871 int attributeCount = 0;
5873 while (endIndex < startIndex + length)
5875 parameters[attributeCount] =
ConvertToFloat(chars, startIndex, length, out endIndex);
5877 length -= (endIndex - startIndex) + 1;
5878 startIndex = endIndex + 1;
5880 attributeCount += 1;
5883 return attributeCount;
5909 protected float ConvertToFloat(
char[] chars,
int startIndex,
int length, out
int lastIndex)
5911 if (startIndex == 0) { lastIndex = 0;
return -9999; }
5912 int endIndex = startIndex + length;
5914 bool isIntegerValue =
true;
5915 float decimalPointMultiplier = 0;
5918 int valueSignMultiplier = 1;
5919 if (chars[startIndex] ==
'+')
5921 valueSignMultiplier = 1;
5924 else if (chars[startIndex] ==
'-')
5926 valueSignMultiplier = -1;
5932 for (
int i = startIndex; i < endIndex; i++)
5936 if (c >=
'0' && c <=
'9' || c ==
'.')
5940 isIntegerValue =
false;
5941 decimalPointMultiplier = 0.1f;
5947 value = value * 10 + (c - 48) * valueSignMultiplier;
5950 value = value + (c - 48) * decimalPointMultiplier * valueSignMultiplier;
5951 decimalPointMultiplier *= 0.1f;
5958 if (i + 1 < endIndex && chars[i + 1] ==
' ')
5967 lastIndex = endIndex;
5981 int tagCharCount = 0;
5982 byte attributeFlag = 0;
5984 TagUnits tagUnits = TagUnits.Pixels;
5985 TagType tagType = TagType.None;
5987 int attributeIndex = 0;
5988 m_xmlAttribute[attributeIndex].nameHashCode = 0;
5989 m_xmlAttribute[attributeIndex].valueType = TagType.None;
5990 m_xmlAttribute[attributeIndex].valueHashCode = 0;
5991 m_xmlAttribute[attributeIndex].valueStartIndex = 0;
5992 m_xmlAttribute[attributeIndex].valueLength = 0;
5995 m_xmlAttribute[1].nameHashCode = 0;
5996 m_xmlAttribute[2].nameHashCode = 0;
5997 m_xmlAttribute[3].nameHashCode = 0;
5998 m_xmlAttribute[4].nameHashCode = 0;
6000 endIndex = startIndex;
6001 bool isTagSet =
false;
6002 bool isValidHtmlTag =
false;
6004 for (
int i = startIndex; i < chars.Length && chars[i] != 0 && tagCharCount < m_htmlTag.Length && chars[i] != 60; i++)
6008 isValidHtmlTag =
true;
6010 m_htmlTag[tagCharCount] = (char)0;
6014 m_htmlTag[tagCharCount] = (char)chars[i];
6017 if (attributeFlag == 1)
6019 if (tagType == TagType.None)
6022 if (chars[i] == 43 || chars[i] == 45 || chars[i] == 46 || (chars[i] >=
'0' && chars[i] <=
'9'))
6024 tagType = TagType.NumericalValue;
6025 m_xmlAttribute[attributeIndex].valueType = TagType.NumericalValue;
6026 m_xmlAttribute[attributeIndex].valueStartIndex = tagCharCount - 1;
6027 m_xmlAttribute[attributeIndex].valueLength += 1;
6029 else if (chars[i] == 35)
6031 tagType = TagType.ColorValue;
6032 m_xmlAttribute[attributeIndex].valueType = TagType.ColorValue;
6033 m_xmlAttribute[attributeIndex].valueStartIndex = tagCharCount - 1;
6034 m_xmlAttribute[attributeIndex].valueLength += 1;
6036 else if (chars[i] == 34)
6038 tagType = TagType.StringValue;
6039 m_xmlAttribute[attributeIndex].valueType = TagType.StringValue;
6040 m_xmlAttribute[attributeIndex].valueStartIndex = tagCharCount;
6044 tagType = TagType.StringValue;
6045 m_xmlAttribute[attributeIndex].valueType = TagType.StringValue;
6046 m_xmlAttribute[attributeIndex].valueStartIndex = tagCharCount - 1;
6047 m_xmlAttribute[attributeIndex].valueHashCode = (m_xmlAttribute[attributeIndex].valueHashCode << 5) + m_xmlAttribute[attributeIndex].valueHashCode ^ chars[i];
6048 m_xmlAttribute[attributeIndex].valueLength += 1;
6053 if (tagType == TagType.NumericalValue)
6056 if (chars[i] == 112 || chars[i] == 101 || chars[i] == 37 || chars[i] == 32)
6059 tagType = TagType.None;
6060 attributeIndex += 1;
6061 m_xmlAttribute[attributeIndex].nameHashCode = 0;
6062 m_xmlAttribute[attributeIndex].valueType = TagType.None;
6063 m_xmlAttribute[attributeIndex].valueHashCode = 0;
6064 m_xmlAttribute[attributeIndex].valueStartIndex = 0;
6065 m_xmlAttribute[attributeIndex].valueLength = 0;
6067 if (chars[i] == 101)
6068 tagUnits = TagUnits.FontUnits;
6069 else if (chars[i] == 37)
6070 tagUnits = TagUnits.Percentage;
6072 else if (attributeFlag != 2)
6074 m_xmlAttribute[attributeIndex].valueLength += 1;
6077 else if (tagType == TagType.ColorValue)
6081 m_xmlAttribute[attributeIndex].valueLength += 1;
6086 tagType = TagType.None;
6087 attributeIndex += 1;
6088 m_xmlAttribute[attributeIndex].nameHashCode = 0;
6089 m_xmlAttribute[attributeIndex].valueType = TagType.None;
6090 m_xmlAttribute[attributeIndex].valueHashCode = 0;
6091 m_xmlAttribute[attributeIndex].valueStartIndex = 0;
6092 m_xmlAttribute[attributeIndex].valueLength = 0;
6095 else if (tagType == TagType.StringValue)
6100 m_xmlAttribute[attributeIndex].valueHashCode = (m_xmlAttribute[attributeIndex].valueHashCode << 5) + m_xmlAttribute[attributeIndex].valueHashCode ^ chars[i];
6101 m_xmlAttribute[attributeIndex].valueLength += 1;
6107 tagType = TagType.None;
6108 attributeIndex += 1;
6109 m_xmlAttribute[attributeIndex].nameHashCode = 0;
6110 m_xmlAttribute[attributeIndex].valueType = TagType.None;
6111 m_xmlAttribute[attributeIndex].valueHashCode = 0;
6112 m_xmlAttribute[attributeIndex].valueStartIndex = 0;
6113 m_xmlAttribute[attributeIndex].valueLength = 0;
6124 if (attributeFlag == 0 && chars[i] == 32)
6126 if (isTagSet)
return false;
6131 tagType = TagType.None;
6132 attributeIndex += 1;
6133 m_xmlAttribute[attributeIndex].nameHashCode = 0;
6134 m_xmlAttribute[attributeIndex].valueType = TagType.None;
6135 m_xmlAttribute[attributeIndex].valueHashCode = 0;
6136 m_xmlAttribute[attributeIndex].valueStartIndex = 0;
6137 m_xmlAttribute[attributeIndex].valueLength = 0;
6140 if (attributeFlag == 0)
6141 m_xmlAttribute[attributeIndex].nameHashCode = (m_xmlAttribute[attributeIndex].nameHashCode << 3) - m_xmlAttribute[attributeIndex].nameHashCode + chars[i];
6143 if (attributeFlag == 2 && chars[i] == 32)
6148 if (!isValidHtmlTag)
6159 if (tag_NoParsing && (m_xmlAttribute[0].nameHashCode != 53822163 && m_xmlAttribute[0].nameHashCode != 49429939))
6161 else if (m_xmlAttribute[0].nameHashCode == 53822163 || m_xmlAttribute[0].nameHashCode == 49429939)
6163 tag_NoParsing =
false;
6168 if (m_htmlTag[0] == 35 && tagCharCount == 4)
6171 m_colorStack.Add(m_htmlColor);
6175 else if (m_htmlTag[0] == 35 && tagCharCount == 5)
6178 m_colorStack.Add(m_htmlColor);
6182 else if (m_htmlTag[0] == 35 && tagCharCount == 7)
6185 m_colorStack.Add(m_htmlColor);
6189 else if (m_htmlTag[0] == 35 && tagCharCount == 9)
6192 m_colorStack.Add(m_htmlColor);
6199 switch (m_xmlAttribute[0].nameHashCode)
6203 m_style |= FontStyles.Bold;
6204 m_fontStyleStack.Add(FontStyles.Bold);
6206 m_fontWeightInternal = 700;
6207 m_fontWeightStack.
Add(700);
6211 if ((m_fontStyle & FontStyles.Bold) != FontStyles.Bold)
6213 m_fontWeightInternal = m_fontWeightStack.
Remove();
6215 if (m_fontStyleStack.Remove(FontStyles.Bold) == 0)
6216 m_style &= ~FontStyles.Bold;
6221 m_style |= FontStyles.Italic;
6222 m_fontStyleStack.Add(FontStyles.Italic);
6226 if (m_fontStyleStack.Remove(FontStyles.Italic) == 0)
6227 m_style &= ~FontStyles.Italic;
6232 m_style |= FontStyles.Strikethrough;
6233 m_fontStyleStack.Add(FontStyles.Strikethrough);
6235 if (m_xmlAttribute[1].nameHashCode == 281955 || m_xmlAttribute[1].nameHashCode == 192323)
6237 m_strikethroughColor =
HexCharsToColor(m_htmlTag, m_xmlAttribute[1].valueStartIndex, m_xmlAttribute[1].valueLength);
6238 m_strikethroughColor.a = m_htmlColor.a < m_strikethroughColor.a ? (byte)(m_htmlColor.a) : (byte)(m_strikethroughColor .a);
6241 m_strikethroughColor = m_htmlColor;
6243 m_strikethroughColorStack.Add(m_strikethroughColor);
6248 if ((m_fontStyle & FontStyles.Strikethrough) != FontStyles.Strikethrough)
6250 if (m_fontStyleStack.Remove(FontStyles.Strikethrough) == 0)
6251 m_style &= ~FontStyles.Strikethrough;
6256 m_style |= FontStyles.Underline;
6257 m_fontStyleStack.Add(FontStyles.Underline);
6259 if (m_xmlAttribute[1].nameHashCode == 281955 || m_xmlAttribute[1].nameHashCode == 192323)
6261 m_underlineColor =
HexCharsToColor(m_htmlTag, m_xmlAttribute[1].valueStartIndex, m_xmlAttribute[1].valueLength);
6262 m_underlineColor.a = m_htmlColor.a < m_underlineColor.a ? (byte)(m_htmlColor.a) : (byte)(m_underlineColor.a);
6265 m_underlineColor = m_htmlColor;
6267 m_underlineColorStack.Add(m_underlineColor);
6272 if ((m_fontStyle & FontStyles.Underline) != FontStyles.Underline)
6274 m_underlineColor = m_underlineColorStack.Remove();
6276 if (m_fontStyleStack.Remove(FontStyles.Underline) == 0)
6277 m_style &= ~FontStyles.Underline;
6282 m_style |= FontStyles.Highlight;
6283 m_fontStyleStack.Add(FontStyles.Highlight);
6285 m_highlightColor =
HexCharsToColor(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
6286 m_highlightColor.a = m_htmlColor.a < m_highlightColor.a ? (byte)(m_htmlColor.a) : (byte)(m_highlightColor.a);
6287 m_highlightColorStack.Add(m_highlightColor);
6291 if ((m_fontStyle & FontStyles.Highlight) != FontStyles.Highlight)
6293 m_highlightColor = m_highlightColorStack.Remove();
6295 if (m_fontStyleStack.Remove(FontStyles.Highlight) == 0)
6296 m_style &= ~FontStyles.Highlight;
6301 m_fontScaleMultiplier *= m_currentFontAsset.
fontInfo.SubSize > 0 ? m_currentFontAsset.
fontInfo.SubSize : 1;
6302 m_baselineOffsetStack.Push(m_baselineOffset);
6303 m_baselineOffset += m_currentFontAsset.
fontInfo.SubscriptOffset * m_fontScale * m_fontScaleMultiplier;
6305 m_fontStyleStack.Add(FontStyles.Subscript);
6306 m_style |= FontStyles.Subscript;
6310 if ((m_style & FontStyles.Subscript) == FontStyles.Subscript)
6312 if (m_fontScaleMultiplier < 1)
6315 m_baselineOffset = m_baselineOffsetStack.Pop();
6316 m_fontScaleMultiplier /= m_currentFontAsset.
fontInfo.SubSize > 0 ? m_currentFontAsset.
fontInfo.SubSize : 1;
6319 if (m_fontStyleStack.Remove(FontStyles.Subscript) == 0)
6320 m_style &= ~FontStyles.Subscript;
6325 m_fontScaleMultiplier *= m_currentFontAsset.
fontInfo.SubSize > 0 ? m_currentFontAsset.
fontInfo.SubSize : 1;
6326 m_baselineOffsetStack.Push(m_baselineOffset);
6327 m_baselineOffset += m_currentFontAsset.
fontInfo.SuperscriptOffset * m_fontScale * m_fontScaleMultiplier;
6329 m_fontStyleStack.Add(FontStyles.Superscript);
6330 m_style |= FontStyles.Superscript;
6334 if ((m_style & FontStyles.Superscript) == FontStyles.Superscript)
6336 if (m_fontScaleMultiplier < 1)
6339 m_baselineOffset = m_baselineOffsetStack.Pop();
6340 m_fontScaleMultiplier /= m_currentFontAsset.
fontInfo.SubSize > 0 ? m_currentFontAsset.
fontInfo.SubSize : 1;
6343 if (m_fontStyleStack.Remove(FontStyles.Superscript) == 0)
6344 m_style &= ~FontStyles.Superscript;
6349 value =
ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
6350 if (value == -9999)
return false;
6352 if ((m_fontStyle & FontStyles.Bold) == FontStyles.Bold)
6361 m_style &= ~FontStyles.Bold;
6366 m_fontWeightInternal = 100;
6369 m_fontWeightInternal = 200;
6372 m_fontWeightInternal = 300;
6375 m_fontWeightInternal = 400;
6379 m_fontWeightInternal = 500;
6382 m_fontWeightInternal = 600;
6385 m_fontWeightInternal = 700;
6386 m_style |= FontStyles.Bold;
6389 m_fontWeightInternal = 800;
6392 m_fontWeightInternal = 900;
6396 m_fontWeightStack.
Add(m_fontWeightInternal);
6401 m_fontWeightInternal = m_fontWeightStack.
Remove();
6402 if (m_fontWeightInternal == 400) m_style &= ~FontStyles.Bold;
6406 value =
ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
6407 if (value == -9999)
return false;
6411 case TagUnits.Pixels:
6425 case TagUnits.FontUnits:
6426 m_xAdvance = value * m_fontScale * m_fontAsset.
fontInfo.TabWidth / m_fontAsset.tabSize;
6429 case TagUnits.Percentage:
6430 m_xAdvance = m_marginWidth * value / 100;
6465 m_isIgnoringAlignment =
false;
6469 value =
ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
6470 if (value == -9999)
return false;
6474 case TagUnits.Pixels:
6475 m_baselineOffset = value;
6477 case TagUnits.FontUnits:
6478 m_baselineOffset = value * m_fontScale * m_fontAsset.
fontInfo.Ascender;
6480 case TagUnits.Percentage:
6487 m_baselineOffset = 0;
6492 if (m_overflowMode == TextOverflowModes.Page)
6494 m_xAdvance = 0 + tag_LineIndent + tag_Indent;
6507 m_isNonBreakingSpace =
true;
6511 m_isNonBreakingSpace =
false;
6515 value =
ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
6516 if (value == -9999)
return false;
6520 case TagUnits.Pixels:
6521 if (m_htmlTag[5] == 43)
6523 m_currentFontSize = m_fontSize + value;
6524 m_sizeStack.
Add(m_currentFontSize);
6525 m_fontScale = (m_currentFontSize / m_currentFontAsset.
fontInfo.PointSize * m_currentFontAsset.
fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f));
6528 else if (m_htmlTag[5] == 45)
6530 m_currentFontSize = m_fontSize + value;
6531 m_sizeStack.
Add(m_currentFontSize);
6532 m_fontScale = (m_currentFontSize / m_currentFontAsset.
fontInfo.PointSize * m_currentFontAsset.
fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f));
6537 m_currentFontSize = value;
6538 m_sizeStack.
Add(m_currentFontSize);
6539 m_fontScale = (m_currentFontSize / m_currentFontAsset.
fontInfo.PointSize * m_currentFontAsset.
fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f));
6542 case TagUnits.FontUnits:
6543 m_currentFontSize = m_fontSize * value;
6544 m_sizeStack.
Add(m_currentFontSize);
6545 m_fontScale = (m_currentFontSize / m_currentFontAsset.
fontInfo.PointSize * m_currentFontAsset.
fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f));
6547 case TagUnits.Percentage:
6548 m_currentFontSize = m_fontSize * value / 100;
6549 m_sizeStack.
Add(m_currentFontSize);
6550 m_fontScale = (m_currentFontSize / m_currentFontAsset.
fontInfo.PointSize * m_currentFontAsset.
fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f));
6556 m_currentFontSize = m_sizeStack.
Remove();
6557 m_fontScale = (m_currentFontSize / m_currentFontAsset.
fontInfo.PointSize * m_currentFontAsset.
fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f));
6563 int fontHashCode = m_xmlAttribute[0].valueHashCode;
6564 int materialAttributeHashCode = m_xmlAttribute[1].nameHashCode;
6565 int materialHashCode = m_xmlAttribute[1].valueHashCode;
6568 if (fontHashCode == 764638571 || fontHashCode == 523367755)
6570 m_currentFontAsset = m_materialReferences[0].fontAsset;
6571 m_currentMaterial = m_materialReferences[0].material;
6572 m_currentMaterialIndex = 0;
6575 m_fontScale = (m_currentFontSize / m_currentFontAsset.
fontInfo.PointSize * m_currentFontAsset.
fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f));
6577 m_materialReferenceStack.
Add(m_materialReferences[0]);
6583 Material tempMaterial;
6600 if (tempFont ==
null)
6609 if (materialAttributeHashCode == 0 && materialHashCode == 0)
6612 m_currentMaterial = tempFont.material;
6616 m_materialReferenceStack.
Add(m_materialReferences[m_currentMaterialIndex]);
6618 else if (materialAttributeHashCode == 103415287 || materialAttributeHashCode == 72669687)
6622 m_currentMaterial = tempMaterial;
6626 m_materialReferenceStack.
Add(m_materialReferences[m_currentMaterialIndex]);
6631 tempMaterial = Resources.Load<Material>(
TMP_Settings.
defaultFontAssetPath +
new string(m_htmlTag, m_xmlAttribute[1].valueStartIndex, m_xmlAttribute[1].valueLength));
6633 if (tempMaterial ==
null)
6639 m_currentMaterial = tempMaterial;
6643 m_materialReferenceStack.
Add(m_materialReferences[m_currentMaterialIndex]);
6649 m_currentFontAsset = tempFont;
6650 m_fontScale = (m_currentFontSize / m_currentFontAsset.
fontInfo.PointSize * m_currentFontAsset.
fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f));
6658 m_currentFontAsset = materialReference.fontAsset;
6659 m_currentMaterial = materialReference.material;
6660 m_currentMaterialIndex = materialReference.index;
6662 m_fontScale = (m_currentFontSize / m_currentFontAsset.
fontInfo.PointSize * m_currentFontAsset.
fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f));
6668 materialHashCode = m_xmlAttribute[0].valueHashCode;
6671 if (materialHashCode == 764638571 || materialHashCode == 523367755)
6676 m_currentMaterial = m_materialReferences[0].material;
6677 m_currentMaterialIndex = 0;
6679 m_materialReferenceStack.
Add(m_materialReferences[0]);
6691 m_currentMaterial = tempMaterial;
6695 m_materialReferenceStack.
Add(m_materialReferences[m_currentMaterialIndex]);
6700 tempMaterial = Resources.Load<Material>(
TMP_Settings.
defaultFontAssetPath +
new string(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength));
6702 if (tempMaterial ==
null)
6711 m_currentMaterial = tempMaterial;
6715 m_materialReferenceStack.
Add(m_materialReferences[m_currentMaterialIndex]);
6726 m_currentMaterial = materialReference.material;
6727 m_currentMaterialIndex = materialReference.index;
6733 value =
ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
6734 if (value == -9999)
return false;
6738 case TagUnits.Pixels:
6739 m_xAdvance += value;
6741 case TagUnits.FontUnits:
6742 m_xAdvance += value * m_fontScale * m_fontAsset.
fontInfo.TabWidth / m_fontAsset.tabSize;
6744 case TagUnits.Percentage:
6751 if (m_xmlAttribute[0].valueLength != 3)
return false;
6753 m_htmlColor.a = (byte)(
HexToInt(m_htmlTag[7]) * 16 +
HexToInt(m_htmlTag[8]));
6762 if (m_isParsingText && !m_isCalculatingPreferredValues)
6764 int index = m_textInfo.linkCount;
6766 if (index + 1 > m_textInfo.linkInfo.Length)
6767 TMP_TextInfo.Resize(ref m_textInfo.linkInfo, index + 1);
6769 m_textInfo.linkInfo[index].textComponent =
this;
6770 m_textInfo.linkInfo[index].hashCode = m_xmlAttribute[0].valueHashCode;
6771 m_textInfo.linkInfo[index].linkTextfirstCharacterIndex = m_characterCount;
6773 m_textInfo.linkInfo[index].linkIdFirstCharacterIndex = startIndex + m_xmlAttribute[0].valueStartIndex;
6774 m_textInfo.linkInfo[index].linkIdLength = m_xmlAttribute[0].valueLength;
6775 m_textInfo.linkInfo[index].SetLinkID(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
6780 if (m_isParsingText && !m_isCalculatingPreferredValues)
6782 if (m_textInfo.linkCount < m_textInfo.linkInfo.Length)
6784 m_textInfo.linkInfo[m_textInfo.linkCount].linkTextLength = m_characterCount - m_textInfo.linkInfo[m_textInfo.linkCount].linkTextfirstCharacterIndex;
6786 m_textInfo.linkCount += 1;
6792 switch (m_xmlAttribute[0].valueHashCode)
6795 m_lineJustification = TextAlignmentOptions.Left;
6796 m_lineJustificationStack.
Add(m_lineJustification);
6799 m_lineJustification = TextAlignmentOptions.Right;
6800 m_lineJustificationStack.
Add(m_lineJustification);
6803 m_lineJustification = TextAlignmentOptions.Center;
6804 m_lineJustificationStack.
Add(m_lineJustification);
6807 m_lineJustification = TextAlignmentOptions.Justified;
6808 m_lineJustificationStack.
Add(m_lineJustification);
6811 m_lineJustification = TextAlignmentOptions.Flush;
6812 m_lineJustificationStack.
Add(m_lineJustification);
6818 m_lineJustification = m_lineJustificationStack.
Remove();
6822 value =
ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
6823 if (value == -9999)
return false;
6827 case TagUnits.Pixels:
6830 case TagUnits.FontUnits:
6833 case TagUnits.Percentage:
6834 m_width = m_marginWidth * value / 100;
6884 if (m_htmlTag[6] == 35 && tagCharCount == 10)
6887 m_colorStack.Add(m_htmlColor);
6891 else if (m_htmlTag[6] == 35 && tagCharCount == 11)
6894 m_colorStack.Add(m_htmlColor);
6898 if (m_htmlTag[6] == 35 && tagCharCount == 13)
6901 m_colorStack.Add(m_htmlColor);
6905 else if (m_htmlTag[6] == 35 && tagCharCount == 15)
6908 m_colorStack.Add(m_htmlColor);
6913 switch (m_xmlAttribute[0].valueHashCode)
6916 m_htmlColor = Color.red;
6917 m_colorStack.Add(m_htmlColor);
6920 m_htmlColor = Color.blue;
6921 m_colorStack.Add(m_htmlColor);
6924 m_htmlColor = Color.black;
6925 m_colorStack.Add(m_htmlColor);
6928 m_htmlColor = Color.green;
6929 m_colorStack.Add(m_htmlColor);
6932 m_htmlColor = Color.white;
6933 m_colorStack.Add(m_htmlColor);
6936 m_htmlColor =
new Color32(255, 128, 0, 255);
6937 m_colorStack.Add(m_htmlColor);
6940 m_htmlColor =
new Color32(160, 32, 240, 255);
6941 m_colorStack.Add(m_htmlColor);
6944 m_htmlColor = Color.yellow;
6945 m_colorStack.Add(m_htmlColor);
6952 int gradientPresetHashCode = m_xmlAttribute[0].valueHashCode;
6958 m_colorGradientPreset = tempColorGradientPreset;
6963 if (tempColorGradientPreset ==
null)
6968 if (tempColorGradientPreset ==
null)
6972 m_colorGradientPreset = tempColorGradientPreset;
6975 m_colorGradientStack.Add(m_colorGradientPreset);
6983 m_colorGradientPreset = m_colorGradientStack.Remove();
6988 value =
ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
6989 if (value == -9999)
return false;
6993 case TagUnits.Pixels:
6996 case TagUnits.FontUnits:
6998 m_cSpacing *= m_fontScale * m_fontAsset.
fontInfo.TabWidth / m_fontAsset.tabSize;
7000 case TagUnits.Percentage:
7006 if (!m_isParsingText)
return true;
7009 if (m_characterCount > 0)
7011 m_xAdvance -= m_cSpacing;
7012 m_textInfo.characterInfo[m_characterCount - 1].xAdvance = m_xAdvance;
7018 value =
ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
7019 if (value == -9999)
return false;
7023 case TagUnits.Pixels:
7024 m_monoSpacing = value;
7026 case TagUnits.FontUnits:
7027 m_monoSpacing = value;
7028 m_monoSpacing *= m_fontScale * m_fontAsset.
fontInfo.TabWidth / m_fontAsset.tabSize;
7030 case TagUnits.Percentage:
7042 m_htmlColor = m_colorStack.Remove();
7046 value =
ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
7047 if (value == -9999)
return false;
7051 case TagUnits.Pixels:
7054 case TagUnits.FontUnits:
7056 tag_Indent *= m_fontScale * m_fontAsset.
fontInfo.TabWidth / m_fontAsset.tabSize;
7058 case TagUnits.Percentage:
7059 tag_Indent = m_marginWidth * value / 100;
7062 m_indentStack.Add(tag_Indent);
7064 m_xAdvance = tag_Indent;
7068 tag_Indent = m_indentStack.Remove();
7073 value =
ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
7074 if (value == -9999)
return false;
7078 case TagUnits.Pixels:
7079 tag_LineIndent = value;
7081 case TagUnits.FontUnits:
7082 tag_LineIndent = value;
7083 tag_LineIndent *= m_fontScale * m_fontAsset.
fontInfo.TabWidth / m_fontAsset.tabSize;
7085 case TagUnits.Percentage:
7086 tag_LineIndent = m_marginWidth * value / 100;
7090 m_xAdvance += tag_LineIndent;
7098 int spriteAssetHashCode = m_xmlAttribute[0].valueHashCode;
7103 if (m_xmlAttribute[0].valueType == TagType.None || m_xmlAttribute[0].valueType == TagType.NumericalValue)
7106 if (m_spriteAsset !=
null)
7108 m_currentSpriteAsset = m_spriteAsset;
7110 else if (m_defaultSpriteAsset !=
null)
7112 m_currentSpriteAsset = m_defaultSpriteAsset;
7114 else if (m_defaultSpriteAsset ==
null)
7119 m_defaultSpriteAsset = Resources.Load<
TMP_SpriteAsset>(
"Sprite Assets/Default Sprite Asset");
7121 m_currentSpriteAsset = m_defaultSpriteAsset;
7125 if (m_currentSpriteAsset ==
null)
7133 m_currentSpriteAsset = tempSpriteAsset;
7138 if (tempSpriteAsset ==
null)
7143 if (tempSpriteAsset ==
null)
7148 m_currentSpriteAsset = tempSpriteAsset;
7153 if (m_xmlAttribute[0].valueType == TagType.NumericalValue)
7155 int index = (int)
ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
7156 if (index == -9999)
return false;
7159 if (index > m_currentSpriteAsset.spriteInfoList.Count - 1)
return false;
7161 m_spriteIndex = index;
7164 m_spriteColor = s_colorWhite;
7165 m_tintSprite =
false;
7168 for (
int i = 0; i < m_xmlAttribute.Length && m_xmlAttribute[i].nameHashCode != 0; i++)
7171 int nameHashCode = m_xmlAttribute[i].nameHashCode;
7174 switch (nameHashCode)
7179 if (index == -1)
return false;
7181 m_spriteIndex = index;
7185 index = (int)
ConvertToFloat(m_htmlTag, m_xmlAttribute[1].valueStartIndex, m_xmlAttribute[1].valueLength);
7186 if (index == -9999)
return false;
7189 if (index > m_currentSpriteAsset.spriteInfoList.Count - 1)
return false;
7191 m_spriteIndex = index;
7195 m_tintSprite =
ConvertToFloat(m_htmlTag, m_xmlAttribute[i].valueStartIndex, m_xmlAttribute[i].valueLength) != 0;
7199 m_spriteColor =
HexCharsToColor(m_htmlTag, m_xmlAttribute[i].valueStartIndex, m_xmlAttribute[i].valueLength);
7204 int paramCount =
GetAttributeParameters(m_htmlTag, m_xmlAttribute[i].valueStartIndex, m_xmlAttribute[i].valueLength, ref m_attributeParameterValues);
7205 if (paramCount != 3)
return false;
7207 m_spriteIndex = (int)m_attributeParameterValues[0];
7209 if (m_isParsingText)
7215 spriteAnimator.DoSpriteAnimation(m_characterCount, m_currentSpriteAsset, m_spriteIndex, (
int)m_attributeParameterValues[1], (
int)m_attributeParameterValues[2]);
7224 if (nameHashCode != 2246877 && nameHashCode != 1619421)
7230 if (m_spriteIndex == -1)
return false;
7235 m_textElementType = TMP_TextElementType.Sprite;
7239 m_style |= FontStyles.LowerCase;
7240 m_fontStyleStack.Add(FontStyles.LowerCase);
7244 if (m_fontStyleStack.Remove(FontStyles.LowerCase) == 0)
7245 m_style &= ~FontStyles.LowerCase;
7251 m_style |= FontStyles.UpperCase;
7252 m_fontStyleStack.Add(FontStyles.UpperCase);
7258 if (m_fontStyleStack.Remove(FontStyles.UpperCase) == 0)
7259 m_style &= ~FontStyles.UpperCase;
7263 m_style |= FontStyles.SmallCaps;
7264 m_fontStyleStack.Add(FontStyles.SmallCaps);
7268 if (m_fontStyleStack.Remove(FontStyles.SmallCaps) == 0)
7269 m_style &= ~FontStyles.SmallCaps;
7273 value =
ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
7274 if (value == -9999)
return false;
7276 m_marginLeft = value;
7279 case TagUnits.Pixels:
7282 case TagUnits.FontUnits:
7283 m_marginLeft *= m_fontScale * m_fontAsset.
fontInfo.TabWidth / m_fontAsset.tabSize;
7285 case TagUnits.Percentage:
7286 m_marginLeft = (m_marginWidth - (m_width != -1 ? m_width : 0)) * m_marginLeft / 100;
7289 m_marginLeft = m_marginLeft >= 0 ? m_marginLeft : 0;
7290 m_marginRight = m_marginLeft;
7300 value =
ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
7301 if (value == -9999)
return false;
7303 m_marginLeft = value;
7306 case TagUnits.Pixels:
7309 case TagUnits.FontUnits:
7310 m_marginLeft *= m_fontScale * m_fontAsset.
fontInfo.TabWidth / m_fontAsset.tabSize;
7312 case TagUnits.Percentage:
7313 m_marginLeft = (m_marginWidth - (m_width != -1 ? m_width : 0)) * m_marginLeft / 100;
7316 m_marginLeft = m_marginLeft >= 0 ? m_marginLeft : 0;
7320 value =
ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
7321 if (value == -9999)
return false;
7323 m_marginRight = value;
7326 case TagUnits.Pixels:
7329 case TagUnits.FontUnits:
7330 m_marginRight *= m_fontScale * m_fontAsset.
fontInfo.TabWidth / m_fontAsset.tabSize;
7332 case TagUnits.Percentage:
7333 m_marginRight = (m_marginWidth - (m_width != -1 ? m_width : 0)) * m_marginRight / 100;
7336 m_marginRight = m_marginRight >= 0 ? m_marginRight : 0;
7340 value =
ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
7341 if (value == -9999 || value == 0)
return false;
7343 m_lineHeight = value;
7346 case TagUnits.Pixels:
7349 case TagUnits.FontUnits:
7350 m_lineHeight *= m_fontAsset.
fontInfo.LineHeight * m_fontScale;
7352 case TagUnits.Percentage:
7353 m_lineHeight = m_fontAsset.
fontInfo.LineHeight * m_lineHeight / 100 * m_fontScale;
7359 m_lineHeight = TMP_Math.FLOAT_UNSET;
7363 tag_NoParsing =
true;
7367 int actionID = m_xmlAttribute[0].valueHashCode;
7369 if (m_isParsingText)
7371 m_actionStack.Add(actionID);
7373 Debug.Log(
"Action ID: [" + actionID +
"] First character index: " + m_characterCount);
7384 if (m_isParsingText)
7386 Debug.Log(
"Action ID: [" + m_actionStack.CurrentItem() +
"] Last character index: " + (m_characterCount - 1));
7389 m_actionStack.Remove();
7393 value =
ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
7394 if (value == -9999)
return false;
7396 m_FXMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity,
new Vector3(value, 1, 1));
7397 m_isFXMatrixSet =
true;
7402 m_isFXMatrixSet =
false;
7408 value =
ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength);
7409 if (value == -9999)
return false;
7411 m_FXMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, value), Vector3.one);
7412 m_isFXMatrixSet =
true;
7417 m_isFXMatrixSet =
false;
7421 switch (m_xmlAttribute[1].nameHashCode)
7424 float tableWidth =
ConvertToFloat(m_htmlTag, m_xmlAttribute[1].valueStartIndex, m_xmlAttribute[1].valueLength);
7428 case TagUnits.Pixels:
7429 Debug.Log(
"Table width = " + tableWidth +
"px.");
7431 case TagUnits.FontUnits:
7432 Debug.Log(
"Table width = " + tableWidth +
"em.");
7434 case TagUnits.Percentage:
7435 Debug.Log(
"Table width = " + tableWidth +
"%.");
7460 for (
int i = 1; i < m_xmlAttribute.Length && m_xmlAttribute[i].nameHashCode != 0; i++)
7462 switch (m_xmlAttribute[i].nameHashCode)
7465 float tableWidth =
ConvertToFloat(m_htmlTag, m_xmlAttribute[i].valueStartIndex, m_xmlAttribute[i].valueLength);
7469 case TagUnits.Pixels:
7470 Debug.Log(
"Table width = " + tableWidth +
"px.");
7472 case TagUnits.FontUnits:
7473 Debug.Log(
"Table width = " + tableWidth +
"em.");
7475 case TagUnits.Percentage:
7476 Debug.Log(
"Table width = " + tableWidth +
"%.");
7481 switch (m_xmlAttribute[i].valueHashCode)
7484 Debug.Log(
"TD align=\"left\".");
7487 Debug.Log(
"TD align=\"right\".");
7490 Debug.Log(
"TD align=\"center\".");
7493 Debug.Log(
"TD align=\"justified\".");
static bool enableKerning
Controls if Kerning is enabled on newly created text objects by default.
Positional adjustments of a glyph
VertexSortingOrder geometrySortingOrder
Determines the sorting order of the geometry of the text object.
T Remove()
Function to retrieve an item from the stack.
virtual int SetArraySizes(int[] chars)
Method used to determine the number of visible characters and required buffer allocations.
Vector2 GetPreferredValues()
Function to Calculate the Preferred Width and Height of the text object.
virtual float preferredHeight
Computed preferred height of the text object.
Vector2 GetRenderedValues()
Method returning the rendered width and height of the text object.
bool isLinkedTextComponent
Indicates whether this text component is linked to another.
TextRenderFlags
Flags controlling what vertex data gets pushed to the mesh.
virtual void SetSharedMaterials(Material[] materials)
Structure used to track XML tags of various types.
override void CrossFadeAlpha(float alpha, float duration, bool ignoreTimeScale)
Tweens the alpha of the CanvasRenderer color associated with this Graphic.
virtual void SetFontBaseMaterial(Material mat)
Function called internally when assigning a new base material.
float mappingUvLineOffset
Controls the UV Offset for the various texture mapping mode on the text object.
bool isUsingLegacyAnimationComponent
Property to handle legacy animation component.
virtual void UpdateGeometry(Mesh mesh, int index)
Function to force the regeneration of the text object.
float alpha
Sets the vertex color alpha value.
static string defaultFontAssetPath
The relative path to a Resources folder in the project.
virtual Bounds GetCompoundBounds()
Method returning the compound bounds of the text object and child sub objects.
int maxVisibleLines
Allows control over how many lines of text are displayed.
float fontSize
The point size of the font.
virtual void SaveGlyphVertexInfo(float padding, float style_padding, Color32 vertexColor)
Store vertex information for each character.
virtual Material [] GetMaterials(Material[] mats)
Method returning instances of the materials used by the text object.
void SetText(string text, float arg0, float arg1)
bool ReplaceOpeningStyleTag(ref StringBuilder sourceText, int srcIndex, out int srcOffset, ref int[] charBuffer, ref int writeIndex)
Method to handle inline replacement of style tag by opening style definition.
Structure which contains information about the individual lines of text.
virtual void SetShaderDepth()
Set the Render Queue and ZTest mode on the current material
virtual Material [] fontSharedMaterials
An array containing the materials used by the text object.
virtual void ComputeMarginSize()
Function to force an update of the margin size.
int hashCode
The hash code corresponding to the name of this style.
static bool enableParseEscapeCharacters
Controls if Escape Characters will be parsed in the Text Input Box on newly created text objects.
void SetText(StringBuilder text)
Set the text using a StringBuilder.
Class which contains information about every element contained within the text object.
void SetText(string text, bool syncTextInputBox)
virtual void ClearMesh()
Function to clear the geometry of the Primary and Sub Text objects.
void ParseInputText()
Method to parse the input text based on its source
Bounds bounds
Returns the bounds of the mesh of the text object in world space.
void ResetVertexLayout(bool isVolumetric)
float GetRenderedHeight(bool onlyVisibleCharacters)
Method returning the rendered height of the text object.
virtual void FillSpriteVertexBuffers(int i, int index_X4)
Fill Vertex Buffers for Sprites
bool ReplaceOpeningStyleTag(ref string sourceText, int srcIndex, out int srcOffset, ref int[] charBuffer, ref int writeIndex)
Method to handle inline replacement of style tag by opening style definition.
TMP_Text linkedTextComponent
The linked text component used for flowing the text from one text component to another.
Vector2 GetPreferredValues(float width, float height)
Function to Calculate the Preferred Width and Height of the text object given the provided width and ...
VertexGradient colorGradient
Sets the vertex colors for each of the 4 vertices of the character quads.
TextRenderFlags renderMode
Determines if the Mesh will be rendered.
virtual bool autoSizeTextContainer
Enables control over setting the size of the text container to match the text object.
bool tintAllSprites
Determines whether or not the sprite color is multiplies by the vertex color of the text.
bool IsTagName(ref int[] text, string tag, int index)
Method to check for a matching rich text tag.
bool useMaxVisibleDescender
Determines if the text's vertical alignment will be adjusted based on visible descender of the text.
static bool autoSizeTextContainer
Set the size of the text container of newly created text objects to match the size of the text.
float characterSpacing
Use the extents of the text geometry for alignment instead of font metrics.
bool ReplaceClosingStyleTag(ref StringBuilder sourceText, int srcIndex, ref int[] charBuffer, ref int writeIndex)
Method to handle inline replacement of style tag by closing style definition.
virtual void InternalCrossFadeColor(Color targetColor, float duration, bool ignoreTimeScale, bool useAlpha)
FontStyles fontStyle
The style of the text
virtual void UpdateMeshPadding()
Function to be used to force recomputing of character padding when Shader / Material properties have ...
float lineSpacing
The amount of additional spacing to add between each lines of text.
TMP_SpriteAsset spriteAsset
Default Sprite Asset used by the text object.
virtual void ClearMesh(bool uploadGeometry)
Function to clear the geometry of the Primary and Sub Text objects.
void StringToCharArray(string sourceText, ref int[] charBuffer)
Method to store the content of a string into an integer array.
int fontWeight
Control the weight of the font if an alternative font asset is assigned for the given weight in the f...
float GetRenderedWidth(bool onlyVisibleCharacters)
Method returning the rendered width of the text object.
int GetUTF16(StringBuilder text, int i)
Convert UTF-16 Hex to Char
virtual void SaveSpriteVertexInfo(Color32 vertexColor)
Store vertex information for each sprite.
TMP_FontAsset GetFontAssetForWeight(int fontWeight)
virtual Vector3 [] GetTextContainerLocalCorners()
Method to return the local corners of the Text Container or RectTransform.
Color32 outlineColor
Sets the color of the _OutlineColor property of the assigned material. Changing outline color will re...
virtual Material [] GetSharedMaterials()
Method which returns an array containing the materials used by the text object.
virtual void SetActiveSubMeshes(bool state)
Method to Enable or Disable child SubMesh objects.
internal void SetTextInternal(string text)
Internal function used by the Text Input Field to populate TMP_TextInfo data.
virtual void UpdateVertexData(TMP_VertexDataUpdateFlags flags)
Function to push the updated vertex data into the mesh and renderer.
Bounds textBounds
Returns the bounds of the text of the text object.
bool overrideColorTags
This overrides the color tags forcing the vertex colors to be the default font color.
static float defaultFontSize
The Default Point Size of newly created text objects.
int GetUTF32(string text, int i)
Convert UTF-32 Hex to Char
void ResizeMeshInfo(int size)
Function to resized the content of MeshData and re-assign normals, tangents and triangles.
Base class which contains common properties and functions shared between the TextMeshPro and TextMesh...
static string defaultSpriteAssetPath
The relative path to a Resources folder in the project.
new Transform transform
Returns are reference to the Transform
virtual Material CreateMaterialInstance(Material source)
Method to set the materials of the text and sub text objects.
int GetUTF32(StringBuilder text, int i)
Convert UTF-32 Hex to Char
TMP_VertexDataUpdateFlags
Flags to control what vertex data is pushed to the mesh and renderer.
static Vector2 defaultTextMeshProTextContainerSize
The Default Size of the Text Container of a TextMeshPro object.
void SetCharArray(char[] sourceText)
Character array containing the text to be displayed.
float GetRenderedHeight()
Method returning the rendered height of the text object.
bool IsTagName(ref StringBuilder text, string tag, int index)
Method to check for a matching rich text tag.
bool parseCtrlCharacters
Enables or Disables parsing of CTRL characters in input text.
float GetPreferredHeight()
Method to calculate the preferred height of a text object.
static TMP_Settings instance
Get a singleton instance of the settings class.
TextureMappingOptions horizontalMapping
Controls how the face and outline textures will be applied to the text object.
virtual Vector2 CalculatePreferredValues(float defaultFontSize, Vector2 marginSize, bool ignoreTextAutoSizing)
Method to calculate the preferred width and height of the text object.
float ConvertToFloat(char[] chars, int startIndex, int length)
Extracts a float value from char[] assuming we know the position of the start, end and decimal point.
virtual void ClearSubMeshObjects()
Destroy Sub Mesh Objects.
void AddFloatToCharArray(float number, ref int index, int precision)
Function used in conjunction with SetText()
Vector2 PackUV(float x, float y, float scale)
Function to pack scale information in the UV2 Channel.
static bool TryGetColorGradientPreset(int hashCode, out TMP_ColorGradient gradientPreset)
Function returning the Color Gradient Preset corresponding to the provided hash code.
virtual void SetCulling()
Set the culling mode on the material.
float characterWidthAdjustment
Percentage the width of characters can be adjusted before text auto-sizing begins to reduce the point...
Material fontMaterial
The material to be assigned to this text object. An instance of the material will be assigned to the ...
void Add(T item)
Function to add a new item to the stack.
new RectTransform rectTransform
Returns are reference to the RectTransform
static bool enableTintAllSprites
Controls if TintAllSprites is enabled on newly created text objects by default.
Bounds GetTextBounds(bool onlyVisibleCharacters)
Method which returns the bounds of the text object;
virtual void ForceMeshUpdate(bool ignoreActiveState)
Method used for resetting vertex layout when switching to and from Volumetric Text mode.
bool havePropertiesChanged
Property tracking if any of the text properties have changed. Flag is set before the text is regenera...
int GetTagHashCode(ref char[] text, int index, out int closeIndex)
Get Hashcode for a given tag.
_VerticalAlignmentOptions
Internal vertical text alignment options.
bool enableCulling
Sets the culling on the shaders. Note changing this value will result in an instance of the material.
void SetTextArrayToCharArray(char[] sourceText, ref int[] charBuffer)
Copies Content of formatted SetText() to charBuffer.
static int AddMaterialReference(Material material, TMP_FontAsset fontAsset, MaterialReference[] materialReferences, Dictionary< int, int > materialReferenceIndexLookup)
Function to add a new material reference and returning its index in the material reference array.
bool isOrthographic
Sets Perspective Correction to Zero for Orthographic Camera mode & 0.875f for Perspective Camera mode...
virtual Vector4 margin
The margins of the text object.
Color32 faceColor
Sets the color of the _FaceColor property of the assigned material. Changing face color will result i...
virtual TMP_TextInfo GetTextInfo(string text)
Function used to evaluate the length of a text string.
bool isTextOverflowing
Indicates if the text exceeds the vertical bounds of its text container.
void SetDefault(T item)
Function to set the first item on the stack and reset index.
int GetUTF16(string text, int i)
Convert UTF-16 Hex to Char
virtual void SetFaceColor(Color32 color)
Function called internally to set the face color of the material. This will results in an instance of...
float GetPreferredWidth()
Method to calculate the preferred width of a text object.
virtual float preferredWidth
Computed preferred width of the text object.
int GetTagHashCode(ref int[] text, int index, out int closeIndex)
Get Hashcode for a given tag.
Vector2 GetPreferredValues(string text, float width, float height)
Function to Calculate the Preferred Width and Height of the text object given a certain string and si...
virtual void SetVertices(Vector3[] vertices)
Function to push a new set of vertices to the mesh.
int firstVisibleCharacter
The first character which should be made visible in conjunction with the Text Overflow Linked mode.
Dictionary< int, KerningPair > kerningDictionary
Dictionary containing the kerning data
virtual void InternalCrossFadeAlpha(float alpha, float duration, bool ignoreTimeScale)
bool isVolumetricText
Determines if the geometry of the characters will be quads or volumetric (cubes).
void SetText(string text, float arg0)
Color32 HexCharsToColor(char[] hexChars, int startIndex, int length)
Method to convert Hex Color values to Color32
float PackUV(float x, float y)
TMP_FontAsset font
The Font Asset to be assigned to this text object.
TextOverflowModes overflowMode
void StringBuilderToIntArray(StringBuilder sourceText, ref int[] charBuffer)
Copy contents of StringBuilder into int array.
void SetText(string text)
static void AddColorGradientPreset(int hashCode, TMP_ColorGradient spriteAsset)
Add new Color Gradient Preset to dictionary.
virtual Material [] fontMaterials
The materials to be assigned to this text object. An instance of the materials will be assigned.
virtual void ForceMeshUpdate()
Function to force the regeneration of the text object.
float paragraphSpacing
The amount of additional spacing to add between each lines of text.
virtual void FillCharacterVertexBuffers(int i, int index_X4)
Store vertex attributes into the appropriate TMP_MeshInfo.
virtual void DrawUnderlineMesh(Vector3 start, Vector3 end, ref int index, float startScale, float endScale, float maxScale, float sdfScale, Color32 underlineColor)
Method to add the underline geometry.
static bool enableWordWrapping
Controls if Word Wrapping will be enabled on newly created text objects by default.
virtual void UpdateVertexData()
Function to push the updated vertex data into the mesh and renderer.
TextureMappingOptions verticalMapping
Controls how the face and outline textures will be applied to the text object.
LayoutElement layoutElement
bool ValidateHtmlTag(int[] chars, int startIndex, out int endIndex)
Function to identify and validate the rich tag. Returns the position of the > if the tag was valid.
bool isUsingBold
Property used in conjunction with padding calculation for the geometry.
static bool enableExtraPadding
Controls if Extra Padding is enabled on newly created text objects by default.
void SetTextSortingOrder(VertexSortingOrder order)
Function to control the sorting of the geometry of the text object.
virtual void SetSharedMaterial(Material mat)
Function called internally when a new shared material is assigned via the fontSharedMaterial property...
Vector2 GetPreferredValues(string text)
Function to Calculate the Preferred Width and Height of the text object given a certain string.
float fontSizeMax
Maximum point size of the font when text auto-sizing is enabled.
TMP_SpriteAnimator spriteAnimator
Component used to control wrapping of text following some arbitrary shape.
virtual Material GetMaterial(Material mat)
Function called internally when a new material is assigned via the fontMaterial property.
float GetPreferredWidth(Vector2 margin)
Method to calculate the preferred width of a text object.
bool ReplaceClosingStyleTag(ref int[] sourceText, int srcIndex, ref int[] charBuffer, ref int writeIndex)
Method to handle inline replacement of style tag by closing style definition.
static TMP_SpriteAsset SearchForSpriteByHashCode(TMP_SpriteAsset spriteAsset, int hashCode, bool includeFallbacks, out int spriteIndex)
Search the given sprite asset and fallbacks for a sprite whose hash code value of its name matches th...
int firstOverflowCharacterIndex
The first character which exceeds the vertical bounds of its text container.
virtual float renderedWidth
Compute the rendered width of the text object.
int maxVisibleCharacters
Allows to control how many characters are visible from the input.
TMP_ColorGradient colorGradientPreset
Set the vertex colors of the 4 vertices of each character quads.
float GetRenderedWidth()
Method returning the rendered width of the text object.
virtual void GenerateTextMesh()
Method which parses the text input, does the layout of the text as well as generating the geometry.
bool extraPadding
Adds extra padding around each character. This may be necessary when the displayed text is very small...
bool IsTagName(ref string text, string tag, int index)
Method to check for a matching rich text tag.
Bounds GetTextBounds()
Method which returns the bounds of the text object;
void SetCharArray(char[] sourceText, int start, int length)
Character array containing the text to be displayed.
bool enableKerning
Determines if kerning is enabled or disabled.
virtual Material fontSharedMaterial
The material to be assigned to this text object.
void AddIntToCharArray(int number, ref int index, int precision)
// Function used in conjunction with SetText()
float outlineWidth
Sets the thickness of the outline of the font. Setting this value will result in an instance of the m...
int maxVisibleWords
Allows to control how many words are visible from the input.
int HexToInt(char hex)
Function to pack scale information in the UV2 Channel.
void ResizeLineExtents(int size)
Function to increase the size of the Line Extents Array.
float wordSpacing
The amount of additional spacing between words.
static Vector2 defaultTextMeshProUITextContainerSize
The Default Width of the Text Container of a TextMeshProUI object.
Vector2 GetRenderedValues(bool onlyVisibleCharacters)
float wordWrappingRatios
Controls the blending between using character and word spacing to fill-in the space for justified tex...
int GetAttributeParameters(char[] chars, int startIndex, int length, ref float[] parameters)
Method which returns the number of parameters used in a tag attribute and populates an array with suc...
static void AddSpriteAsset(TMP_SpriteAsset spriteAsset)
Add new Sprite Asset to dictionary.
TMP custom data type to represent 32 bit characters.
_HorizontalAlignmentOptions
Internal horizontal text alignment options.
bool isTextTruncated
Property indicating whether the text is Truncated or using Ellipsis.
int RestoreWordWrappingState(ref WordWrapState state)
Restore the State of various variables used in the mesh creation loop.
void SetText(string text, float arg0, float arg1, float arg2)
int pageToDisplay
Controls which page of text is shown
float lineSpacingAdjustment
The amount of potential line spacing adjustment before text auto sizing kicks in.
virtual float GetPaddingForMaterial(Material mat)
Get the padding value for the given material
float ConvertToFloat(char[] chars, int startIndex, int length, out int lastIndex)
Extracts a float value from char[] given a start index and length.
void SetTextSortingOrder(int[] order)
Function to sort the geometry of the text object in accordance to the provided order.
float fontScale
The scale of the current text.
void ResizeInternalArray< T >(ref T[] array)
static void AddFontMaterial(int hashCode, Material material)
Add new Material reference to dictionary.
static void AddFontAsset(TMP_FontAsset fontAsset)
Add new font asset reference to dictionary.
virtual void SetOutlineThickness(float thickness)
Function called internally to set the outline thickness property of the material. This will results i...
virtual float GetPaddingForMaterial()
Get the padding value for the currently assigned material
bool enableWordWrapping
Controls whether or not word wrapping is applied. When disabled, the text will be displayed on a sing...
void GetSpecialCharacters(TMP_FontAsset fontAsset)
Method used to find and cache references to the Underline and Ellipsis characters.
FaceInfo fontInfo
The general information about the font.
override Color color
This is the default vertex color assigned to each vertices. Color tags will override vertex colors un...
virtual void AdjustLineOffset(int startIndex, int endIndex, float offset)
Method to adjust line spacing as a result of using different fonts or font point size.
void SetCharArray(int[] sourceText, int start, int length)
Character array containing the text to be displayed.
virtual void SetOutlineColor(Color32 color)
Function called internally to set the outline color of the material. This will results in an instance...
int GetTagHashCode(ref StringBuilder text, int index, out int closeIndex)
Get Hashcode for a given tag.
string text
A string containing the text to be displayed.
bool ReplaceClosingStyleTag(ref char[] sourceText, int srcIndex, ref int[] charBuffer, ref int writeIndex)
Method to handle inline replacement of style tag by closing style definition.
bool richText
Enables or Disables Rich Text Tags
static TMP_Style GetStyle(int hashCode)
Function to retrieve the Style matching the HashCode.
Class that contains the basic information about the font.
bool enableAutoSizing
Enable text auto-sizing
static float defaultTextAutoSizingMaxRatio
The multiplier used to computer the default Max point size when Text Auto Sizing is used.
void ReplaceTagWithCharacter(int[] chars, int insertionIndex, int tagLength, char c)
Replace a given number of characters (tag) in the array with a new character and shift subsequent cha...
virtual float renderedHeight
Compute the rendered height of the text object.
static bool TryGetMaterial(int hashCode, out Material material)
Function returning the Font Material corresponding to the provided hash code.
void LoadDefaultSettings()
Internal function used to load the default settings of text objects.
bool IsTagName(ref char[] text, string tag, int index)
Method to check for a matching rich text tag.
static bool TryGetSpriteAsset(int hashCode, out TMP_SpriteAsset spriteAsset)
Function returning the Sprite Asset corresponding to the provided hash code.
virtual string GetParsedText()
Function which returns the text after it has been parsed and rich text tags removed.
static bool warningsDisabled
Controls the display of warning message in the console.
static string defaultColorGradientPresetsPath
The relative path to a Resources folder in the project that contains Color Gradient Presets.
static bool TryGetFontAsset(int hashCode, out TMP_FontAsset fontAsset)
Function returning the Font Asset corresponding to the provided hash code.
int GetTagHashCode(ref string text, int index, out int closeIndex)
Get Hashcode for a given tag.
bool ignoreVisibility
Forces objects that are not visible to get refreshed.
bool ReplaceOpeningStyleTag(ref char[] sourceText, int srcIndex, out int srcOffset, ref int[] charBuffer, ref int writeIndex)
Method to handle inline replacement of style tag by opening style definition.
bool enableVertexGradient
Determines if Vertex Color Gradient should be used
TextAlignmentOptions alignment
Text alignment options
float fontSizeMin
Minimum point size of the font when text auto-sizing is enabled.
bool ignoreRectMaskCulling
Controls whether or not the text object will be culled when using a 2D Rect Mask.
bool isOverlay
Sets the RenderQueue along with Ztest to force the text to be drawn last and on top of scene elements...
virtual void LoadFontAsset()
Method which derived classes need to override to load Font Assets.
Structure used to track basic XML tags which are binary (on / off)
float GetPreferredHeight(Vector2 margin)
Method to calculate the preferred height of a text object.
void SaveWordWrappingState(ref WordWrapState state, int index, int count)
Function used in conjunction with GetTextInfo to figure out Array allocations.
bool ReplaceClosingStyleTag(ref string sourceText, int srcIndex, ref int[] charBuffer, ref int writeIndex)
Method to handle inline replacement of style tag by closing style definition.
static float defaultTextAutoSizingMinRatio
The multiplier used to computer the default Min point size when Text Auto Sizing is used.
bool ReplaceOpeningStyleTag(ref int[] sourceText, int srcIndex, out int srcOffset, ref int[] charBuffer, ref int writeIndex)
Method to handle inline replacement of style tag by opening style definition.
virtual Mesh mesh
The mesh used by the font asset and material assigned to the text object.
override void CrossFadeColor(Color targetColor, float duration, bool ignoreTimeScale, bool useAlpha)
static TMP_SpriteAsset defaultSpriteAsset
The Default Sprite Asset to be used by default.
Color32 HexCharsToColor(char[] hexChars, int tagCount)
Method to convert Hex color values to Color32
TMP_TextInfo textInfo
Returns data about the text object which includes information about each character,...
static LineBreakingTable linebreakingRules