forked from hunterzonewu/unity-decompiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFontUpdateTracker.cs
More file actions
72 lines (67 loc) · 2.42 KB
/
FontUpdateTracker.cs
File metadata and controls
72 lines (67 loc) · 2.42 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
// Decompiled with JetBrains decompiler
// Type: UnityEngine.UI.FontUpdateTracker
// Assembly: UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 2216A18B-AF52-44A5-85A0-A1CAA19C1090
// Assembly location: C:\Users\Blake\sandbox\unity\test-project\Library\UnityAssemblies\UnityEngine.UI.dll
using System;
using System.Collections.Generic;
namespace UnityEngine.UI
{
/// <summary>
/// <para>Utility class that is used to help with Text update.</para>
/// </summary>
public static class FontUpdateTracker
{
private static Dictionary<Font, List<Text>> m_Tracked = new Dictionary<Font, List<Text>>();
/// <summary>
/// <para>Register a Text element for receiving texture atlas rebuild calls.</para>
/// </summary>
/// <param name="t"></param>
public static void TrackText(Text t)
{
if ((UnityEngine.Object) t.font == (UnityEngine.Object) null)
return;
List<Text> textList;
FontUpdateTracker.m_Tracked.TryGetValue(t.font, out textList);
if (textList == null)
{
if (FontUpdateTracker.m_Tracked.Count == 0)
Font.textureRebuilt += new Action<Font>(FontUpdateTracker.RebuildForFont);
textList = new List<Text>();
FontUpdateTracker.m_Tracked.Add(t.font, textList);
}
if (textList.Contains(t))
return;
textList.Add(t);
}
private static void RebuildForFont(Font f)
{
List<Text> textList;
FontUpdateTracker.m_Tracked.TryGetValue(f, out textList);
if (textList == null)
return;
for (int index = 0; index < textList.Count; ++index)
textList[index].FontTextureChanged();
}
/// <summary>
/// <para>Deregister a Text element from receiving texture atlas rebuild calls.</para>
/// </summary>
/// <param name="t"></param>
public static void UntrackText(Text t)
{
if ((UnityEngine.Object) t.font == (UnityEngine.Object) null)
return;
List<Text> textList;
FontUpdateTracker.m_Tracked.TryGetValue(t.font, out textList);
if (textList == null)
return;
textList.Remove(t);
if (textList.Count != 0)
return;
FontUpdateTracker.m_Tracked.Remove(t.font);
if (FontUpdateTracker.m_Tracked.Count != 0)
return;
Font.textureRebuilt -= new Action<Font>(FontUpdateTracker.RebuildForFont);
}
}
}