Hue Preserving Color Blending
TMP_Style.cs
1 using UnityEngine;
2 using System.Collections;
3 
4 #pragma warning disable 0649 // Disabled warnings.
5 
6 namespace TMPro
7 {
8 
9  [System.Serializable]
10  public class TMP_Style
11  {
12  // PUBLIC PROPERTIES
13 
17  public string name
18  { get { return m_Name; } set { if (value != m_Name) m_Name = value; } }
19 
23  public int hashCode
24  { get { return m_HashCode; } set { if (value != m_HashCode) m_HashCode = value; } }
25 
29  public string styleOpeningDefinition
30  { get { return m_OpeningDefinition; } }
31 
35  public string styleClosingDefinition
36  { get { return m_ClosingDefinition; } }
37 
38 
39  public int[] styleOpeningTagArray
40  { get { return m_OpeningTagArray; } }
41 
42 
43  public int[] styleClosingTagArray
44  { get { return m_ClosingTagArray; } }
45 
46 
47  // PRIVATE FIELDS
48  [SerializeField]
49  private string m_Name;
50 
51  [SerializeField]
52  private int m_HashCode;
53 
54  [SerializeField]
55  private string m_OpeningDefinition;
56 
57  [SerializeField]
58  private string m_ClosingDefinition;
59 
60  [SerializeField]
61  private int[] m_OpeningTagArray;
62 
63  [SerializeField]
64  private int[] m_ClosingTagArray;
65 
66 
67  //public TMP_Style()
68  //{
69  //Debug.Log("New Style with Name: " + m_Name + " was created. ID: ");
70  //}
71 
72 
76  public void RefreshStyle()
77  {
78  m_HashCode = TMP_TextUtilities.GetSimpleHashCode(m_Name);
79 
80  m_OpeningTagArray = new int[m_OpeningDefinition.Length];
81  for (int i = 0; i < m_OpeningDefinition.Length; i++)
82  m_OpeningTagArray[i] = m_OpeningDefinition[i];
83 
84  m_ClosingTagArray = new int[m_ClosingDefinition.Length];
85  for (int i = 0; i < m_ClosingDefinition.Length; i++)
86  m_ClosingTagArray[i] = m_ClosingDefinition[i];
87 
88 #if UNITY_EDITOR
89  // Event to update objects when styles are changed in the editor.
90  TMPro_EventManager.ON_TEXT_STYLE_PROPERTY_CHANGED(true);
91 #endif
92  }
93 
94  }
95 }
int hashCode
The hash code corresponding to the name of this style.
Definition: TMP_Style.cs:24
string name
The name identifying this style. ex. <style="name">.
Definition: TMP_Style.cs:18
string styleClosingDefinition
The closing definition of the style. ex. .
Definition: TMP_Style.cs:36
void RefreshStyle()
Function to update the content of the int[] resulting from changes to OpeningDefinition & ClosingDefi...
Definition: TMP_Style.cs:76
string styleOpeningDefinition
The initial definition of the style. ex. .
Definition: TMP_Style.cs:30