/// <summary> /// Function to create a deep copy of a GlyphInfo. /// </summary> /// <param name="source"></param> /// <returns></returns> public static TMP_Glyph Clone(TMP_Glyph source) { TMP_Glyph copy = new TMP_Glyph(); copy.id = source.id; copy.x = source.x; copy.y = source.y; copy.width = source.width; copy.height = source.height; copy.xOffset = source.xOffset; copy.yOffset = source.yOffset; copy.xAdvance = source.xAdvance; copy.scale = source.scale; return(copy); }
/// <summary> /// /// </summary> /// <param name="glyphInfo"></param> public void AddGlyphInfo(TMP_Glyph[] glyphInfo) { m_glyphInfoList = new List <TMP_Glyph>(); int characterCount = glyphInfo.Length; m_fontInfo.CharacterCount = characterCount; m_characterSet = new int[characterCount]; for (int i = 0; i < characterCount; i++) { TMP_Glyph g = new TMP_Glyph(); g.id = glyphInfo[i].id; g.x = glyphInfo[i].x; g.y = glyphInfo[i].y; g.width = glyphInfo[i].width; g.height = glyphInfo[i].height; g.xOffset = glyphInfo[i].xOffset; g.yOffset = (glyphInfo[i].yOffset); g.xAdvance = glyphInfo[i].xAdvance; g.scale = 1; m_glyphInfoList.Add(g); // While iterating through list of glyphs, find the Descender & Ascender for this GlyphSet. //m_fontInfo.Ascender = Mathf.Max(m_fontInfo.Ascender, glyphInfo[i].yOffset); //m_fontInfo.Descender = Mathf.Min(m_fontInfo.Descender, glyphInfo[i].yOffset - glyphInfo[i].height); //Debug.Log(m_fontInfo.Ascender + " " + m_fontInfo.Descender); m_characterSet[i] = g.id; // Add Character ID to Array to make it easier to get the kerning pairs. } // Sort List by ID. m_glyphInfoList = m_glyphInfoList.OrderBy(s => s.id).ToList(); }
public static TMP_Glyph Clone(TMP_Glyph source) { TMP_Glyph tMP_Glyph = new TMP_Glyph(); tMP_Glyph.id = source.id; tMP_Glyph.x = source.x; tMP_Glyph.y = source.y; tMP_Glyph.width = source.width; tMP_Glyph.height = source.height; tMP_Glyph.xOffset = source.xOffset; tMP_Glyph.yOffset = source.yOffset; tMP_Glyph.xAdvance = source.xAdvance; tMP_Glyph.scale = source.scale; return(tMP_Glyph); }
public static TMP_Glyph Clone(TMP_Glyph source) { return(new TMP_Glyph { id = source.id, x = source.x, y = source.y, width = source.width, height = source.height, xOffset = source.xOffset, yOffset = source.yOffset, xAdvance = source.xAdvance, scale = source.scale }); }
/// <summary> /// Function to create a deep copy of a GlyphInfo. /// </summary> /// <param name="source"></param> /// <returns></returns> public static TMP_Glyph Clone (TMP_Glyph source) { TMP_Glyph copy = new TMP_Glyph(); copy.id = source.id; copy.x = source.x; copy.y = source.y; copy.width = source.width; copy.height = source.height; copy.xOffset = source.xOffset; copy.yOffset = source.yOffset; copy.xAdvance = source.xAdvance; return copy; }
public void AddGlyphInfo(TMP_Glyph[] glyphInfo) { this.m_glyphInfoList = new List <TMP_Glyph>(); int num = glyphInfo.Length; this.m_fontInfo.CharacterCount = num; this.m_characterSet = new int[num]; for (int i = 0; i < num; i++) { TMP_Glyph tmp_Glyph = new TMP_Glyph(); tmp_Glyph.id = glyphInfo[i].id; tmp_Glyph.x = glyphInfo[i].x; tmp_Glyph.y = glyphInfo[i].y; tmp_Glyph.width = glyphInfo[i].width; tmp_Glyph.height = glyphInfo[i].height; tmp_Glyph.xOffset = glyphInfo[i].xOffset; tmp_Glyph.yOffset = glyphInfo[i].yOffset; tmp_Glyph.xAdvance = glyphInfo[i].xAdvance; tmp_Glyph.scale = 1f; this.m_glyphInfoList.Add(tmp_Glyph); this.m_characterSet[i] = tmp_Glyph.id; } this.m_glyphInfoList = this.m_glyphInfoList.OrderBy((TMP_Glyph s) => s.id).ToList <TMP_Glyph>(); }
private static TMP_FontAsset SearchForGlyphInternal(List <TMP_FontAsset> fonts, int character, out TMP_Glyph glyph) { glyph = null; if (fonts != null && fonts.Count > 0) { for (int i = 0; i < fonts.Count; i++) { TMP_FontAsset fontAsset = SearchForGlyphInternal(fonts[i], character, out glyph); if (fontAsset != null) { return(fontAsset); } } } return(null); }
private static TMP_FontAsset SearchForGlyphInternal(TMP_FontAsset font, int character, out TMP_Glyph glyph) { glyph = null; if (font == null) { return(null); } if (font.characterDictionary.TryGetValue(character, out glyph)) { return(font); } else if (font.fallbackFontAssets != null && font.fallbackFontAssets.Count > 0) { for (int i = 0; i < font.fallbackFontAssets.Count && glyph == null; i++) { TMP_FontAsset temp = font.fallbackFontAssets[i]; if (temp == null) { continue; } int id = temp.GetInstanceID(); // Skip over the fallback font asset in the event it is null or if already searched. if (k_searchedFontAssets.Contains(id)) { continue; } // Add to list of font assets already searched. k_searchedFontAssets.Add(id); temp = SearchForGlyphInternal(temp, character, out glyph); if (temp != null) { return(temp); } } } return(null); }
/// <summary> /// Search through the given list of fonts and their possible fallbacks for the specified character. /// </summary> /// <param name="fonts"></param> /// <param name="character"></param> /// <param name="glyph"></param> /// <returns></returns> public static TMP_FontAsset SearchForGlyph(List <TMP_FontAsset> fonts, int character, out TMP_Glyph glyph) { return(SearchForGlyphInternal(fonts, character, out glyph)); }
/// <summary> /// Search through the given font and its fallbacks for the specified character. /// </summary> /// <param name="font">The font asset to search for the given character.</param> /// <param name="character">The character to find.</param> /// <param name="glyph">out parameter containing the glyph for the specified character (if found).</param> /// <returns></returns> public static TMP_FontAsset SearchForGlyph(TMP_FontAsset font, int character, out TMP_Glyph glyph) { if (k_searchedFontAssets == null) { k_searchedFontAssets = new List <int>(); } k_searchedFontAssets.Clear(); return(SearchForGlyphInternal(font, character, out glyph)); }
public void AddGlyphInfo(TMP_Glyph[] glyphInfo) { m_glyphInfoList = new List<TMP_Glyph>(); int characterCount = glyphInfo.Length; m_fontInfo.CharacterCount = characterCount; m_characterSet = new int[characterCount]; for (int i = 0; i < characterCount; i++) { TMP_Glyph g = new TMP_Glyph(); g.id = glyphInfo[i].id; g.x = glyphInfo[i].x; g.y = glyphInfo[i].y; g.width = glyphInfo[i].width; g.height = glyphInfo[i].height; g.xOffset = glyphInfo[i].xOffset; g.yOffset = (glyphInfo[i].yOffset) + m_fontInfo.Padding; // Padding added to keep baseline at Y = 0. g.xAdvance = glyphInfo[i].xAdvance; m_glyphInfoList.Add(g); // While iterating through list of glyphs, find the Descender & Ascender for this GlyphSet. //m_fontInfo.Ascender = Mathf.Max(m_fontInfo.Ascender, glyphInfo[i].yOffset); //m_fontInfo.Descender = Mathf.Min(m_fontInfo.Descender, glyphInfo[i].yOffset - glyphInfo[i].height); //Debug.Log(m_fontInfo.Ascender + " " + m_fontInfo.Descender); m_characterSet[i] = g.id; // Add Character ID to Array to make it easier to get the kerning pairs. } // Sort List by ID. m_glyphInfoList = m_glyphInfoList.OrderBy(s => s.id).ToList(); }
private static TMP_FontAsset SearchForGlyphInternal(TMP_FontAsset font, int character, out TMP_Glyph glyph) { glyph = null; if (font == null) { return(null); } if (font.characterDictionary.TryGetValue(character, out glyph)) { return(font); } if (font.fallbackFontAssets != null && font.fallbackFontAssets.Count > 0) { for (int i = 0; i < font.fallbackFontAssets.Count; i++) { if (glyph != null) { break; } TMP_FontAsset tMP_FontAsset = font.fallbackFontAssets[i]; if (tMP_FontAsset == null) { continue; } int instanceID = tMP_FontAsset.GetInstanceID(); if (!k_searchedFontAssets.Contains(instanceID)) { k_searchedFontAssets.Add(instanceID); tMP_FontAsset = SearchForGlyphInternal(tMP_FontAsset, character, out glyph); if (tMP_FontAsset != null) { return(tMP_FontAsset); } } } } return(null); }
public void ReadFontDefinition() { if (m_fontInfo == null) { return; } m_characterDictionary = new Dictionary <int, TMP_Glyph>(); for (int i = 0; i < m_glyphInfoList.Count; i++) { TMP_Glyph tMP_Glyph = m_glyphInfoList[i]; if (!m_characterDictionary.ContainsKey(tMP_Glyph.id)) { m_characterDictionary.Add(tMP_Glyph.id, tMP_Glyph); } if (tMP_Glyph.scale == 0f) { tMP_Glyph.scale = 1f; } } TMP_Glyph tMP_Glyph2 = new TMP_Glyph(); if (m_characterDictionary.ContainsKey(32)) { m_characterDictionary[32].width = m_characterDictionary[32].xAdvance; m_characterDictionary[32].height = m_fontInfo.Ascender - m_fontInfo.Descender; m_characterDictionary[32].yOffset = m_fontInfo.Ascender; m_characterDictionary[32].scale = 1f; } else { tMP_Glyph2 = new TMP_Glyph(); tMP_Glyph2.id = 32; tMP_Glyph2.x = 0f; tMP_Glyph2.y = 0f; tMP_Glyph2.width = m_fontInfo.Ascender / 5f; tMP_Glyph2.height = m_fontInfo.Ascender - m_fontInfo.Descender; tMP_Glyph2.xOffset = 0f; tMP_Glyph2.yOffset = m_fontInfo.Ascender; tMP_Glyph2.xAdvance = m_fontInfo.PointSize / 4f; tMP_Glyph2.scale = 1f; m_characterDictionary.Add(32, tMP_Glyph2); } if (!m_characterDictionary.ContainsKey(160)) { tMP_Glyph2 = TMP_Glyph.Clone(m_characterDictionary[32]); m_characterDictionary.Add(160, tMP_Glyph2); } if (!m_characterDictionary.ContainsKey(8203)) { tMP_Glyph2 = TMP_Glyph.Clone(m_characterDictionary[32]); tMP_Glyph2.width = 0f; tMP_Glyph2.xAdvance = 0f; m_characterDictionary.Add(8203, tMP_Glyph2); } if (!m_characterDictionary.ContainsKey(8288)) { tMP_Glyph2 = TMP_Glyph.Clone(m_characterDictionary[32]); tMP_Glyph2.width = 0f; tMP_Glyph2.xAdvance = 0f; m_characterDictionary.Add(8288, tMP_Glyph2); } if (!m_characterDictionary.ContainsKey(10)) { tMP_Glyph2 = new TMP_Glyph(); tMP_Glyph2.id = 10; tMP_Glyph2.x = 0f; tMP_Glyph2.y = 0f; tMP_Glyph2.width = 10f; tMP_Glyph2.height = m_characterDictionary[32].height; tMP_Glyph2.xOffset = 0f; tMP_Glyph2.yOffset = m_characterDictionary[32].yOffset; tMP_Glyph2.xAdvance = 0f; tMP_Glyph2.scale = 1f; m_characterDictionary.Add(10, tMP_Glyph2); if (!m_characterDictionary.ContainsKey(13)) { m_characterDictionary.Add(13, tMP_Glyph2); } } if (!m_characterDictionary.ContainsKey(9)) { tMP_Glyph2 = new TMP_Glyph(); tMP_Glyph2.id = 9; tMP_Glyph2.x = m_characterDictionary[32].x; tMP_Glyph2.y = m_characterDictionary[32].y; tMP_Glyph2.width = m_characterDictionary[32].width * (float)(int)tabSize + (m_characterDictionary[32].xAdvance - m_characterDictionary[32].width) * (float)(tabSize - 1); tMP_Glyph2.height = m_characterDictionary[32].height; tMP_Glyph2.xOffset = m_characterDictionary[32].xOffset; tMP_Glyph2.yOffset = m_characterDictionary[32].yOffset; tMP_Glyph2.xAdvance = m_characterDictionary[32].xAdvance * (float)(int)tabSize; tMP_Glyph2.scale = 1f; m_characterDictionary.Add(9, tMP_Glyph2); } m_fontInfo.TabWidth = m_characterDictionary[9].xAdvance; if (m_fontInfo.CapHeight == 0f && m_characterDictionary.ContainsKey(72)) { m_fontInfo.CapHeight = m_characterDictionary[72].yOffset; } if (m_fontInfo.Scale == 0f) { m_fontInfo.Scale = 1f; } if (m_fontInfo.strikethrough == 0f) { m_fontInfo.strikethrough = m_fontInfo.CapHeight / 2.5f; } if (m_fontInfo.Padding == 0f && material.HasProperty(ShaderUtilities.ID_GradientScale)) { m_fontInfo.Padding = material.GetFloat(ShaderUtilities.ID_GradientScale) - 1f; } m_kerningDictionary = new Dictionary <int, KerningPair>(); List <KerningPair> kerningPairs = m_kerningInfo.kerningPairs; for (int j = 0; j < kerningPairs.Count; j++) { KerningPair kerningPair = kerningPairs[j]; KerningPairKey kerningPairKey = new KerningPairKey(kerningPair.AscII_Left, kerningPair.AscII_Right); if (!m_kerningDictionary.ContainsKey(kerningPairKey.key)) { m_kerningDictionary.Add(kerningPairKey.key, kerningPair); } else if (!TMP_Settings.warningsDisabled) { Debug.LogWarning("Kerning Key for [" + kerningPairKey.ascii_Left + "] and [" + kerningPairKey.ascii_Right + "] already exists."); } } hashCode = TMP_TextUtilities.GetSimpleHashCode(base.name); materialHashCode = TMP_TextUtilities.GetSimpleHashCode(material.name); }
private static TMP_FontAsset SearchForGlyphInternal(TMP_FontAsset font, int character, out TMP_Glyph glyph) { glyph = null; if (font == null) { return(null); } if (font.characterDictionary.TryGetValue(character, out glyph)) { return(font); } if (font.fallbackFontAssets != null && font.fallbackFontAssets.Count > 0) { int num = 0; while (num < font.fallbackFontAssets.Count && glyph == null) { TMP_FontAsset tmp_FontAsset = font.fallbackFontAssets[num]; if (!(tmp_FontAsset == null)) { int instanceID = tmp_FontAsset.GetInstanceID(); if (!TMP_FontUtilities.k_searchedFontAssets.Contains(instanceID)) { TMP_FontUtilities.k_searchedFontAssets.Add(instanceID); tmp_FontAsset = TMP_FontUtilities.SearchForGlyphInternal(tmp_FontAsset, character, out glyph); if (tmp_FontAsset != null) { return(tmp_FontAsset); } } } num++; } } return(null); }
/// <summary> /// Search through the given font and its fallbacks for the specified character. /// </summary> /// <param name="font">The font asset to search for the given character.</param> /// <param name="character">The character to find.</param> /// <param name="glyph">out parameter containing the glyph for the specified character (if found).</param> /// <returns></returns> public static TMP_FontAsset SearchForGlyph(TMP_FontAsset font, int character, out TMP_Glyph glyph) { glyph = null; if (font == null) { return(null); } if (font.characterDictionary.TryGetValue(character, out glyph)) { return(font); } else if (font.fallbackFontAssets != null && font.fallbackFontAssets.Count > 0) { for (int i = 0; i < font.fallbackFontAssets.Count && glyph == null; i++) { TMP_FontAsset temp = SearchForGlyph(font.fallbackFontAssets[i], character, out glyph); if (temp != null) { return(temp); } } } return(null); }
//private int loopCountB = 0; //private int loopCountC = 0; //private int loopCountD = 0; //private int loopCountE = 0; //[SerializeField] //private new Material m_MaskMaterial; protected override void Awake() { //Debug.Log("***** Awake() *****"); // Cache Reference to the Canvas m_canvas = this.canvas; m_isOrthographic = true; // Cache Reference to RectTransform. m_rectTransform = gameObject.GetComponent<RectTransform>(); if (m_rectTransform == null) m_rectTransform = gameObject.AddComponent<RectTransform>(); // Cache a reference to the CanvasRenderer. m_canvasRenderer = GetComponent<CanvasRenderer>(); if (m_canvasRenderer == null) m_canvasRenderer = gameObject.AddComponent<CanvasRenderer> (); if (m_mesh == null) { //Debug.Log("Creating new mesh."); m_mesh = new Mesh(); m_mesh.hideFlags = HideFlags.HideAndDontSave; //m_mesh.bounds = new Bounds(transform.position, new Vector3(1000, 1000, 0)); } // Load TMP Settings for new text object instances. if (m_text == null) { m_enableWordWrapping = TMP_Settings.enableWordWrapping; m_enableKerning = TMP_Settings.enableKerning; m_enableExtraPadding = TMP_Settings.enableExtraPadding; m_tintAllSprites = TMP_Settings.enableTintAllSprites; m_parseCtrlCharacters = TMP_Settings.enableParseEscapeCharacters; } // Load the font asset and assign material to renderer. LoadFontAsset(); // Load Default TMP StyleSheet TMP_StyleSheet.LoadDefaultStyleSheet(); // Allocate our initial buffers. m_char_buffer = new int[m_max_characters]; m_cached_TextElement = new TMP_Glyph(); m_isFirstAllocation = true; if (m_textInfo == null) m_textInfo = new TMP_TextInfo(this); // Check if we have a font asset assigned. Return if we don't because no one likes to see purple squares on screen. if (m_fontAsset == null) { Debug.LogWarning("Please assign a Font Asset to this " + transform.name + " gameobject.", this); return; } // Set Defaults for Font Auto-sizing if (m_fontSizeMin == 0) m_fontSizeMin = m_fontSize / 2; if (m_fontSizeMax == 0) m_fontSizeMax = m_fontSize * 2; //// Set flags to ensure our text is parsed and redrawn. m_isInputParsingRequired = true; m_havePropertiesChanged = true; m_isCalculateSizeRequired = true; m_isAwake = true; }
public void ReadFontDefinition() { if (this.m_fontInfo == null) { return; } this.m_characterDictionary = new Dictionary <int, TMP_Glyph>(); for (int i = 0; i < this.m_glyphInfoList.Count; i++) { TMP_Glyph tmp_Glyph = this.m_glyphInfoList[i]; if (!this.m_characterDictionary.ContainsKey(tmp_Glyph.id)) { this.m_characterDictionary.Add(tmp_Glyph.id, tmp_Glyph); } if (tmp_Glyph.scale == 0f) { tmp_Glyph.scale = 1f; } } TMP_Glyph tmp_Glyph2 = new TMP_Glyph(); if (this.m_characterDictionary.ContainsKey(32)) { this.m_characterDictionary[32].width = this.m_characterDictionary[32].xAdvance; this.m_characterDictionary[32].height = this.m_fontInfo.Ascender - this.m_fontInfo.Descender; this.m_characterDictionary[32].yOffset = this.m_fontInfo.Ascender; this.m_characterDictionary[32].scale = 1f; } else { tmp_Glyph2 = new TMP_Glyph(); tmp_Glyph2.id = 32; tmp_Glyph2.x = 0f; tmp_Glyph2.y = 0f; tmp_Glyph2.width = this.m_fontInfo.Ascender / 5f; tmp_Glyph2.height = this.m_fontInfo.Ascender - this.m_fontInfo.Descender; tmp_Glyph2.xOffset = 0f; tmp_Glyph2.yOffset = this.m_fontInfo.Ascender; tmp_Glyph2.xAdvance = this.m_fontInfo.PointSize / 4f; tmp_Glyph2.scale = 1f; this.m_characterDictionary.Add(32, tmp_Glyph2); } if (!this.m_characterDictionary.ContainsKey(160)) { tmp_Glyph2 = TMP_Glyph.Clone(this.m_characterDictionary[32]); this.m_characterDictionary.Add(160, tmp_Glyph2); } if (!this.m_characterDictionary.ContainsKey(8203)) { tmp_Glyph2 = TMP_Glyph.Clone(this.m_characterDictionary[32]); tmp_Glyph2.width = 0f; tmp_Glyph2.xAdvance = 0f; this.m_characterDictionary.Add(8203, tmp_Glyph2); } if (!this.m_characterDictionary.ContainsKey(8288)) { tmp_Glyph2 = TMP_Glyph.Clone(this.m_characterDictionary[32]); tmp_Glyph2.width = 0f; tmp_Glyph2.xAdvance = 0f; this.m_characterDictionary.Add(8288, tmp_Glyph2); } if (!this.m_characterDictionary.ContainsKey(10)) { tmp_Glyph2 = new TMP_Glyph(); tmp_Glyph2.id = 10; tmp_Glyph2.x = 0f; tmp_Glyph2.y = 0f; tmp_Glyph2.width = 10f; tmp_Glyph2.height = this.m_characterDictionary[32].height; tmp_Glyph2.xOffset = 0f; tmp_Glyph2.yOffset = this.m_characterDictionary[32].yOffset; tmp_Glyph2.xAdvance = 0f; tmp_Glyph2.scale = 1f; this.m_characterDictionary.Add(10, tmp_Glyph2); if (!this.m_characterDictionary.ContainsKey(13)) { this.m_characterDictionary.Add(13, tmp_Glyph2); } } if (!this.m_characterDictionary.ContainsKey(9)) { tmp_Glyph2 = new TMP_Glyph(); tmp_Glyph2.id = 9; tmp_Glyph2.x = this.m_characterDictionary[32].x; tmp_Glyph2.y = this.m_characterDictionary[32].y; tmp_Glyph2.width = this.m_characterDictionary[32].width * (float)this.tabSize + (this.m_characterDictionary[32].xAdvance - this.m_characterDictionary[32].width) * (float)(this.tabSize - 1); tmp_Glyph2.height = this.m_characterDictionary[32].height; tmp_Glyph2.xOffset = this.m_characterDictionary[32].xOffset; tmp_Glyph2.yOffset = this.m_characterDictionary[32].yOffset; tmp_Glyph2.xAdvance = this.m_characterDictionary[32].xAdvance * (float)this.tabSize; tmp_Glyph2.scale = 1f; this.m_characterDictionary.Add(9, tmp_Glyph2); } this.m_fontInfo.TabWidth = this.m_characterDictionary[9].xAdvance; if (this.m_fontInfo.CapHeight == 0f && this.m_characterDictionary.ContainsKey(72)) { this.m_fontInfo.CapHeight = this.m_characterDictionary[72].yOffset; } if (this.m_fontInfo.Scale == 0f) { this.m_fontInfo.Scale = 1f; } if (this.m_fontInfo.strikethrough == 0f) { this.m_fontInfo.strikethrough = this.m_fontInfo.CapHeight / 2.5f; } if (this.m_fontInfo.Padding == 0f && this.material.HasProperty(ShaderUtilities.ID_GradientScale)) { this.m_fontInfo.Padding = this.material.GetFloat(ShaderUtilities.ID_GradientScale) - 1f; } this.m_kerningDictionary = new Dictionary <int, KerningPair>(); List <KerningPair> kerningPairs = this.m_kerningInfo.kerningPairs; for (int j = 0; j < kerningPairs.Count; j++) { KerningPair kerningPair = kerningPairs[j]; if (kerningPair.xOffset != 0f) { kerningPairs[j].ConvertLegacyKerningData(); } KerningPairKey kerningPairKey = new KerningPairKey(kerningPair.firstGlyph, kerningPair.secondGlyph); if (!this.m_kerningDictionary.ContainsKey((int)kerningPairKey.key)) { this.m_kerningDictionary.Add((int)kerningPairKey.key, kerningPair); } else if (!TMP_Settings.warningsDisabled) { Debug.LogWarning(string.Concat(new object[] { "Kerning Key for [", kerningPairKey.ascii_Left, "] and [", kerningPairKey.ascii_Right, "] already exists." })); } } this.hashCode = TMP_TextUtilities.GetSimpleHashCode(base.name); this.materialHashCode = TMP_TextUtilities.GetSimpleHashCode(this.material.name); }
//private int loopCountB = 0; //private int loopCountC = 0; //private int loopCountD = 0; //private int loopCountE = 0; protected override void Awake() { //base.Awake(); //Debug.Log("***** Awake() *****"); m_isAwake = true; // Cache Reference to the Canvas m_canvas = this.canvas; m_isOrthographic = true; // Cache Reference to RectTransform. m_rectTransform = gameObject.GetComponent<RectTransform>(); if (m_rectTransform == null) m_rectTransform = gameObject.AddComponent<RectTransform>(); // Cache a reference to the UIRenderer. m_uiRenderer = GetComponent<CanvasRenderer>(); if (m_uiRenderer == null) m_uiRenderer = gameObject.AddComponent<CanvasRenderer> (); if (m_mesh == null) { //Debug.Log("Creating new mesh."); m_mesh = new Mesh(); m_mesh.hideFlags = HideFlags.HideAndDontSave; //m_mesh.bounds = new Bounds(transform.position, new Vector3(1000, 1000, 0)); } // Cache reference to Mask Component if one is present //m_stencilID = MaterialManager.GetStencilID(gameObject); //m_mask = GetComponentInParent<Mask>(); // Load TMP Settings for new text object instances. if (m_settings == null) m_settings = TMP_Settings.LoadDefaultSettings(); if (m_settings != null) { if (m_isNewTextObject) { m_enableWordWrapping = m_settings.enableWordWrapping; m_enableKerning = m_settings.enableKerning; m_enableExtraPadding = m_settings.enableExtraPadding; m_isNewTextObject = false; } m_warningsDisabled = m_settings.warningsDisabled; } // Load the font asset and assign material to renderer. LoadFontAsset(); // Load Default TMP StyleSheet TMP_StyleSheet.LoadDefaultStyleSheet(); // Allocate our initial buffers. m_char_buffer = new int[m_max_characters]; m_cached_TextElement = new TMP_Glyph(); m_isFirstAllocation = true; m_textInfo = new TMP_TextInfo(this); // Check if we have a font asset assigned. Return if we don't because no one likes to see purple squares on screen. if (m_fontAsset == null) { Debug.LogWarning("Please assign a Font Asset to this " + transform.name + " gameobject.", this); return; } // Set Defaults for Font Auto-sizing if (m_fontSizeMin == 0) m_fontSizeMin = m_fontSize / 2; if (m_fontSizeMax == 0) m_fontSizeMax = m_fontSize * 2; //// Set flags to ensure our text is parsed and text re-drawn. m_isInputParsingRequired = true; m_havePropertiesChanged = true; m_isCalculateSizeRequired = true; //ForceMeshUpdate(); // Force an update of the text object to pre-populate the TextInfo and Preferred values used by Unity's Layout System. }
public void ReadFontDefinition() { //Debug.Log("Reading Font Definition for " + this.name + "."); // Make sure that we have a Font Asset file assigned. if (m_fontInfo == null) { return; } // Check Font Asset type //Debug.Log(name + " " + fontAssetType); // Create new instance of GlyphInfo Dictionary for fast access to glyph info. m_characterDictionary = new Dictionary<int, TMP_Glyph>(); foreach (TMP_Glyph glyph in m_glyphInfoList) { if (!m_characterDictionary.ContainsKey(glyph.id)) m_characterDictionary.Add(glyph.id, glyph); } //Debug.Log("PRE: BaseLine:" + m_fontInfo.Baseline + " Ascender:" + m_fontInfo.Ascender + " Descender:" + m_fontInfo.Descender); // + " Centerline:" + m_fontInfo.CenterLine); TMP_Glyph temp_charInfo = new TMP_Glyph(); // Add Character (10) LineFeed, (13) Carriage Return & Space (32) to Dictionary if they don't exists. if (m_characterDictionary.ContainsKey(32)) { m_characterDictionary[32].width = m_characterDictionary[32].xAdvance; // m_fontInfo.Ascender / 5; m_characterDictionary[32].height = m_fontInfo.Ascender - m_fontInfo.Descender; m_characterDictionary[32].yOffset= m_fontInfo.Ascender; } else { //Debug.Log("Adding Character 32 (Space) to Dictionary for Font (" + m_fontInfo.Name + ")."); temp_charInfo = new TMP_Glyph(); temp_charInfo.id = 32; temp_charInfo.x = 0; temp_charInfo.y = 0; temp_charInfo.width = m_fontInfo.Ascender / 5; temp_charInfo.height = m_fontInfo.Ascender - m_fontInfo.Descender; temp_charInfo.xOffset = 0; temp_charInfo.yOffset = m_fontInfo.Ascender; temp_charInfo.xAdvance = m_fontInfo.PointSize / 4; m_characterDictionary.Add(32, temp_charInfo); } // Add Non-Breaking Space (160) if (!m_characterDictionary.ContainsKey(160)) { temp_charInfo = TMP_Glyph.Clone(m_characterDictionary[32]); m_characterDictionary.Add(160, temp_charInfo); } if (m_characterDictionary.ContainsKey(10) == false) { //Debug.Log("Adding Character 10 (Linefeed) to Dictionary for Font (" + m_fontInfo.Name + ")."); temp_charInfo = new TMP_Glyph(); temp_charInfo.id = 10; temp_charInfo.x = 0; // m_characterDictionary[32].x; temp_charInfo.y = 0; // m_characterDictionary[32].y; temp_charInfo.width = 10; // m_characterDictionary[32].width; temp_charInfo.height = m_characterDictionary[32].height; temp_charInfo.xOffset = 0; // m_characterDictionary[32].xOffset; temp_charInfo.yOffset = m_characterDictionary[32].yOffset; temp_charInfo.xAdvance = 0; m_characterDictionary.Add(10, temp_charInfo); if (!m_characterDictionary.ContainsKey(13)) m_characterDictionary.Add(13, temp_charInfo); } // Add Tab Character to Dictionary. Tab is Tab Size * Space Character Width. if (m_characterDictionary.ContainsKey(9) == false) { //Debug.Log("Adding Character 9 (Tab) to Dictionary for Font (" + m_fontInfo.Name + ")."); temp_charInfo = new TMP_Glyph(); temp_charInfo.id = 9; temp_charInfo.x = m_characterDictionary[32].x; temp_charInfo.y = m_characterDictionary[32].y; temp_charInfo.width = m_characterDictionary[32].width * tabSize + (m_characterDictionary[32].xAdvance - m_characterDictionary[32].width) * (tabSize - 1); temp_charInfo.height = m_characterDictionary[32].height; temp_charInfo.xOffset = m_characterDictionary[32].xOffset; temp_charInfo.yOffset = m_characterDictionary[32].yOffset; temp_charInfo.xAdvance = m_characterDictionary[32].xAdvance * tabSize; m_characterDictionary.Add(9, temp_charInfo); } // Centerline is located at the center of character like { or in the middle of the lowercase o. //m_fontInfo.CenterLine = m_characterDictionary[111].yOffset - m_characterDictionary[111].height * 0.5f; // Tab Width is using the same xAdvance as space (32). m_fontInfo.TabWidth = m_characterDictionary[9].xAdvance; // Adjust Font Scale for compatibility reasons if (m_fontInfo.Scale == 0) m_fontInfo.Scale = 1.0f; // Populate Dictionary with Kerning Information m_kerningDictionary = new Dictionary<int, KerningPair>(); List<KerningPair> pairs = m_kerningInfo.kerningPairs; //Debug.Log(m_fontInfo.Name + " has " + pairs.Count + " Kerning Pairs."); for (int i = 0; i < pairs.Count; i++) { KerningPair pair = pairs[i]; KerningPairKey uniqueKey = new KerningPairKey(pair.AscII_Left, pair.AscII_Right); if (m_kerningDictionary.ContainsKey(uniqueKey.key) == false) m_kerningDictionary.Add(uniqueKey.key, pair); else Debug.Log("Kerning Key for [" + uniqueKey.ascii_Left + "] and [" + uniqueKey.ascii_Right + "] already exists."); } // Add Line Breaking Characters m_lineBreakingInfo = new LineBreakingTable(); TextAsset leadingCharFile = Resources.Load("LineBreaking Leading Characters", typeof(TextAsset)) as TextAsset; if (leadingCharFile != null) m_lineBreakingInfo.leadingCharacters = GetCharacters(leadingCharFile); TextAsset followingCharFile = Resources.Load("LineBreaking Following Characters", typeof(TextAsset)) as TextAsset; if (followingCharFile != null) m_lineBreakingInfo.followingCharacters = GetCharacters(followingCharFile); // Compute Hashcode for the font asset name fontHashCode = TMP_TextUtilities.GetSimpleHashCode(this.name); // Compute Hashcode for the material name materialHashCode = TMP_TextUtilities.GetSimpleHashCode(material.name); }
//private int loopCountB; //private int loopCountC; //private int loopCountD; //private int loopCountE; protected override void Awake() { //Debug.Log("Awake() called on Object ID " + GetInstanceID()); // Code to handle Compatibility related to the switch from Color32 to Color if (m_fontColor == Color.white && m_fontColor32 != Color.white) { Debug.LogWarning("Converting Vertex Colors from Color32 to Color.", this); m_fontColor = m_fontColor32; } m_textContainer = GetComponent<TextContainer>(); //if (m_textContainer == null) // m_textContainer = gameObject.AddComponent<TextContainer>(); // Cache Reference to the Mesh Renderer. m_renderer = GetComponent<Renderer>(); if (m_renderer == null) m_renderer = gameObject.AddComponent<Renderer>(); // Disable CanvasRenderer and hide it if (this.canvasRenderer != null) { this.canvasRenderer.hideFlags = HideFlags.HideInInspector; } // Cache Reference to RectTransform m_rectTransform = this.rectTransform; // Cache Reference to the transform; m_transform = this.transform; // Cache a reference to the Mesh Filter. m_meshFilter = GetComponent<MeshFilter>(); if (m_meshFilter == null) m_meshFilter = gameObject.AddComponent<MeshFilter>(); // Cache a reference to our mesh. if (m_mesh == null) { //Debug.Log("Creating new mesh."); m_mesh = new Mesh(); m_mesh.hideFlags = HideFlags.HideAndDontSave; m_meshFilter.mesh = m_mesh; //m_mesh.bounds = new Bounds(transform.position, new Vector3(1000, 1000, 0)); } m_meshFilter.hideFlags = HideFlags.HideInInspector; // Load TMP Settings for new text object instances. if (m_settings == null) m_settings = TMP_Settings.LoadDefaultSettings(); if (m_settings != null) { if (m_isNewTextObject) { m_enableWordWrapping = m_settings.enableWordWrapping; m_enableKerning = m_settings.enableKerning; m_enableExtraPadding = m_settings.enableExtraPadding; m_isNewTextObject = false; } m_warningsDisabled = m_settings.warningsDisabled; } // Load the font asset and assign material to renderer. LoadFontAsset(); // Allocate our initial buffers. m_char_buffer = new int[m_max_characters]; m_cached_TextElement = new TMP_Glyph(); //m_vertices = new Vector3[0]; // m_isFirstAllocation = true; m_textInfo = new TMP_TextInfo(this); // Check if we have a font asset assigned. Return if we don't because no one likes to see purple squares on screen. if (m_fontAsset == null) { Debug.LogWarning("Please assign a Font Asset to this " + transform.name + " gameobject.", this); return; } // Set Defaults for Font Auto-sizing if (m_fontSizeMin == 0) m_fontSizeMin = m_fontSize / 2; if (m_fontSizeMax == 0) m_fontSizeMax = m_fontSize * 2; //// Set flags to cause ensure our text is parsed and text redrawn. m_isInputParsingRequired = true; m_havePropertiesChanged = true; m_isCalculateSizeRequired = true; //ForceMeshUpdate(); // Force an update of the text object to pre-populate the TextInfo and Preferred values. }
/// <summary> /// /// </summary> public void ReadFontDefinition() { //Debug.Log("Reading Font Definition for " + this.name + "."); // Make sure that we have a Font Asset file assigned. if (m_fontInfo == null) { return; } // Check Font Asset type //Debug.Log(name + " " + fontAssetType); // Create new instance of GlyphInfo Dictionary for fast access to glyph info. m_characterDictionary = new Dictionary <int, TMP_Glyph>(); for (int i = 0; i < m_glyphInfoList.Count; i++) { TMP_Glyph glyph = m_glyphInfoList[i]; if (!m_characterDictionary.ContainsKey(glyph.id)) { m_characterDictionary.Add(glyph.id, glyph); } // Compatibility if (glyph.scale == 0) { glyph.scale = 1; } } //Debug.Log("PRE: BaseLine:" + m_fontInfo.Baseline + " Ascender:" + m_fontInfo.Ascender + " Descender:" + m_fontInfo.Descender); // + " Centerline:" + m_fontInfo.CenterLine); TMP_Glyph temp_charInfo = new TMP_Glyph(); // Add Character (10) LineFeed, (13) Carriage Return & Space (32) to Dictionary if they don't exists. if (m_characterDictionary.ContainsKey(32)) { m_characterDictionary[32].width = m_characterDictionary[32].xAdvance; // m_fontInfo.Ascender / 5; m_characterDictionary[32].height = m_fontInfo.Ascender - m_fontInfo.Descender; m_characterDictionary[32].yOffset = m_fontInfo.Ascender; m_characterDictionary[32].scale = 1; } else { //Debug.Log("Adding Character 32 (Space) to Dictionary for Font (" + m_fontInfo.Name + ")."); temp_charInfo = new TMP_Glyph(); temp_charInfo.id = 32; temp_charInfo.x = 0; temp_charInfo.y = 0; temp_charInfo.width = m_fontInfo.Ascender / 5; temp_charInfo.height = m_fontInfo.Ascender - m_fontInfo.Descender; temp_charInfo.xOffset = 0; temp_charInfo.yOffset = m_fontInfo.Ascender; temp_charInfo.xAdvance = m_fontInfo.PointSize / 4; temp_charInfo.scale = 1; m_characterDictionary.Add(32, temp_charInfo); } // Add Non-Breaking Space (160) if (!m_characterDictionary.ContainsKey(160)) { temp_charInfo = TMP_Glyph.Clone(m_characterDictionary[32]); m_characterDictionary.Add(160, temp_charInfo); } // Add Zero Width Space (8203) if (!m_characterDictionary.ContainsKey(8203)) { temp_charInfo = TMP_Glyph.Clone(m_characterDictionary[32]); temp_charInfo.width = 0; temp_charInfo.xAdvance = 0; m_characterDictionary.Add(8203, temp_charInfo); } //Add Zero Width no-break space (8288) if (!m_characterDictionary.ContainsKey(8288)) { temp_charInfo = TMP_Glyph.Clone(m_characterDictionary[32]); temp_charInfo.width = 0; temp_charInfo.xAdvance = 0; m_characterDictionary.Add(8288, temp_charInfo); } // Add Linefeed (10) if (m_characterDictionary.ContainsKey(10) == false) { //Debug.Log("Adding Character 10 (Linefeed) to Dictionary for Font (" + m_fontInfo.Name + ")."); temp_charInfo = new TMP_Glyph(); temp_charInfo.id = 10; temp_charInfo.x = 0; // m_characterDictionary[32].x; temp_charInfo.y = 0; // m_characterDictionary[32].y; temp_charInfo.width = 10; // m_characterDictionary[32].width; temp_charInfo.height = m_characterDictionary[32].height; temp_charInfo.xOffset = 0; // m_characterDictionary[32].xOffset; temp_charInfo.yOffset = m_characterDictionary[32].yOffset; temp_charInfo.xAdvance = 0; temp_charInfo.scale = 1; m_characterDictionary.Add(10, temp_charInfo); if (!m_characterDictionary.ContainsKey(13)) { m_characterDictionary.Add(13, temp_charInfo); } } // Add Tab Character to Dictionary. Tab is Tab Size * Space Character Width. if (m_characterDictionary.ContainsKey(9) == false) { //Debug.Log("Adding Character 9 (Tab) to Dictionary for Font (" + m_fontInfo.Name + ")."); temp_charInfo = new TMP_Glyph(); temp_charInfo.id = 9; temp_charInfo.x = m_characterDictionary[32].x; temp_charInfo.y = m_characterDictionary[32].y; temp_charInfo.width = m_characterDictionary[32].width * tabSize + (m_characterDictionary[32].xAdvance - m_characterDictionary[32].width) * (tabSize - 1); temp_charInfo.height = m_characterDictionary[32].height; temp_charInfo.xOffset = m_characterDictionary[32].xOffset; temp_charInfo.yOffset = m_characterDictionary[32].yOffset; temp_charInfo.xAdvance = m_characterDictionary[32].xAdvance * tabSize; temp_charInfo.scale = 1; m_characterDictionary.Add(9, temp_charInfo); } // Centerline is located at the center of character like { or in the middle of the lowercase o. //m_fontInfo.CenterLine = m_characterDictionary[111].yOffset - m_characterDictionary[111].height * 0.5f; // Tab Width is using the same xAdvance as space (32). m_fontInfo.TabWidth = m_characterDictionary[9].xAdvance; // Set Cap Height if (m_fontInfo.CapHeight == 0 && m_characterDictionary.ContainsKey(72)) { m_fontInfo.CapHeight = m_characterDictionary[72].yOffset; } // Adjust Font Scale for compatibility reasons if (m_fontInfo.Scale == 0) { m_fontInfo.Scale = 1.0f; } // Set Strikethrough Offset (if needed) if (m_fontInfo.strikethrough == 0) { m_fontInfo.strikethrough = m_fontInfo.CapHeight / 2.5f; } // Set Padding value for legacy font assets. if (m_fontInfo.Padding == 0) { if (material.HasProperty(ShaderUtilities.ID_GradientScale)) { m_fontInfo.Padding = material.GetFloat(ShaderUtilities.ID_GradientScale) - 1; } } // Populate Dictionary with Kerning Information m_kerningDictionary = new Dictionary <int, KerningPair>(); List <KerningPair> pairs = m_kerningInfo.kerningPairs; //Debug.Log(m_fontInfo.Name + " has " + pairs.Count + " Kerning Pairs."); for (int i = 0; i < pairs.Count; i++) { KerningPair pair = pairs[i]; // Convert legacy kerning data if (pair.xOffset != 0) { pairs[i].ConvertLegacyKerningData(); } KerningPairKey uniqueKey = new KerningPairKey(pair.firstGlyph, pair.secondGlyph); if (m_kerningDictionary.ContainsKey((int)uniqueKey.key) == false) { m_kerningDictionary.Add((int)uniqueKey.key, pair); } else { if (!TMP_Settings.warningsDisabled) { Debug.LogWarning("Kerning Key for [" + uniqueKey.ascii_Left + "] and [" + uniqueKey.ascii_Right + "] already exists."); } } } // Compute Hashcode for the font asset name hashCode = TMP_TextUtilities.GetSimpleHashCode(this.name); // Compute Hashcode for the material name materialHashCode = TMP_TextUtilities.GetSimpleHashCode(material.name); // Unload font atlas texture //ShaderUtilities.GetShaderPropertyIDs(); //Resources.UnloadAsset(material.GetTexture(ShaderUtilities.ID_MainTex)); // Initialize Font Weights if needed //InitializeFontWeights(); }
public void ReadFontDefinition() { //Debug.Log("Reading Font Definition for " + this.name + "."); // Make sure that we have a Font Asset file assigned. if (m_fontInfo == null) { return; } // Check Font Asset type //Debug.Log(name + " " + fontAssetType); // Create new instance of GlyphInfo Dictionary for fast access to glyph info. m_characterDictionary = new Dictionary <int, TMP_Glyph>(); foreach (TMP_Glyph glyph in m_glyphInfoList) { if (!m_characterDictionary.ContainsKey(glyph.id)) { m_characterDictionary.Add(glyph.id, glyph); } } //Debug.Log("PRE: BaseLine:" + m_fontInfo.Baseline + " Ascender:" + m_fontInfo.Ascender + " Descender:" + m_fontInfo.Descender); // + " Centerline:" + m_fontInfo.CenterLine); TMP_Glyph temp_charInfo = new TMP_Glyph(); // Add Character (10) LineFeed, (13) Carriage Return & Space (32) to Dictionary if they don't exists. if (m_characterDictionary.ContainsKey(32)) { m_characterDictionary[32].width = m_characterDictionary[32].xAdvance; // m_fontInfo.Ascender / 5; m_characterDictionary[32].height = m_fontInfo.Ascender - m_fontInfo.Descender; m_characterDictionary[32].yOffset = m_fontInfo.Ascender; } else { //Debug.Log("Adding Character 32 (Space) to Dictionary for Font (" + m_fontInfo.Name + ")."); temp_charInfo = new TMP_Glyph(); temp_charInfo.id = 32; temp_charInfo.x = 0; temp_charInfo.y = 0; temp_charInfo.width = m_fontInfo.Ascender / 5; temp_charInfo.height = m_fontInfo.Ascender - m_fontInfo.Descender; temp_charInfo.xOffset = 0; temp_charInfo.yOffset = m_fontInfo.Ascender; temp_charInfo.xAdvance = m_fontInfo.PointSize / 4; m_characterDictionary.Add(32, temp_charInfo); } // Add Non-Breaking Space (160) if (!m_characterDictionary.ContainsKey(160)) { temp_charInfo = TMP_Glyph.Clone(m_characterDictionary[32]); m_characterDictionary.Add(160, temp_charInfo); } if (m_characterDictionary.ContainsKey(10) == false) { //Debug.Log("Adding Character 10 (Linefeed) to Dictionary for Font (" + m_fontInfo.Name + ")."); temp_charInfo = new TMP_Glyph(); temp_charInfo.id = 10; temp_charInfo.x = 0; // m_characterDictionary[32].x; temp_charInfo.y = 0; // m_characterDictionary[32].y; temp_charInfo.width = 10; // m_characterDictionary[32].width; temp_charInfo.height = m_characterDictionary[32].height; temp_charInfo.xOffset = 0; // m_characterDictionary[32].xOffset; temp_charInfo.yOffset = m_characterDictionary[32].yOffset; temp_charInfo.xAdvance = 0; m_characterDictionary.Add(10, temp_charInfo); if (!m_characterDictionary.ContainsKey(13)) { m_characterDictionary.Add(13, temp_charInfo); } } // Add Tab Character to Dictionary. Tab is Tab Size * Space Character Width. if (m_characterDictionary.ContainsKey(9) == false) { //Debug.Log("Adding Character 9 (Tab) to Dictionary for Font (" + m_fontInfo.Name + ")."); temp_charInfo = new TMP_Glyph(); temp_charInfo.id = 9; temp_charInfo.x = m_characterDictionary[32].x; temp_charInfo.y = m_characterDictionary[32].y; temp_charInfo.width = m_characterDictionary[32].width * tabSize + (m_characterDictionary[32].xAdvance - m_characterDictionary[32].width) * (tabSize - 1); temp_charInfo.height = m_characterDictionary[32].height; temp_charInfo.xOffset = m_characterDictionary[32].xOffset; temp_charInfo.yOffset = m_characterDictionary[32].yOffset; temp_charInfo.xAdvance = m_characterDictionary[32].xAdvance * tabSize; m_characterDictionary.Add(9, temp_charInfo); } // Centerline is located at the center of character like { or in the middle of the lowercase o. //m_fontInfo.CenterLine = m_characterDictionary[111].yOffset - m_characterDictionary[111].height * 0.5f; // Tab Width is using the same xAdvance as space (32). m_fontInfo.TabWidth = m_characterDictionary[9].xAdvance; // Adjust Font Scale for compatibility reasons if (m_fontInfo.Scale == 0) { m_fontInfo.Scale = 1.0f; } // Populate Dictionary with Kerning Information m_kerningDictionary = new Dictionary <int, KerningPair>(); List <KerningPair> pairs = m_kerningInfo.kerningPairs; //Debug.Log(m_fontInfo.Name + " has " + pairs.Count + " Kerning Pairs."); for (int i = 0; i < pairs.Count; i++) { KerningPair pair = pairs[i]; KerningPairKey uniqueKey = new KerningPairKey(pair.AscII_Left, pair.AscII_Right); if (m_kerningDictionary.ContainsKey(uniqueKey.key) == false) { m_kerningDictionary.Add(uniqueKey.key, pair); } else { Debug.Log("Kerning Key for [" + uniqueKey.ascii_Left + "] and [" + uniqueKey.ascii_Right + "] already exists."); } } // Add Line Breaking Characters m_lineBreakingInfo = new LineBreakingTable(); TextAsset leadingCharFile = Resources.Load("LineBreaking Leading Characters", typeof(TextAsset)) as TextAsset; if (leadingCharFile != null) { m_lineBreakingInfo.leadingCharacters = GetCharacters(leadingCharFile); } TextAsset followingCharFile = Resources.Load("LineBreaking Following Characters", typeof(TextAsset)) as TextAsset; if (followingCharFile != null) { m_lineBreakingInfo.followingCharacters = GetCharacters(followingCharFile); } // Compute Hashcode for the font asset name fontHashCode = TMP_TextUtilities.GetSimpleHashCode(this.name); // Compute Hashcode for the material name materialHashCode = TMP_TextUtilities.GetSimpleHashCode(material.name); }