using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using UnityEngine.Scripting; namespace UnityEngine { // Token: 0x0200023C RID: 572 [UsedByNativeCode] [StructLayout(LayoutKind.Sequential)] public sealed class TextGenerator : IDisposable { // Token: 0x06002743 RID: 10051 RVA: 0x0002CF38 File Offset: 0x0002B138 public TextGenerator() : this(50) { } // Token: 0x06002744 RID: 10052 RVA: 0x0002CF44 File Offset: 0x0002B144 public TextGenerator(int initialCapacity) { this.m_Verts = new List((initialCapacity + 1) * 4); this.m_Characters = new List(initialCapacity + 1); this.m_Lines = new List(20); this.Init(); } // Token: 0x06002745 RID: 10053 RVA: 0x0002CF80 File Offset: 0x0002B180 ~TextGenerator() { ((IDisposable)this).Dispose(); } // Token: 0x06002746 RID: 10054 RVA: 0x0002CFB0 File Offset: 0x0002B1B0 void IDisposable.Dispose() { this.Dispose_cpp(); } // Token: 0x06002747 RID: 10055 RVA: 0x0002CFBC File Offset: 0x0002B1BC private TextGenerationSettings ValidatedSettings(TextGenerationSettings settings) { TextGenerationSettings textGenerationSettings; if (settings.font != null && settings.font.dynamic) { textGenerationSettings = settings; } else { if (settings.fontSize != 0 || settings.fontStyle != FontStyle.Normal) { if (settings.font != null) { Debug.LogWarningFormat(settings.font, "Font size and style overrides are only supported for dynamic fonts. Font '{0}' is not dynamic.", new object[] { settings.font.name }); } settings.fontSize = 0; settings.fontStyle = FontStyle.Normal; } if (settings.resizeTextForBestFit) { if (settings.font != null) { Debug.LogWarningFormat(settings.font, "BestFit is only supported for dynamic fonts. Font '{0}' is not dynamic.", new object[] { settings.font.name }); } settings.resizeTextForBestFit = false; } textGenerationSettings = settings; } return textGenerationSettings; } // Token: 0x06002748 RID: 10056 RVA: 0x0002D0AC File Offset: 0x0002B2AC public void Invalidate() { this.m_HasGenerated = false; } // Token: 0x06002749 RID: 10057 RVA: 0x0002D0B8 File Offset: 0x0002B2B8 public void GetCharacters(List characters) { this.GetCharactersInternal(characters); } // Token: 0x0600274A RID: 10058 RVA: 0x0002D0C4 File Offset: 0x0002B2C4 public void GetLines(List lines) { this.GetLinesInternal(lines); } // Token: 0x0600274B RID: 10059 RVA: 0x0002D0D0 File Offset: 0x0002B2D0 public void GetVertices(List vertices) { this.GetVerticesInternal(vertices); } // Token: 0x0600274C RID: 10060 RVA: 0x0002D0DC File Offset: 0x0002B2DC public float GetPreferredWidth(string str, TextGenerationSettings settings) { settings.horizontalOverflow = HorizontalWrapMode.Overflow; settings.verticalOverflow = VerticalWrapMode.Overflow; settings.updateBounds = true; this.Populate(str, settings); return this.rectExtents.width; } // Token: 0x0600274D RID: 10061 RVA: 0x0002D120 File Offset: 0x0002B320 public float GetPreferredHeight(string str, TextGenerationSettings settings) { settings.verticalOverflow = VerticalWrapMode.Overflow; settings.updateBounds = true; this.Populate(str, settings); return this.rectExtents.height; } // Token: 0x0600274E RID: 10062 RVA: 0x0002D15C File Offset: 0x0002B35C public bool PopulateWithErrors(string str, TextGenerationSettings settings, GameObject context) { TextGenerationError textGenerationError = this.PopulateWithError(str, settings); bool flag; if (textGenerationError == TextGenerationError.None) { flag = true; } else { if ((textGenerationError & TextGenerationError.CustomSizeOnNonDynamicFont) != TextGenerationError.None) { Debug.LogErrorFormat(context, "Font '{0}' is not dynamic, which is required to override its size", new object[] { settings.font }); } if ((textGenerationError & TextGenerationError.CustomStyleOnNonDynamicFont) != TextGenerationError.None) { Debug.LogErrorFormat(context, "Font '{0}' is not dynamic, which is required to override its style", new object[] { settings.font }); } flag = false; } return flag; } // Token: 0x0600274F RID: 10063 RVA: 0x0002D1D0 File Offset: 0x0002B3D0 public bool Populate(string str, TextGenerationSettings settings) { TextGenerationError textGenerationError = this.PopulateWithError(str, settings); return textGenerationError == TextGenerationError.None; } // Token: 0x06002750 RID: 10064 RVA: 0x0002D1F4 File Offset: 0x0002B3F4 private TextGenerationError PopulateWithError(string str, TextGenerationSettings settings) { TextGenerationError textGenerationError; if (this.m_HasGenerated && str == this.m_LastString && settings.Equals(this.m_LastSettings)) { textGenerationError = this.m_LastValid; } else { this.m_LastValid = this.PopulateAlways(str, settings); textGenerationError = this.m_LastValid; } return textGenerationError; } // Token: 0x06002751 RID: 10065 RVA: 0x0002D258 File Offset: 0x0002B458 private TextGenerationError PopulateAlways(string str, TextGenerationSettings settings) { this.m_LastString = str; this.m_HasGenerated = true; this.m_CachedVerts = false; this.m_CachedCharacters = false; this.m_CachedLines = false; this.m_LastSettings = settings; TextGenerationSettings textGenerationSettings = this.ValidatedSettings(settings); TextGenerationError textGenerationError; this.Populate_Internal(str, textGenerationSettings.font, textGenerationSettings.color, textGenerationSettings.fontSize, textGenerationSettings.scaleFactor, textGenerationSettings.lineSpacing, textGenerationSettings.fontStyle, textGenerationSettings.richText, textGenerationSettings.resizeTextForBestFit, textGenerationSettings.resizeTextMinSize, textGenerationSettings.resizeTextMaxSize, textGenerationSettings.verticalOverflow, textGenerationSettings.horizontalOverflow, textGenerationSettings.updateBounds, textGenerationSettings.textAnchor, textGenerationSettings.generationExtents, textGenerationSettings.pivot, textGenerationSettings.generateOutOfBounds, textGenerationSettings.alignByGeometry, out textGenerationError); this.m_LastValid = textGenerationError; return textGenerationError; } // Token: 0x1700092C RID: 2348 // (get) Token: 0x06002752 RID: 10066 RVA: 0x0002D330 File Offset: 0x0002B530 public IList verts { get { if (!this.m_CachedVerts) { this.GetVertices(this.m_Verts); this.m_CachedVerts = true; } return this.m_Verts; } } // Token: 0x1700092D RID: 2349 // (get) Token: 0x06002753 RID: 10067 RVA: 0x0002D36C File Offset: 0x0002B56C public IList characters { get { if (!this.m_CachedCharacters) { this.GetCharacters(this.m_Characters); this.m_CachedCharacters = true; } return this.m_Characters; } } // Token: 0x1700092E RID: 2350 // (get) Token: 0x06002754 RID: 10068 RVA: 0x0002D3A8 File Offset: 0x0002B5A8 public IList lines { get { if (!this.m_CachedLines) { this.GetLines(this.m_Lines); this.m_CachedLines = true; } return this.m_Lines; } } // Token: 0x06002755 RID: 10069 [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void Init(); // Token: 0x06002756 RID: 10070 [ThreadAndSerializationSafe] [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void Dispose_cpp(); // Token: 0x06002757 RID: 10071 RVA: 0x0002D3E4 File Offset: 0x0002B5E4 internal bool Populate_Internal(string str, Font font, Color color, int fontSize, float scaleFactor, float lineSpacing, FontStyle style, bool richText, bool resizeTextForBestFit, int resizeTextMinSize, int resizeTextMaxSize, VerticalWrapMode verticalOverFlow, HorizontalWrapMode horizontalOverflow, bool updateBounds, TextAnchor anchor, Vector2 extents, Vector2 pivot, bool generateOutOfBounds, bool alignByGeometry, out TextGenerationError error) { uint num = 0U; bool flag; if (font == null) { error = TextGenerationError.NoFont; flag = false; } else { bool flag2 = this.Populate_Internal_cpp(str, font, color, fontSize, scaleFactor, lineSpacing, style, richText, resizeTextForBestFit, resizeTextMinSize, resizeTextMaxSize, (int)verticalOverFlow, (int)horizontalOverflow, updateBounds, anchor, extents.x, extents.y, pivot.x, pivot.y, generateOutOfBounds, alignByGeometry, out num); error = (TextGenerationError)num; flag = flag2; } return flag; } // Token: 0x06002758 RID: 10072 RVA: 0x0002D460 File Offset: 0x0002B660 internal bool Populate_Internal_cpp(string str, Font font, Color color, int fontSize, float scaleFactor, float lineSpacing, FontStyle style, bool richText, bool resizeTextForBestFit, int resizeTextMinSize, int resizeTextMaxSize, int verticalOverFlow, int horizontalOverflow, bool updateBounds, TextAnchor anchor, float extentsX, float extentsY, float pivotX, float pivotY, bool generateOutOfBounds, bool alignByGeometry, out uint error) { return TextGenerator.INTERNAL_CALL_Populate_Internal_cpp(this, str, font, ref color, fontSize, scaleFactor, lineSpacing, style, richText, resizeTextForBestFit, resizeTextMinSize, resizeTextMaxSize, verticalOverFlow, horizontalOverflow, updateBounds, anchor, extentsX, extentsY, pivotX, pivotY, generateOutOfBounds, alignByGeometry, out error); } // Token: 0x06002759 RID: 10073 [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool INTERNAL_CALL_Populate_Internal_cpp(TextGenerator self, string str, Font font, ref Color color, int fontSize, float scaleFactor, float lineSpacing, FontStyle style, bool richText, bool resizeTextForBestFit, int resizeTextMinSize, int resizeTextMaxSize, int verticalOverFlow, int horizontalOverflow, bool updateBounds, TextAnchor anchor, float extentsX, float extentsY, float pivotX, float pivotY, bool generateOutOfBounds, bool alignByGeometry, out uint error); // Token: 0x1700092F RID: 2351 // (get) Token: 0x0600275A RID: 10074 RVA: 0x0002D4A8 File Offset: 0x0002B6A8 public Rect rectExtents { get { Rect rect; this.INTERNAL_get_rectExtents(out rect); return rect; } } // Token: 0x0600275B RID: 10075 [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void INTERNAL_get_rectExtents(out Rect value); // Token: 0x17000930 RID: 2352 // (get) Token: 0x0600275C RID: 10076 public extern int vertexCount { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; } // Token: 0x0600275D RID: 10077 [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void GetVerticesInternal(object vertices); // Token: 0x0600275E RID: 10078 [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern UIVertex[] GetVerticesArray(); // Token: 0x17000931 RID: 2353 // (get) Token: 0x0600275F RID: 10079 public extern int characterCount { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; } // Token: 0x17000932 RID: 2354 // (get) Token: 0x06002760 RID: 10080 RVA: 0x0002D4C8 File Offset: 0x0002B6C8 public int characterCountVisible { get { return this.characterCount - 1; } } // Token: 0x06002761 RID: 10081 [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void GetCharactersInternal(object characters); // Token: 0x06002762 RID: 10082 [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern UICharInfo[] GetCharactersArray(); // Token: 0x17000933 RID: 2355 // (get) Token: 0x06002763 RID: 10083 public extern int lineCount { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; } // Token: 0x06002764 RID: 10084 [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void GetLinesInternal(object lines); // Token: 0x06002765 RID: 10085 [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern UILineInfo[] GetLinesArray(); // Token: 0x17000934 RID: 2356 // (get) Token: 0x06002766 RID: 10086 public extern int fontSizeUsedForBestFit { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; } // Token: 0x040006B2 RID: 1714 internal IntPtr m_Ptr; // Token: 0x040006B3 RID: 1715 private string m_LastString; // Token: 0x040006B4 RID: 1716 private TextGenerationSettings m_LastSettings; // Token: 0x040006B5 RID: 1717 private bool m_HasGenerated; // Token: 0x040006B6 RID: 1718 private TextGenerationError m_LastValid; // Token: 0x040006B7 RID: 1719 private readonly List m_Verts; // Token: 0x040006B8 RID: 1720 private readonly List m_Characters; // Token: 0x040006B9 RID: 1721 private readonly List m_Lines; // Token: 0x040006BA RID: 1722 private bool m_CachedVerts; // Token: 0x040006BB RID: 1723 private bool m_CachedCharacters; // Token: 0x040006BC RID: 1724 private bool m_CachedLines; } }