summaryrefslogtreecommitdiff
path: root/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/ClipperRegistry.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/ClipperRegistry.cs')
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/ClipperRegistry.cs50
1 files changed, 50 insertions, 0 deletions
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/ClipperRegistry.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/ClipperRegistry.cs
new file mode 100644
index 0000000..ea7f527
--- /dev/null
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Culling/ClipperRegistry.cs
@@ -0,0 +1,50 @@
+using System.Collections.Generic;
+using UnityEngine.UI.Collections;
+
+namespace UnityEngine.UI
+{
+ public class ClipperRegistry
+ {
+ static ClipperRegistry s_Instance;
+
+ readonly IndexedSet<IClipper> m_Clippers = new IndexedSet<IClipper>();
+
+ protected ClipperRegistry()
+ {
+ // This is needed for AOT platforms. Without it the compile doesn't get the definition of the Dictionarys
+#pragma warning disable 168
+ Dictionary<IClipper, int> emptyIClipperDic;
+#pragma warning restore 168
+ }
+
+ public static ClipperRegistry instance
+ {
+ get
+ {
+ if (s_Instance == null)
+ s_Instance = new ClipperRegistry();
+ return s_Instance;
+ }
+ }
+
+ public void Cull()
+ {
+ for (var i = 0; i < m_Clippers.Count; ++i)
+ {
+ m_Clippers[i].PerformClipping();
+ }
+ }
+
+ public static void Register(IClipper c)
+ {
+ if (c == null)
+ return;
+ instance.m_Clippers.AddUnique(c);
+ }
+
+ public static void Unregister(IClipper c)
+ {
+ instance.m_Clippers.Remove(c);
+ }
+ }
+}