private void LoadSpriteAsset(TMP_SpriteAsset spriteAsset) { if (spriteAsset == null) { // Load Default SpriteAsset TMP_Settings settings = Resources.Load("TMP Settings") as TMP_Settings; if (settings != null && settings.spriteAsset != null) { spriteAsset = settings.spriteAsset; } else { spriteAsset = Resources.Load("Sprite Assets/Default Sprite Asset") as TMP_SpriteAsset; } } m_spriteAsset = spriteAsset; m_inlineGraphic.texture = m_spriteAsset.spriteSheet; if (m_textComponent != null && m_isInitialized) { m_textComponent.havePropertiesChanged = true; m_textComponent.SetVerticesDirty(); } }
private void LoadSpriteAsset(SpriteAsset spriteAsset) { if (spriteAsset == null) { // Load Default SpriteAsset TMP_Settings settings = Resources.Load("TMP Settings") as TMP_Settings; if (settings != null && settings.spriteAsset != null) { spriteAsset = settings.spriteAsset; } else { spriteAsset = Resources.Load("Sprite Assets/Default Sprite Asset") as SpriteAsset; } // Kyle: we don't have a default, added this to remove console NRE spam if (spriteAsset == null) { return; } } m_spriteAsset = spriteAsset; m_inlineGraphic.texture = m_spriteAsset.spriteSheet; if (m_TextMeshPro != null) { m_TextMeshPro.havePropertiesChanged = true; } if (m_TextMeshProUI != null) { m_TextMeshProUI.havePropertiesChanged = true; } }
private void LoadSpriteAsset(SpriteAsset spriteAsset) { if (spriteAsset == null) { // Load Default SpriteAsset TMP_Settings settings = Resources.Load("TMP Settings") as TMP_Settings; if (settings != null && settings.spriteAsset != null) { spriteAsset = settings.spriteAsset; } else { spriteAsset = Resources.Load("Sprite Assets/Default Sprite Asset") as SpriteAsset; } } m_spriteAsset = spriteAsset; m_inlineGraphic.texture = m_spriteAsset.spriteSheet; if (m_TextMeshPro != null) { m_TextMeshPro.havePropertiesChanged = true; } if (m_TextMeshProUI != null) { m_TextMeshProUI.havePropertiesChanged = true; } }
private void LoadSpriteAsset(SpriteAsset spriteAsset) { //Debug.Log("**** Loading SpriteAsset *****"); if (spriteAsset != null) { } else { // Load Default SpriteAsset TMP_Settings settings = Resources.Load("TMP_Settings") as TMP_Settings; if (settings.spriteAsset != null) { spriteAsset = settings.spriteAsset; } else { spriteAsset = Resources.Load("Sprites/Default Sprite Atlas") as SpriteAsset; } } m_spriteAsset = spriteAsset; m_inlineGraphic.texture = m_spriteAsset.spriteSheet; if (m_TextMeshPro != null) { m_TextMeshPro.hasChanged = true; } if (m_TextMeshProUI != null) { m_TextMeshProUI.hasChanged = true; } }
void OnEnable() { if (Instance == null) { // Load settings from TMP_Settings file TMP_Settings settings = Resources.Load("TMP Settings") as TMP_Settings; if (settings == null) { return; } if (settings.styleSheet != null) { Instance = settings.styleSheet; } else { Instance = Resources.Load("Style Sheets/TMP Default Style Sheet") as TMP_StyleSheet; } if (!m_isDictionaryLoaded) { Instance.LoadStyleDictionary(); } } }
// Event received when TMP resources have been loaded. static void ON_RESOURCES_LOADED() { TMPro_EventManager.RESOURCE_LOAD_EVENT.Remove(ON_RESOURCES_LOADED); TMP_Settings textSettings = TMP_Settings.instance; Selection.activeObject = textSettings; // TODO: Do we want to ping the Project Text Settings asset in the Project Inspector EditorUtility.FocusProjectWindow(); EditorGUIUtility.PingObject(textSettings); }
public static TMP_Settings LoadDefaultSettings() { if (s_Instance == null) { TMP_Settings x = Resources.Load("TMP Settings") as TMP_Settings; if (x != null) { s_Instance = x; } } return(s_Instance); }
public static TMP_Settings LoadDefaultSettings() { if (Instance == null) { TMP_Settings tMP_Settings = Resources.Load("TMP Settings") as TMP_Settings; if (tMP_Settings != null) { Instance = tMP_Settings; } } return(Instance); }
/// <summary> /// Static Function to load the TMP Settings file. /// </summary> /// <returns></returns> public static TMP_Settings LoadDefaultSettings() { if (Instance == null) { // Load settings from TMP_Settings file TMP_Settings settings = Resources.Load("TMP Settings") as TMP_Settings; if (settings != null) Instance = settings; } return Instance; }
public static TMP_Settings LoadDefaultSettings() { if (s_Instance == null) { TMP_Settings tMPSettings = HFFResources.instance.TMPSettings; if (tMPSettings != null) { s_Instance = tMPSettings; } } return(s_Instance); }
public static void LoadLinebreakingRules() { if (TMP_Settings.instance == null) { return; } if (TMP_Settings.s_Instance.m_linebreakingRules == null) { TMP_Settings.s_Instance.m_linebreakingRules = new TMP_Settings.LineBreakingTable(); } TMP_Settings.s_Instance.m_linebreakingRules.leadingCharacters = TMP_Settings.GetCharacters(TMP_Settings.s_Instance.m_leadingCharacters); TMP_Settings.s_Instance.m_linebreakingRules.followingCharacters = TMP_Settings.GetCharacters(TMP_Settings.s_Instance.m_followingCharacters); }
/// <summary> /// Static Function to load the TMP Settings file. /// </summary> /// <returns></returns> public static TMP_Settings LoadDefaultSettings() { if (s_Instance == null) { // Load settings from TMP_Settings file TMP_Settings settings = Resources.Load <TMP_Settings>("TMP Settings"); if (settings != null) { s_Instance = settings; } } return(s_Instance); }
/// <summary> /// Static Function to load the TMP Settings file. /// </summary> /// <returns></returns> public static TMP_Settings LoadDefaultSettings() { if (s_Instance == null) { // Load settings from TMP_Settings file TMP_Settings settings = ObjectPoolManager.GetSharedResource("TMP Settings", EResType.eResFontAsset) as TMP_Settings; if (settings != null) { s_Instance = settings; } } return(s_Instance); }
public static TMP_StyleSheet LoadDefaultStyleSheet() { if (Instance == null) { TMP_Settings tMP_Settings = Resources.Load("TMP Settings") as TMP_Settings; if (tMP_Settings != null && tMP_Settings.styleSheet != null) { Instance = tMP_Settings.styleSheet; } else { Instance = (Resources.Load("Style Sheets/TMP Default Style Sheet") as TMP_StyleSheet); } } return(Instance); }
/// <summary> /// Static Function to load the Default Style Sheet. /// </summary> /// <returns></returns> public static TMP_StyleSheet LoadDefaultStyleSheet() { if (Instance == null) { // Load settings from TMP_Settings file TMP_Settings settings = Resources.Load("TMP Settings") as TMP_Settings; if (settings != null && settings.styleSheet != null) { Instance = settings.styleSheet; } else { Instance = Resources.Load("Style Sheets/TMP Default Style Sheet") as TMP_StyleSheet; } } return(Instance); }
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) { if (target == BuildTarget.iOS) { // Try loading the TMP Settings TMP_Settings settings = Resources.Load <TMP_Settings>("TMP Settings"); if (settings == null) { return; } string file = Path.Combine(pathToBuiltProject, "Classes/UI/Keyboard.mm"); string content = File.ReadAllText(file); content = content.Replace("FILTER_EMOJIS_IOS_KEYBOARD 1", "FILTER_EMOJIS_IOS_KEYBOARD 0"); File.WriteAllText(file, content); } }
private void LoadSpriteAsset(SpriteAsset spriteAsset) { if (spriteAsset == null) { TMP_Settings tMP_Settings = Resources.Load("TMP Settings") as TMP_Settings; spriteAsset = ((!(tMP_Settings != null) || !(tMP_Settings.spriteAsset != null)) ? (Resources.Load("Sprite Assets/Default Sprite Asset") as SpriteAsset) : tMP_Settings.spriteAsset); } m_spriteAsset = spriteAsset; m_inlineGraphic.texture = m_spriteAsset.spriteSheet; if (m_TextMeshPro != null) { m_TextMeshPro.havePropertiesChanged = true; } if (m_TextMeshProUI != null) { m_TextMeshProUI.havePropertiesChanged = true; } }
internal static TMP_Settings GetTextSettings() { if (s_TextSettings == null) { // Try loading the TMP Settings from a Resources folder in the user project. s_TextSettings = Resources.Load <TMP_Settings>("TextSettings"); // ?? ScriptableObject.CreateInstance<TMP_Settings>(); #if UNITY_EDITOR if (s_TextSettings == null) { // Open TMP Resources Importer to enable the user to import the TMP Essential Resources and option TMP Examples & Extras TMP_PackageResourceImporterWindow.ShowPackageImporterWindow(); } #endif } return(s_TextSettings); }
private void OnEnable() { if (Instance == null) { TMP_Settings tMP_Settings = Resources.Load("TMP Settings") as TMP_Settings; if (!(tMP_Settings == null)) { if (tMP_Settings.styleSheet != null) { Instance = tMP_Settings.styleSheet; } else { Instance = (Resources.Load("Style Sheets/TMP Default Style Sheet") as TMP_StyleSheet); } if (!m_isDictionaryLoaded) { Instance.LoadStyleDictionary(); } } } }
//private int loopCountB; //private int loopCountC; //private int loopCountD; //private int loopCountE; 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>(); // Cache Reference to the transform; m_transform = gameObject.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 if (m_settings == null) m_settings = TMP_Settings.LoadDefaultSettings(); if (m_settings != null) { //m_enableWordWrapping = m_settings.enableWordWrapping; //m_enableKerning = m_settings.enableKerning; //m_enableExtraPadding = m_settings.enableExtraPadding; } // Load the font asset and assign material to renderer. LoadFontAsset(); // Allocate our initial buffers. m_char_buffer = new int[m_max_characters]; //m_parsedCharacters = new char[m_max_characters]; //m_lineExtents = new Mesh_Extents[m_max_numberOfLines]; m_cached_GlyphInfo = new GlyphInfo(); m_vertices = new Vector3[0]; // m_isFirstAllocation = true; m_textInfo = new TMP_TextInfo(); //m_fontAssetArray = new TextMeshProFont[16]; // 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. isInputParsingRequired = true; m_havePropertiesChanged = true; ForceMeshUpdate(); // Added to force OnWillRenderObject() to be called in case object is not visible so we get initial bounds for the mesh. }
//void OnPrefabUpdated(GameObject obj) //{ // Debug.Log("Prefab ID " + obj.name + " has been updated. Mesh ID " + m_mesh.GetInstanceID()); // //if (obj.GetInstanceID() == gameObject.GetInstanceID()) // //{ // // if (m_meshFilter.sharedMesh.GetInstanceID() != m_mesh.GetInstanceID()) // // m_mesh = m_meshFilter.sharedMesh; // //} //} // Function which loads either the default font or a newly assigned font asset. This function also assigned the appropriate material to the renderer. void LoadFontAsset() { //Debug.Log("TextMeshPro LoadFontAsset() has been called."); // Current Font Asset is " + (font != null ? font.name: "Null") ); ShaderUtilities.GetShaderPropertyIDs(); // Initialize & Get shader property IDs. if (m_fontAsset == null) { // Load TMP_Settings if (m_settings == null) m_settings = TMP_Settings.LoadDefaultSettings(); if (m_settings != null && m_settings.fontAsset != null) m_fontAsset = m_settings.fontAsset; else m_fontAsset = Resources.Load("Fonts & Materials/ARIAL SDF", typeof(TextMeshProFont)) as TextMeshProFont; if (m_fontAsset == null) { Debug.LogWarning("The ARIAL SDF Font Asset was not found. There is no Font Asset assigned to " + gameObject.name + ".", this); return; } if (m_fontAsset.characterDictionary == null) { Debug.Log("Dictionary is Null!"); } m_renderer.sharedMaterial = m_fontAsset.material; m_sharedMaterial = m_fontAsset.material; m_sharedMaterial.SetFloat("_CullMode", 0); m_sharedMaterial.SetFloat("_ZTestMode", 4); m_renderer.receiveShadows = false; m_renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; // true; // Get a Reference to the Shader } else { if (m_fontAsset.characterDictionary == null) { //Debug.Log("Reading Font Definition and Creating Character Dictionary."); m_fontAsset.ReadFontDefinition(); } //Debug.Log("Font Asset name:" + font.material.name); // If font atlas texture doesn't match the assigned material font atlas, switch back to default material specified in the Font Asset. if (m_renderer.sharedMaterial == null || m_renderer.sharedMaterial.mainTexture == null || m_fontAsset.atlas.GetInstanceID() != m_renderer.sharedMaterial.GetTexture(ShaderUtilities.ID_MainTex).GetInstanceID()) { m_renderer.sharedMaterial = m_fontAsset.material; m_sharedMaterial = m_fontAsset.material; } else { m_sharedMaterial = m_renderer.sharedMaterial; } //m_sharedMaterial.SetFloat("_CullMode", 0); m_sharedMaterial.SetFloat("_ZTestMode", 4); // Check if we are using the SDF Surface Shader if (m_sharedMaterial.passCount > 1) { m_renderer.receiveShadows = true; m_renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On; } else { m_renderer.receiveShadows = false; m_renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; } } m_padding = ShaderUtilities.GetPadding(m_renderer.sharedMaterials, m_enableExtraPadding, m_isUsingBold); //m_alignmentPadding = ShaderUtilities.GetFontExtent(m_sharedMaterial); m_isMaskingEnabled = ShaderUtilities.IsMaskingEnabled(m_sharedMaterial); if (!m_fontAsset.characterDictionary.TryGetValue(95, out m_cached_Underline_GlyphInfo)) //95 Debug.LogWarning("Underscore character wasn't found in the current Font Asset. No characters assigned for Underline.", this); // Add Font Asset and Material to dictionaries if (!m_fontAsset_Dict.ContainsKey(m_fontAsset.fontHashCode)) m_fontAsset_Dict.Add(m_fontAsset.fontHashCode, m_fontAsset); int materialHashCode = TMP_TextUtilities.GetSimpleHashCode(m_sharedMaterial.name); if (!m_fontMaterial_Dict.ContainsKey(materialHashCode)) m_fontMaterial_Dict.Add(materialHashCode, m_sharedMaterial); m_sharedMaterials.Add(m_sharedMaterial); // Hide Material Editor Component //m_renderer.sharedMaterial.hideFlags = HideFlags.None; }
//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 = GetComponentInParent(typeof(Canvas)) as Canvas; // 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 if (m_settings == null) m_settings = TMP_Settings.LoadDefaultSettings(); if (m_settings != null) { //m_enableWordWrapping = m_settings.enableWordWrapping; //m_enableKerning = m_settings.enableKerning; //m_enableExtraPadding = m_settings.enableExtraPadding; } // 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_GlyphInfo = new GlyphInfo(); m_isFirstAllocation = true; m_textInfo = new TMP_TextInfo(); m_textInfo.meshInfo.mesh = m_mesh; // 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. isInputParsingRequired = true; m_havePropertiesChanged = true; m_rectTransformDimensionsChanged = true; ForceMeshUpdate(); // Added to force OnWillRenderObject() to be called in case object is not visible so we get initial bounds for the mesh. }
// Function which loads either the default font or a newly assigned font asset. This function also assigned the appropriate material to the renderer. void LoadFontAsset() { //Debug.Log("***** LoadFontAsset() *****"); //TextMeshPro LoadFontAsset() has been called."); // Current Font Asset is " + (font != null ? font.name: "Null") ); ShaderUtilities.GetShaderPropertyIDs(); if (m_fontAsset == null) { // Load TMP_Settings if (m_settings == null) m_settings = TMP_Settings.LoadDefaultSettings(); if (m_settings != null && m_settings.fontAsset != null) m_fontAsset = m_settings.fontAsset; else m_fontAsset = Resources.Load("Fonts & Materials/ARIAL SDF", typeof(TextMeshProFont)) as TextMeshProFont; if (m_fontAsset == null) { Debug.LogWarning("The ARIAL SDF Font Asset was not found. There is no Font Asset assigned to " + gameObject.name + ".", this); return; } if (m_fontAsset.characterDictionary == null) { Debug.Log("Dictionary is Null!"); } //m_uiRenderer.SetMaterial(m_fontAsset.material, null); m_baseMaterial = m_fontAsset.material; m_sharedMaterial = m_baseMaterial; m_isNewBaseMaterial = true; //m_renderer.receiveShadows = false; //m_renderer.castShadows = false; // true; // Get a Reference to the Shader } else { if (m_fontAsset.characterDictionary == null) { //Debug.Log("Reading Font Definition and Creating Character Dictionary."); m_fontAsset.ReadFontDefinition(); } // Force the use of the base material m_sharedMaterial = m_baseMaterial; m_isNewBaseMaterial = true; // If font atlas texture doesn't match the assigned material font atlas, switch back to default material specified in the Font Asset. if (m_sharedMaterial == null || m_sharedMaterial.mainTexture == null || m_fontAsset.atlas.GetInstanceID() != m_sharedMaterial.mainTexture.GetInstanceID()) { m_sharedMaterial = m_fontAsset.material; m_baseMaterial = m_sharedMaterial; m_isNewBaseMaterial = true; } } // Check & Assign Underline Character for use with the Underline tag. if (!m_fontAsset.characterDictionary.TryGetValue(95, out m_cached_Underline_GlyphInfo)) //95 Debug.LogWarning("Underscore character wasn't found in the current Font Asset. No characters assigned for Underline.", this); m_stencilID = MaterialManager.GetStencilID(gameObject); if (m_stencilID == 0) { if (m_maskingMaterial != null) { MaterialManager.ReleaseStencilMaterial(m_maskingMaterial); m_maskingMaterial = null; } m_sharedMaterial = m_baseMaterial; } else { if (m_maskingMaterial == null) m_maskingMaterial = MaterialManager.GetStencilMaterial(m_baseMaterial, m_stencilID); else if (m_maskingMaterial.GetInt(ShaderUtilities.ID_StencilID) != m_stencilID || m_isNewBaseMaterial) { MaterialManager.ReleaseStencilMaterial(m_maskingMaterial); m_maskingMaterial = MaterialManager.GetStencilMaterial(m_baseMaterial, m_stencilID); } m_sharedMaterial = m_maskingMaterial; } m_isNewBaseMaterial = false; //m_sharedMaterials.Add(m_sharedMaterial); SetShaderDepth(); // Set ZTestMode based on Canvas RenderMode. if (m_uiRenderer == null) m_uiRenderer = GetComponent<CanvasRenderer>(); m_uiRenderer.SetMaterial(m_sharedMaterial, m_sharedMaterial.mainTexture); m_padding = ShaderUtilities.GetPadding(m_sharedMaterial, m_enableExtraPadding, m_isUsingBold); //m_alignmentPadding = ShaderUtilities.GetFontExtent(m_sharedMaterial); }
/// <summary> /// Function to identify and validate the rich tag. Returns the position of the > if the tag was valid. /// </summary> /// <param name="chars"></param> /// <param name="startIndex"></param> /// <param name="endIndex"></param> /// <returns></returns> protected bool ValidateHtmlTag(int[] chars, int startIndex, out int endIndex) { int tagCharCount = 0; byte attributeFlag = 0; TagUnits tagUnits = TagUnits.Pixels; TagType tagType = TagType.None; int attributeIndex = 0; m_xmlAttribute[attributeIndex].nameHashCode = 0; m_xmlAttribute[attributeIndex].valueType = TagType.None; m_xmlAttribute[attributeIndex].valueHashCode = 0; m_xmlAttribute[attributeIndex].valueStartIndex = 0; m_xmlAttribute[attributeIndex].valueLength = 0; m_xmlAttribute[attributeIndex].valueDecimalIndex = 0; endIndex = startIndex; bool isTagSet = false; bool isValidHtmlTag = false; for (int i = startIndex; i < chars.Length && chars[i] != 0 && tagCharCount < m_htmlTag.Length && chars[i] != 60; i++) { if (chars[i] == 62) // ASCII Code of End HTML tag '>' { isValidHtmlTag = true; endIndex = i; m_htmlTag[tagCharCount] = (char)0; break; } m_htmlTag[tagCharCount] = (char)chars[i]; tagCharCount += 1; if (attributeFlag == 1) { if (m_xmlAttribute[attributeIndex].valueStartIndex == 0) { // Check for attribute type if (chars[i] == 43 || chars[i] == 45 || char.IsDigit((char)chars[i])) { tagType = TagType.NumericalValue; m_xmlAttribute[attributeIndex].valueType = TagType.NumericalValue; m_xmlAttribute[attributeIndex].valueStartIndex = tagCharCount - 1; m_xmlAttribute[attributeIndex].valueLength += 1; } else if (chars[i] == 35) { tagType = TagType.ColorValue; m_xmlAttribute[attributeIndex].valueType = TagType.ColorValue; m_xmlAttribute[attributeIndex].valueStartIndex = tagCharCount - 1; m_xmlAttribute[attributeIndex].valueLength += 1; } else if (chars[i] != 34) { tagType = TagType.StringValue; m_xmlAttribute[attributeIndex].valueType = TagType.StringValue; m_xmlAttribute[attributeIndex].valueStartIndex = tagCharCount - 1; m_xmlAttribute[attributeIndex].valueHashCode = (m_xmlAttribute[attributeIndex].valueHashCode << 5) + m_xmlAttribute[attributeIndex].valueHashCode ^ chars[i]; m_xmlAttribute[attributeIndex].valueLength += 1; } } else { if (tagType == TagType.NumericalValue) { if (chars[i] == 46) // '.' Decimal Point Index m_xmlAttribute[attributeIndex].valueDecimalIndex = tagCharCount - 1; // Check for termination of numerical value. if (chars[i] == 112 || chars[i] == 101 || chars[i] == 37 || chars[i] == 32) { attributeFlag = 2; tagType = TagType.None; attributeIndex += 1; m_xmlAttribute[attributeIndex].nameHashCode = 0; m_xmlAttribute[attributeIndex].valueType = TagType.None; m_xmlAttribute[attributeIndex].valueHashCode = 0; m_xmlAttribute[attributeIndex].valueStartIndex = 0; m_xmlAttribute[attributeIndex].valueLength = 0; m_xmlAttribute[attributeIndex].valueDecimalIndex = 0; if (chars[i] == 101) tagUnits = TagUnits.FontUnits; else if (chars[i] == 37) tagUnits = TagUnits.Percentage; } else if (attributeFlag != 2) { m_xmlAttribute[attributeIndex].valueLength += 1; } } else if (tagType == TagType.ColorValue) { if (chars[i] != 32) { m_xmlAttribute[attributeIndex].valueLength += 1; } else { attributeFlag = 2; tagType = TagType.None; attributeIndex += 1; m_xmlAttribute[attributeIndex].nameHashCode = 0; m_xmlAttribute[attributeIndex].valueType = TagType.None; m_xmlAttribute[attributeIndex].valueHashCode = 0; m_xmlAttribute[attributeIndex].valueStartIndex = 0; m_xmlAttribute[attributeIndex].valueLength = 0; m_xmlAttribute[attributeIndex].valueDecimalIndex = 0; } } else if (tagType == TagType.StringValue) { // Compute HashCode value for the named tag. if (chars[i] != 34) { m_xmlAttribute[attributeIndex].valueHashCode = (m_xmlAttribute[attributeIndex].valueHashCode << 5) + m_xmlAttribute[attributeIndex].valueHashCode ^ chars[i]; m_xmlAttribute[attributeIndex].valueLength += 1; } else { //m_xmlAttribute[attributeIndex].valueHashCode = -1; attributeFlag = 2; tagType = TagType.None; attributeIndex += 1; m_xmlAttribute[attributeIndex].nameHashCode = 0; m_xmlAttribute[attributeIndex].valueType = TagType.None; m_xmlAttribute[attributeIndex].valueHashCode = 0; m_xmlAttribute[attributeIndex].valueStartIndex = 0; m_xmlAttribute[attributeIndex].valueLength = 0; m_xmlAttribute[attributeIndex].valueDecimalIndex = 0; } } } } if (chars[i] == 61) // '=' attributeFlag = 1; // Compute HashCode for the name of the attribute if (attributeFlag == 0 && chars[i] == 32) { if (isTagSet) return false; isTagSet = true; attributeFlag = 2; tagType = TagType.None; attributeIndex += 1; m_xmlAttribute[attributeIndex].nameHashCode = 0; m_xmlAttribute[attributeIndex].valueType = TagType.None; m_xmlAttribute[attributeIndex].valueHashCode = 0; m_xmlAttribute[attributeIndex].valueStartIndex = 0; m_xmlAttribute[attributeIndex].valueLength = 0; m_xmlAttribute[attributeIndex].valueDecimalIndex = 0; } if (attributeFlag == 0) m_xmlAttribute[attributeIndex].nameHashCode = (m_xmlAttribute[attributeIndex].nameHashCode << 3) - m_xmlAttribute[attributeIndex].nameHashCode + chars[i]; if (attributeFlag == 2 && chars[i] == 32) attributeFlag = 0; } if (!isValidHtmlTag) { return false; } //Debug.Log("Tag is [" + m_htmlTag.ArrayToString() + "]. Tag HashCode: " + m_xmlAttribute[0].nameHashCode + " Tag Value HashCode: " + m_xmlAttribute[0].valueHashCode + " Attribute 1 HashCode: " + m_xmlAttribute[1].nameHashCode + " Value HashCode: " + m_xmlAttribute[1].valueHashCode); //for (int i = 0; i < attributeIndex + 1; i++) // Debug.Log("Tag [" + i + "] with HashCode: " + m_xmlAttribute[i].nameHashCode + " has value of [" + new string(m_htmlTag, m_xmlAttribute[i].valueStartIndex, m_xmlAttribute[i].valueLength) + "] Numerical Value: " + ConvertToFloat(m_htmlTag, m_xmlAttribute[i].valueStartIndex, m_xmlAttribute[i].valueLength, m_xmlAttribute[i].valueDecimalIndex)); // Special handling of the NoParsing tag if (tag_NoParsing && m_xmlAttribute[0].nameHashCode != 53822163) return false; else if (m_xmlAttribute[0].nameHashCode == 53822163) { tag_NoParsing = false; return true; } // Color <#FF00FF> if (m_htmlTag[0] == 35 && tagCharCount == 7) // if Tag begins with # and contains 7 characters. { m_htmlColor = HexCharsToColor(m_htmlTag, tagCharCount); m_colorStack.Add(m_htmlColor); return true; } // Color <#FF00FF00> with alpha else if (m_htmlTag[0] == 35 && tagCharCount == 9) // if Tag begins with # and contains 9 characters. { m_htmlColor = HexCharsToColor(m_htmlTag, tagCharCount); m_colorStack.Add(m_htmlColor); return true; } else { float value = 0; switch (m_xmlAttribute[0].nameHashCode) { case 98: // <b> m_style |= FontStyles.Bold; m_fontWeightInternal = 700; m_fontWeightStack.Add(700); return true; case 427: // </b> if ((m_fontStyle & FontStyles.Bold) != FontStyles.Bold) { m_style &= ~FontStyles.Bold; m_fontWeightInternal = m_fontWeightStack.Remove(); } return true; case 105: // <i> m_style |= FontStyles.Italic; return true; case 434: // </i> m_style &= ~FontStyles.Italic; return true; case 115: // <s> m_style |= FontStyles.Strikethrough; return true; case 444: // </s> if ((m_fontStyle & FontStyles.Strikethrough) != FontStyles.Strikethrough) m_style &= ~FontStyles.Strikethrough; return true; case 117: // <u> m_style |= FontStyles.Underline; return true; case 446: // </u> if ((m_fontStyle & FontStyles.Underline) != FontStyles.Underline) m_style &= ~FontStyles.Underline; return true; case 6552: // <sub> m_fontScaleMultiplier = m_currentFontAsset.fontInfo.SubSize > 0 ? m_currentFontAsset.fontInfo.SubSize : 1; m_baselineOffset = m_currentFontAsset.fontInfo.SubscriptOffset * m_fontScale * m_fontScaleMultiplier; m_style |= FontStyles.Subscript; return true; case 22673: // </sub> if ((m_style & FontStyles.Subscript) == FontStyles.Subscript) { // Check to make sure we are not also using Superscript if ((m_style & FontStyles.Superscript) == FontStyles.Superscript) { m_fontScaleMultiplier = m_currentFontAsset.fontInfo.SubSize > 0 ? m_currentFontAsset.fontInfo.SubSize : 1; m_baselineOffset = m_currentFontAsset.fontInfo.SuperscriptOffset * m_fontScale * m_fontScaleMultiplier; } else { m_baselineOffset = 0; m_fontScaleMultiplier = 1; } m_style &= ~FontStyles.Subscript; } return true; case 6566: // <sup> m_fontScaleMultiplier = m_currentFontAsset.fontInfo.SubSize > 0 ? m_currentFontAsset.fontInfo.SubSize : 1; m_baselineOffset = m_currentFontAsset.fontInfo.SuperscriptOffset * m_fontScale * m_fontScaleMultiplier; m_style |= FontStyles.Superscript; return true; case 22687: // </sup> if ((m_style & FontStyles.Superscript) == FontStyles.Superscript) { // Check to make sure we are not also using Superscript if ((m_style & FontStyles.Subscript) == FontStyles.Subscript) { m_fontScaleMultiplier = m_currentFontAsset.fontInfo.SubSize > 0 ? m_currentFontAsset.fontInfo.SubSize : 1; m_baselineOffset = m_currentFontAsset.fontInfo.SubscriptOffset * m_fontScale * m_fontScaleMultiplier; } else { m_baselineOffset = 0; m_fontScaleMultiplier = 1; } m_style &= ~FontStyles.Superscript; } return true; case -330774850: // <font-weight> value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength, m_xmlAttribute[0].valueDecimalIndex); if (value == -9999 || value == 0) return false; if ((m_fontStyle & FontStyles.Bold) == FontStyles.Bold) { // Nothing happens since Bold is forced on the text. //m_fontWeight = 700; return true; } // Remove bold style m_style &= ~FontStyles.Bold; switch ((int)value) { case 100: m_fontWeightInternal = 100; break; case 200: m_fontWeightInternal = 200; break; case 300: m_fontWeightInternal = 300; break; case 400: m_fontWeightInternal = 400; break; case 500: m_fontWeightInternal = 500; break; case 600: m_fontWeightInternal = 600; break; case 700: m_fontWeightInternal = 700; m_style |= FontStyles.Bold; break; case 800: m_fontWeightInternal = 800; break; case 900: m_fontWeightInternal = 900; break; } m_fontWeightStack.Add(m_fontWeightInternal); return true; case -1885698441: // </font-weight> m_fontWeightInternal = m_fontWeightStack.Remove(); return true; case 6380: // <pos=000.00px> <pos=0em> <pos=50%> value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength, m_xmlAttribute[0].valueDecimalIndex); if (value == -9999) return false; switch (tagUnits) { case TagUnits.Pixels: m_xAdvance = value; //m_isIgnoringAlignment = true; return true; case TagUnits.FontUnits: m_xAdvance = value * m_fontScale * m_fontAsset.fontInfo.TabWidth / m_fontAsset.tabSize; //m_isIgnoringAlignment = true; return true; case TagUnits.Percentage: m_xAdvance = m_marginWidth * value / 100; //m_isIgnoringAlignment = true; return true; } return false; case 22501: // </pos> m_isIgnoringAlignment = false; return true; case 16034505: // <voffset> value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength, m_xmlAttribute[0].valueDecimalIndex); if (value == -9999 || value == 0) return false; switch (tagUnits) { case TagUnits.Pixels: m_baselineOffset = value; return true; case TagUnits.FontUnits: m_baselineOffset = value * m_fontScale * m_fontAsset.fontInfo.Ascender; return true; case TagUnits.Percentage: //m_baselineOffset = m_marginHeight * val / 100; return false; } return false; case 54741026: // </voffset> m_baselineOffset = 0; return true; case 43991: // <page> // This tag only works when Overflow - Page mode is used. if (m_overflowMode == TextOverflowModes.Page) { m_xAdvance = 0 + tag_LineIndent + tag_Indent; //m_textInfo.lineInfo[m_lineNumber].marginLeft = m_xAdvance; m_lineOffset = 0; m_pageNumber += 1; m_isNewPage = true; } return true; case 43969: // <nobr> m_isNonBreakingSpace = true; return true; case 156816: // </nobr> m_isNonBreakingSpace = false; return true; case 45545: // <size=> value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength, m_xmlAttribute[0].valueDecimalIndex); if (value == -9999 || value == 0) return false; switch (tagUnits) { case TagUnits.Pixels: if (m_htmlTag[5] == 43) // <size=+00> { m_currentFontSize = m_fontSize + value; m_sizeStack.Add(m_currentFontSize); m_fontScale = (m_currentFontSize / m_currentFontAsset.fontInfo.PointSize * m_currentFontAsset.fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f)); return true; } else if (m_htmlTag[5] == 45) // <size=-00> { m_currentFontSize = m_fontSize + value; m_sizeStack.Add(m_currentFontSize); m_fontScale = (m_currentFontSize / m_currentFontAsset.fontInfo.PointSize * m_currentFontAsset.fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f)); return true; } else // <size=00.0> { m_currentFontSize = value; m_sizeStack.Add(m_currentFontSize); m_fontScale = (m_currentFontSize / m_currentFontAsset.fontInfo.PointSize * m_currentFontAsset.fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f)); return true; } case TagUnits.FontUnits: m_currentFontSize = m_fontSize * value; m_sizeStack.Add(m_currentFontSize); m_fontScale = (m_currentFontSize / m_currentFontAsset.fontInfo.PointSize * m_currentFontAsset.fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f)); return true; case TagUnits.Percentage: m_currentFontSize = m_fontSize * value / 100; m_sizeStack.Add(m_currentFontSize); m_fontScale = (m_currentFontSize / m_currentFontAsset.fontInfo.PointSize * m_currentFontAsset.fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f)); return true; } return false; case 158392: // </size> m_currentFontSize = m_sizeStack.Remove(); m_fontScale = (m_currentFontSize / m_currentFontAsset.fontInfo.PointSize * m_currentFontAsset.fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f)); return true; case 41311: // <font=xx> //Debug.Log("Font name: \"" + new string(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength) + "\" HashCode: " + m_xmlAttribute[0].valueHashCode + " Material Name: \"" + new string(m_htmlTag, m_xmlAttribute[1].valueStartIndex, m_xmlAttribute[1].valueLength) + "\" Hashcode: " + m_xmlAttribute[1].valueHashCode); int fontHashCode = m_xmlAttribute[0].valueHashCode; int materialAttributeHashCode = m_xmlAttribute[1].nameHashCode; int materialHashCode = m_xmlAttribute[1].valueHashCode; // Special handling for <font=default> or <font=Default> if (fontHashCode == 764638571 || fontHashCode == 523367755) { m_currentFontAsset = m_materialReferences[0].fontAsset; m_currentMaterial = m_materialReferences[0].material; m_currentMaterialIndex = 0; //Debug.Log("<font=Default> assigning Font Asset [" + m_currentFontAsset.name + "] with Material [" + m_currentMaterial.name + "]."); m_fontScale = (m_currentFontSize / m_currentFontAsset.fontInfo.PointSize * m_currentFontAsset.fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f)); m_materialReferenceStack.Add(m_materialReferences[0]); return true; } TMP_FontAsset tempFont; Material tempMaterial; // HANDLE NEW FONT ASSET if (MaterialReferenceManager.TryGetFontAsset(fontHashCode, out tempFont)) { //if (tempFont != m_currentFontAsset) //{ // //Debug.Log("Assigning Font Asset: " + tempFont.name); // m_currentFontAsset = tempFont; // m_fontScale = (m_currentFontSize / m_currentFontAsset.fontInfo.PointSize * m_currentFontAsset.fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f)); //} } else { // Load Font Asset tempFont = Resources.Load<TMP_FontAsset>("Fonts & Materials/" + new string(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength)); if (tempFont == null) return false; // Add new reference to the font asset as well as default material to the MaterialReferenceManager MaterialReferenceManager.AddFontAsset(tempFont); } // HANDLE NEW MATERIAL if (materialAttributeHashCode == 0 && materialHashCode == 0) { // No material specified then use default font asset material. m_currentMaterial = tempFont.material; m_currentMaterialIndex = MaterialReference.AddMaterialReference(m_currentMaterial, tempFont, m_materialReferences, m_materialReferenceIndexLookup); m_materialReferenceStack.Add(m_materialReferences[m_currentMaterialIndex]); } else if (materialAttributeHashCode == 103415287) // using material attribute { if (MaterialReferenceManager.TryGetMaterial(materialHashCode, out tempMaterial)) { m_currentMaterial = tempMaterial; m_currentMaterialIndex = MaterialReference.AddMaterialReference(m_currentMaterial, tempFont, m_materialReferences, m_materialReferenceIndexLookup); m_materialReferenceStack.Add(m_materialReferences[m_currentMaterialIndex]); } else { // Load new material tempMaterial = Resources.Load<Material>("Fonts & Materials/" + new string(m_htmlTag, m_xmlAttribute[1].valueStartIndex, m_xmlAttribute[1].valueLength)); if (tempMaterial == null) return false; // Add new reference to this material in the MaterialReferenceManager MaterialReferenceManager.AddFontMaterial(materialHashCode, tempMaterial); m_currentMaterial = tempMaterial; m_currentMaterialIndex = MaterialReference.AddMaterialReference(m_currentMaterial, tempFont, m_materialReferences, m_materialReferenceIndexLookup); m_materialReferenceStack.Add(m_materialReferences[m_currentMaterialIndex]); } } else return false; m_currentFontAsset = tempFont; m_fontScale = (m_currentFontSize / m_currentFontAsset.fontInfo.PointSize * m_currentFontAsset.fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f)); return true; case 154158: // </font> MaterialReference materialReference = m_materialReferenceStack.Remove(); m_currentFontAsset = materialReference.fontAsset; m_currentMaterial = materialReference.material; m_currentMaterialIndex = materialReference.index; m_fontScale = (m_currentFontSize / m_currentFontAsset.fontInfo.PointSize * m_currentFontAsset.fontInfo.Scale * (m_isOrthographic ? 1 : 0.1f)); return true; case 320078: // <space=000.00> value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength, m_xmlAttribute[0].valueDecimalIndex); if (value == -9999 || value == 0) return false; switch (tagUnits) { case TagUnits.Pixels: m_xAdvance += value; return true; case TagUnits.FontUnits: m_xAdvance += value * m_fontScale * m_fontAsset.fontInfo.TabWidth / m_fontAsset.tabSize; return true; case TagUnits.Percentage: // Not applicable return false; } return false; case 276254: // <alpha=#FF> if (m_xmlAttribute[0].valueLength != 3) return false; m_htmlColor.a = (byte)(HexToInt(m_htmlTag[7]) * 16 + HexToInt(m_htmlTag[8])); return true; case 1750458: // <a name=" "> return false; case 426: // </a> return true; case 43066: // <link="name"> if (m_isParsingText) { tag_LinkInfo.textComponent = this; tag_LinkInfo.hashCode = m_xmlAttribute[0].valueHashCode; tag_LinkInfo.linkTextfirstCharacterIndex = m_characterCount; tag_LinkInfo.linkIdFirstCharacterIndex = startIndex + m_xmlAttribute[0].valueStartIndex; tag_LinkInfo.linkIdLength = m_xmlAttribute[0].valueLength; } return true; case 155913: // </link> if (m_isParsingText) { tag_LinkInfo.linkTextLength = m_characterCount - tag_LinkInfo.linkTextfirstCharacterIndex; int size = m_textInfo.linkInfo.Length; if (m_textInfo.linkCount + 1 > size) TMP_TextInfo.Resize(ref m_textInfo.linkInfo, size + 1); m_textInfo.linkInfo[m_textInfo.linkCount] = tag_LinkInfo; m_textInfo.linkCount += 1; } return true; case 275917: // <align=> switch (m_xmlAttribute[0].valueHashCode) { case 3774683: // <align=left> m_lineJustification = TextAlignmentOptions.Left; return true; case 136703040: // <align=right> m_lineJustification = TextAlignmentOptions.Right; return true; case -458210101: // <align=center> m_lineJustification = TextAlignmentOptions.Center; return true; case -523808257: // <align=justified> m_lineJustification = TextAlignmentOptions.Justified; return true; } return false; case 1065846: // </align> m_lineJustification = m_textAlignment; return true; case 327550: // <width=xx> value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength, m_xmlAttribute[0].valueDecimalIndex); if (value == -9999 || value == 0) return false; switch (tagUnits) { case TagUnits.Pixels: m_width = value; break; case TagUnits.FontUnits: return false; //break; case TagUnits.Percentage: m_width = m_marginWidth * value / 100; break; } return true; case 1117479: // </width> m_width = -1; return true; case 322689: // <style="name"> TMP_Style style = TMP_StyleSheet.Instance.GetStyle(m_xmlAttribute[0].valueHashCode); if (style == null) return false; m_styleStack.Add(style.hashCode); //// Parse Style Macro for (int i = 0; i < style.styleOpeningTagArray.Length; i++) { if (style.styleOpeningTagArray[i] == 60) ValidateHtmlTag(style.styleOpeningTagArray, i + 1, out i); } return true; case 1112618: // </style> style = TMP_StyleSheet.Instance.GetStyle(m_xmlAttribute[0].valueHashCode); if (style == null) { // Get style from the Style Stack int styleHashCode = m_styleStack.Remove(); style = TMP_StyleSheet.Instance.GetStyle(styleHashCode); } if (style == null) return false; //// Parse Style Macro for (int i = 0; i < style.styleClosingTagArray.Length; i++) { if (style.styleClosingTagArray[i] == 60) ValidateHtmlTag(style.styleClosingTagArray, i + 1, out i); } return true; case 281955: // <color=#FF00FF> or <color=#FF00FF00> // <color=#FF00FF> 3 Hex pairs if (m_htmlTag[6] == 35 && tagCharCount == 13) { m_htmlColor = HexCharsToColor(m_htmlTag, tagCharCount); m_colorStack.Add(m_htmlColor); return true; } // <color=#FF00FF00> 4 Hex pairs else if (m_htmlTag[6] == 35 && tagCharCount == 15) { m_htmlColor = HexCharsToColor(m_htmlTag, tagCharCount); m_colorStack.Add(m_htmlColor); return true; } // <color=name> switch (m_xmlAttribute[0].valueHashCode) { case 125395: // <color=red> m_htmlColor = Color.red; m_colorStack.Add(m_htmlColor); return true; case 3573310: // <color=blue> m_htmlColor = Color.blue; m_colorStack.Add(m_htmlColor); return true; case 117905991: // <color=black> m_htmlColor = Color.black; m_colorStack.Add(m_htmlColor); return true; case 121463835: // <color=green> m_htmlColor = Color.green; m_colorStack.Add(m_htmlColor); return true; case 140357351: // <color=white> m_htmlColor = Color.white; m_colorStack.Add(m_htmlColor); return true; case 26556144: // <color=orange> m_htmlColor = new Color32(255, 128, 0, 255); m_colorStack.Add(m_htmlColor); return true; case -36881330: // <color=purple> m_htmlColor = new Color32(160, 32, 240, 255); m_colorStack.Add(m_htmlColor); return true; case 554054276: // <color=yellow> m_htmlColor = Color.yellow; m_colorStack.Add(m_htmlColor); return true; } return false; case 1983971: // <cspace=xx.x> value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength, m_xmlAttribute[0].valueDecimalIndex); if (value == -9999 || value == 0) return false; switch (tagUnits) { case TagUnits.Pixels: m_cSpacing = value; break; case TagUnits.FontUnits: m_cSpacing = value; m_cSpacing *= m_fontScale * m_fontAsset.fontInfo.TabWidth / m_fontAsset.tabSize; break; case TagUnits.Percentage: return false; } return true; case 7513474: // </cspace> m_cSpacing = 0; return true; case 2152041: // <mspace=xx.x> value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength, m_xmlAttribute[0].valueDecimalIndex); if (value == -9999 || value == 0) return false; switch (tagUnits) { case TagUnits.Pixels: m_monoSpacing = value; break; case TagUnits.FontUnits: m_monoSpacing = value; m_monoSpacing *= m_fontScale * m_fontAsset.fontInfo.TabWidth / m_fontAsset.tabSize; break; case TagUnits.Percentage: return false; } return true; case 7681544: // </mspace> m_monoSpacing = 0; return true; case 280416: // <class="name"> return false; case 1071884: // </color> m_htmlColor = m_colorStack.Remove(); return true; case 2068980: // <indent=10px> <indent=10em> <indent=50%> value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength, m_xmlAttribute[0].valueDecimalIndex); if (value == -9999 || value == 0) return false; switch (tagUnits) { case TagUnits.Pixels: tag_Indent = value; break; case TagUnits.FontUnits: tag_Indent = value; tag_Indent *= m_fontScale * m_fontAsset.fontInfo.TabWidth / m_fontAsset.tabSize; break; case TagUnits.Percentage: tag_Indent = m_marginWidth * value / 100; break; } m_indentStack.Add(tag_Indent); m_xAdvance = tag_Indent; return true; case 7598483: // </indent> tag_Indent = m_indentStack.Remove(); //m_xAdvance = tag_Indent; return true; case 1109386397: // <line-indent> value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength, m_xmlAttribute[0].valueDecimalIndex); if (value == -9999 || value == 0) return false; switch (tagUnits) { case TagUnits.Pixels: tag_LineIndent = value; break; case TagUnits.FontUnits: tag_LineIndent = value; tag_LineIndent *= m_fontScale * m_fontAsset.fontInfo.TabWidth / m_fontAsset.tabSize; break; case TagUnits.Percentage: tag_LineIndent = m_marginWidth * value / 100; break; } m_xAdvance += tag_LineIndent; return true; case -445537194: // </line-indent> tag_LineIndent = 0; return true; case 2246877: // <sprite=x> int spriteAssetHashCode = m_xmlAttribute[0].valueHashCode; TMP_SpriteAsset tempSpriteAsset; // CHECK TAG FORMAT if (m_xmlAttribute[0].valueType == TagType.None || m_xmlAttribute[0].valueType == TagType.NumericalValue) { // No Sprite Asset specified if (m_defaultSpriteAsset == null) { // Load TMP Settings if (m_settings == null) m_settings = TMP_Settings.LoadDefaultSettings(); if (m_settings != null && m_settings.spriteAsset != null) m_defaultSpriteAsset = m_settings.spriteAsset; else m_defaultSpriteAsset = Resources.Load<TMP_SpriteAsset>("Sprite Assets/Default Sprite Asset"); } m_currentSpriteAsset = m_defaultSpriteAsset; // No valid sprite asset available if (m_currentSpriteAsset == null) return false; } else { // A Sprite Asset has been specified if (MaterialReferenceManager.TryGetSpriteAsset(spriteAssetHashCode, out tempSpriteAsset)) { m_currentSpriteAsset = tempSpriteAsset; } else { // Load Sprite Asset if (tempSpriteAsset == null) { tempSpriteAsset = Resources.Load<TMP_SpriteAsset>("Sprites/" + new string(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength)); } if (tempSpriteAsset == null) return false; //Debug.Log("Loading & assigning new Sprite Asset: " + tempSpriteAsset.name); MaterialReferenceManager.AddSpriteAsset(spriteAssetHashCode, tempSpriteAsset); m_currentSpriteAsset = tempSpriteAsset; } } if (m_xmlAttribute[0].valueType == TagType.NumericalValue) { int index = (int)ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength, m_xmlAttribute[0].valueDecimalIndex); if (index == -9999) return false; m_spriteIndex = index; } else if (m_xmlAttribute[1].nameHashCode == 43347) // <sprite name=""> { //Debug.Log("Name attribute [" + new string(m_htmlTag, m_xmlAttribute[1].valueStartIndex, m_xmlAttribute[1].valueLength) + "]."); int index = m_currentSpriteAsset.GetSpriteIndex(m_xmlAttribute[1].valueHashCode); if (index == -1) return false; m_spriteIndex = index; } else if (m_xmlAttribute[1].nameHashCode == 295562) // <sprite index=xx> { int index = (int)ConvertToFloat(m_htmlTag, m_xmlAttribute[1].valueStartIndex, m_xmlAttribute[1].valueLength, m_xmlAttribute[1].valueDecimalIndex); if (index == -9999) return false; m_spriteIndex = index; // Check to make sure sprite index is valid if (m_spriteIndex > m_currentSpriteAsset.spriteInfoList.Count - 1) return false; } else { return false; } // Material HashCode for the Sprite Asset is the Sprite Asset Hash Code m_currentMaterialIndex = MaterialReference.AddMaterialReference(m_currentSpriteAsset.material, m_currentSpriteAsset, m_materialReferences, m_materialReferenceIndexLookup); //m_materialReferenceStack.Add(m_materialReferenceManager.materialReferences[m_currentMaterialIndex]); m_spriteColor = s_colorWhite; m_tintSprite = false; // Handle Tint Attribute if (m_xmlAttribute[1].nameHashCode == 45819) m_tintSprite = ConvertToFloat(m_htmlTag, m_xmlAttribute[1].valueStartIndex, m_xmlAttribute[1].valueLength, m_xmlAttribute[1].valueDecimalIndex) != 0; else if (m_xmlAttribute[2].nameHashCode == 45819) m_tintSprite = ConvertToFloat(m_htmlTag, m_xmlAttribute[2].valueStartIndex, m_xmlAttribute[2].valueLength, m_xmlAttribute[2].valueDecimalIndex) != 0; // Handle Color Attribute if (m_xmlAttribute[1].nameHashCode == 281955) m_spriteColor = HexCharsToColor(m_htmlTag, m_xmlAttribute[1].valueStartIndex, m_xmlAttribute[1].valueLength); else if (m_xmlAttribute[2].nameHashCode == 281955) m_spriteColor = HexCharsToColor(m_htmlTag, m_xmlAttribute[2].valueStartIndex, m_xmlAttribute[2].valueLength); m_xmlAttribute[1].nameHashCode = 0; m_xmlAttribute[2].nameHashCode = 0; m_textElementType = TMP_TextElementType.Sprite; return true; case 730022849: // <lowercase> m_style |= FontStyles.LowerCase; return true; case -1668324918: // </lowercase> m_style &= ~FontStyles.LowerCase; return true; case 13526026: // <allcaps> case 781906058: // <uppercase> m_style |= FontStyles.UpperCase; return true; case 52232547: // </allcaps> case -1616441709: // </uppercase> m_style &= ~FontStyles.UpperCase; return true; case 766244328: // <smallcaps> m_style |= FontStyles.SmallCaps; return true; case -1632103439: // </smallcaps> m_style &= ~FontStyles.SmallCaps; return true; case 2109854: // <margin=00.0> <margin=00em> <margin=50%> value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength, m_xmlAttribute[0].valueDecimalIndex); // px if (value == -9999 || value == 0) return false; m_marginLeft = value; switch (tagUnits) { case TagUnits.Pixels: // Default behavior break; case TagUnits.FontUnits: m_marginLeft *= m_fontScale * m_fontAsset.fontInfo.TabWidth / m_fontAsset.tabSize; break; case TagUnits.Percentage: m_marginLeft = (m_marginWidth - (m_width != -1 ? m_width : 0)) * m_marginLeft / 100; break; } m_marginLeft = m_marginLeft >= 0 ? m_marginLeft : 0; m_marginRight = m_marginLeft; return true; case 7639357: // </margin> m_marginLeft = 0; m_marginRight = 0; return true; case 1100728678: // <margin-left=xx.x> value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength, m_xmlAttribute[0].valueDecimalIndex); // px if (value == -9999 || value == 0) return false; m_marginLeft = value; switch (tagUnits) { case TagUnits.Pixels: // Default behavior break; case TagUnits.FontUnits: m_marginLeft *= m_fontScale * m_fontAsset.fontInfo.TabWidth / m_fontAsset.tabSize; break; case TagUnits.Percentage: m_marginLeft = (m_marginWidth - (m_width != -1 ? m_width : 0)) * m_marginLeft / 100; break; } m_marginLeft = m_marginLeft >= 0 ? m_marginLeft : 0; return true; case -884817987: // <margin-right=xx.x> value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength, m_xmlAttribute[0].valueDecimalIndex); // px if (value == -9999 || value == 0) return false; m_marginRight = value; switch (tagUnits) { case TagUnits.Pixels: // Default behavior break; case TagUnits.FontUnits: m_marginRight *= m_fontScale * m_fontAsset.fontInfo.TabWidth / m_fontAsset.tabSize; break; case TagUnits.Percentage: m_marginRight = (m_marginWidth - (m_width != -1 ? m_width : 0)) * m_marginRight / 100; break; } m_marginRight = m_marginRight >= 0 ? m_marginRight : 0; return true; case 1109349752: // <line-height=xx.x> value = ConvertToFloat(m_htmlTag, m_xmlAttribute[0].valueStartIndex, m_xmlAttribute[0].valueLength, m_xmlAttribute[0].valueDecimalIndex); if (value == -9999 || value == 0) return false; m_lineHeight = value; switch (tagUnits) { case TagUnits.Pixels: //m_lineHeight *= m_isOrthographic ? 1 : 0.1f; break; case TagUnits.FontUnits: m_lineHeight *= m_fontAsset.fontInfo.LineHeight * m_fontScale; break; case TagUnits.Percentage: m_lineHeight = m_fontAsset.fontInfo.LineHeight * m_lineHeight / 100 * m_fontScale; break; } return true; case -445573839: // </line-height> m_lineHeight = 0; return true; case 15115642: // <noparse> tag_NoParsing = true; return true; case 1913798: // <action> // TODO return false; case 7443301: // </action> // TODO return false; } } return false; }