TMP_Style.cs
3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
using UnityEngine;
using System.Collections;
#pragma warning disable 0649 // Disabled warnings.
namespace TMPro
{
[System.Serializable]
public class TMP_Style
{
public static TMP_Style NormalStyle
{
get
{
if (k_NormalStyle == null)
k_NormalStyle = new TMP_Style("Normal", string.Empty, string.Empty);
return k_NormalStyle;
}
}
internal static TMP_Style k_NormalStyle;
// PUBLIC PROPERTIES
/// <summary>
/// The name identifying this style. ex. <style="name">.
/// </summary>
public string name
{ get { return m_Name; } set { if (value != m_Name) m_Name = value; } }
/// <summary>
/// The hash code corresponding to the name of this style.
/// </summary>
public int hashCode
{ get { return m_HashCode; } set { if (value != m_HashCode) m_HashCode = value; } }
/// <summary>
/// The initial definition of the style. ex. <b> <u>.
/// </summary>
public string styleOpeningDefinition
{ get { return m_OpeningDefinition; } }
/// <summary>
/// The closing definition of the style. ex. </b> </u>.
/// </summary>
public string styleClosingDefinition
{ get { return m_ClosingDefinition; } }
public int[] styleOpeningTagArray
{ get { return m_OpeningTagArray; } }
public int[] styleClosingTagArray
{ get { return m_ClosingTagArray; } }
// PRIVATE FIELDS
[SerializeField]
private string m_Name;
[SerializeField]
private int m_HashCode;
[SerializeField]
private string m_OpeningDefinition;
[SerializeField]
private string m_ClosingDefinition;
[SerializeField]
private int[] m_OpeningTagArray;
[SerializeField]
private int[] m_ClosingTagArray;
/// <summary>
/// Constructor
/// </summary>
/// <param name="styleName">Name of the style.</param>
/// <param name="styleOpeningDefinition">Style opening definition.</param>
/// <param name="styleClosingDefinition">Style closing definition.</param>
internal TMP_Style(string styleName, string styleOpeningDefinition, string styleClosingDefinition)
{
m_Name = styleName;
m_HashCode = TMP_TextParsingUtilities.GetHashCode(styleName);
m_OpeningDefinition = styleOpeningDefinition;
m_ClosingDefinition = styleClosingDefinition;
RefreshStyle();
}
/// <summary>
/// Function to update the content of the int[] resulting from changes to OpeningDefinition & ClosingDefinition.
/// </summary>
public void RefreshStyle()
{
m_HashCode = TMP_TextParsingUtilities.GetHashCode(m_Name);
m_OpeningTagArray = new int[m_OpeningDefinition.Length];
for (int i = 0; i < m_OpeningDefinition.Length; i++)
m_OpeningTagArray[i] = m_OpeningDefinition[i];
m_ClosingTagArray = new int[m_ClosingDefinition.Length];
for (int i = 0; i < m_ClosingDefinition.Length; i++)
m_ClosingTagArray[i] = m_ClosingDefinition[i];
}
}
}