scripts
This commit is contained in:
@@ -0,0 +1,273 @@
|
||||
using System;
|
||||
using UnityEngine.UI.Collections;
|
||||
|
||||
namespace UnityEngine.UI
|
||||
{
|
||||
// Token: 0x0200003E RID: 62
|
||||
public class CanvasUpdateRegistry
|
||||
{
|
||||
// Token: 0x0600018E RID: 398 RVA: 0x00007D71 File Offset: 0x00006171
|
||||
protected CanvasUpdateRegistry()
|
||||
{
|
||||
Canvas.willRenderCanvases += this.PerformUpdate;
|
||||
}
|
||||
|
||||
// Token: 0x1700006A RID: 106
|
||||
// (get) Token: 0x0600018F RID: 399 RVA: 0x00007DA4 File Offset: 0x000061A4
|
||||
public static CanvasUpdateRegistry instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CanvasUpdateRegistry.s_Instance == null)
|
||||
{
|
||||
CanvasUpdateRegistry.s_Instance = new CanvasUpdateRegistry();
|
||||
}
|
||||
return CanvasUpdateRegistry.s_Instance;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000190 RID: 400 RVA: 0x00007DD4 File Offset: 0x000061D4
|
||||
private bool ObjectValidForUpdate(ICanvasElement element)
|
||||
{
|
||||
bool flag = element != null;
|
||||
bool flag2 = element is Object;
|
||||
if (flag2)
|
||||
{
|
||||
flag = element as Object != null;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x06000191 RID: 401 RVA: 0x00007E10 File Offset: 0x00006210
|
||||
private void CleanInvalidItems()
|
||||
{
|
||||
for (int i = this.m_LayoutRebuildQueue.Count - 1; i >= 0; i--)
|
||||
{
|
||||
ICanvasElement canvasElement = this.m_LayoutRebuildQueue[i];
|
||||
if (canvasElement == null)
|
||||
{
|
||||
this.m_LayoutRebuildQueue.RemoveAt(i);
|
||||
}
|
||||
else if (canvasElement.IsDestroyed())
|
||||
{
|
||||
this.m_LayoutRebuildQueue.RemoveAt(i);
|
||||
canvasElement.LayoutComplete();
|
||||
}
|
||||
}
|
||||
for (int j = this.m_GraphicRebuildQueue.Count - 1; j >= 0; j--)
|
||||
{
|
||||
ICanvasElement canvasElement2 = this.m_GraphicRebuildQueue[j];
|
||||
if (canvasElement2 == null)
|
||||
{
|
||||
this.m_GraphicRebuildQueue.RemoveAt(j);
|
||||
}
|
||||
else if (canvasElement2.IsDestroyed())
|
||||
{
|
||||
this.m_GraphicRebuildQueue.RemoveAt(j);
|
||||
canvasElement2.GraphicUpdateComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000192 RID: 402 RVA: 0x00007EE8 File Offset: 0x000062E8
|
||||
private void PerformUpdate()
|
||||
{
|
||||
UISystemProfilerApi.BeginSample(UISystemProfilerApi.SampleType.Layout);
|
||||
this.CleanInvalidItems();
|
||||
this.m_PerformingLayoutUpdate = true;
|
||||
this.m_LayoutRebuildQueue.Sort(CanvasUpdateRegistry.s_SortLayoutFunction);
|
||||
for (int i = 0; i <= 2; i++)
|
||||
{
|
||||
for (int j = 0; j < this.m_LayoutRebuildQueue.Count; j++)
|
||||
{
|
||||
ICanvasElement canvasElement = CanvasUpdateRegistry.instance.m_LayoutRebuildQueue[j];
|
||||
try
|
||||
{
|
||||
if (this.ObjectValidForUpdate(canvasElement))
|
||||
{
|
||||
canvasElement.Rebuild((CanvasUpdate)i);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogException(ex, canvasElement.transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int k = 0; k < this.m_LayoutRebuildQueue.Count; k++)
|
||||
{
|
||||
this.m_LayoutRebuildQueue[k].LayoutComplete();
|
||||
}
|
||||
CanvasUpdateRegistry.instance.m_LayoutRebuildQueue.Clear();
|
||||
this.m_PerformingLayoutUpdate = false;
|
||||
ClipperRegistry.instance.Cull();
|
||||
this.m_PerformingGraphicUpdate = true;
|
||||
for (int l = 3; l < 5; l++)
|
||||
{
|
||||
for (int m = 0; m < CanvasUpdateRegistry.instance.m_GraphicRebuildQueue.Count; m++)
|
||||
{
|
||||
try
|
||||
{
|
||||
ICanvasElement canvasElement2 = CanvasUpdateRegistry.instance.m_GraphicRebuildQueue[m];
|
||||
if (this.ObjectValidForUpdate(canvasElement2))
|
||||
{
|
||||
canvasElement2.Rebuild((CanvasUpdate)l);
|
||||
}
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
Debug.LogException(ex2, CanvasUpdateRegistry.instance.m_GraphicRebuildQueue[m].transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int n = 0; n < this.m_GraphicRebuildQueue.Count; n++)
|
||||
{
|
||||
this.m_GraphicRebuildQueue[n].GraphicUpdateComplete();
|
||||
}
|
||||
CanvasUpdateRegistry.instance.m_GraphicRebuildQueue.Clear();
|
||||
this.m_PerformingGraphicUpdate = false;
|
||||
UISystemProfilerApi.EndSample(UISystemProfilerApi.SampleType.Layout);
|
||||
}
|
||||
|
||||
// Token: 0x06000193 RID: 403 RVA: 0x000080E4 File Offset: 0x000064E4
|
||||
private static int ParentCount(Transform child)
|
||||
{
|
||||
int num;
|
||||
if (child == null)
|
||||
{
|
||||
num = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Transform transform = child.parent;
|
||||
int num2 = 0;
|
||||
while (transform != null)
|
||||
{
|
||||
num2++;
|
||||
transform = transform.parent;
|
||||
}
|
||||
num = num2;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000194 RID: 404 RVA: 0x00008134 File Offset: 0x00006534
|
||||
private static int SortLayoutList(ICanvasElement x, ICanvasElement y)
|
||||
{
|
||||
Transform transform = x.transform;
|
||||
Transform transform2 = y.transform;
|
||||
return CanvasUpdateRegistry.ParentCount(transform) - CanvasUpdateRegistry.ParentCount(transform2);
|
||||
}
|
||||
|
||||
// Token: 0x06000195 RID: 405 RVA: 0x00008164 File Offset: 0x00006564
|
||||
public static void RegisterCanvasElementForLayoutRebuild(ICanvasElement element)
|
||||
{
|
||||
CanvasUpdateRegistry.instance.InternalRegisterCanvasElementForLayoutRebuild(element);
|
||||
}
|
||||
|
||||
// Token: 0x06000196 RID: 406 RVA: 0x00008174 File Offset: 0x00006574
|
||||
public static bool TryRegisterCanvasElementForLayoutRebuild(ICanvasElement element)
|
||||
{
|
||||
return CanvasUpdateRegistry.instance.InternalRegisterCanvasElementForLayoutRebuild(element);
|
||||
}
|
||||
|
||||
// Token: 0x06000197 RID: 407 RVA: 0x00008194 File Offset: 0x00006594
|
||||
private bool InternalRegisterCanvasElementForLayoutRebuild(ICanvasElement element)
|
||||
{
|
||||
return !this.m_LayoutRebuildQueue.Contains(element) && this.m_LayoutRebuildQueue.AddUnique(element);
|
||||
}
|
||||
|
||||
// Token: 0x06000198 RID: 408 RVA: 0x000081CD File Offset: 0x000065CD
|
||||
public static void RegisterCanvasElementForGraphicRebuild(ICanvasElement element)
|
||||
{
|
||||
CanvasUpdateRegistry.instance.InternalRegisterCanvasElementForGraphicRebuild(element);
|
||||
}
|
||||
|
||||
// Token: 0x06000199 RID: 409 RVA: 0x000081DC File Offset: 0x000065DC
|
||||
public static bool TryRegisterCanvasElementForGraphicRebuild(ICanvasElement element)
|
||||
{
|
||||
return CanvasUpdateRegistry.instance.InternalRegisterCanvasElementForGraphicRebuild(element);
|
||||
}
|
||||
|
||||
// Token: 0x0600019A RID: 410 RVA: 0x000081FC File Offset: 0x000065FC
|
||||
private bool InternalRegisterCanvasElementForGraphicRebuild(ICanvasElement element)
|
||||
{
|
||||
bool flag;
|
||||
if (this.m_PerformingGraphicUpdate)
|
||||
{
|
||||
Debug.LogError(string.Format("Trying to add {0} for graphic rebuild while we are already inside a graphic rebuild loop. This is not supported.", element));
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = this.m_GraphicRebuildQueue.AddUnique(element);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x0600019B RID: 411 RVA: 0x00008240 File Offset: 0x00006640
|
||||
public static void UnRegisterCanvasElementForRebuild(ICanvasElement element)
|
||||
{
|
||||
CanvasUpdateRegistry.instance.InternalUnRegisterCanvasElementForLayoutRebuild(element);
|
||||
CanvasUpdateRegistry.instance.InternalUnRegisterCanvasElementForGraphicRebuild(element);
|
||||
}
|
||||
|
||||
// Token: 0x0600019C RID: 412 RVA: 0x00008259 File Offset: 0x00006659
|
||||
private void InternalUnRegisterCanvasElementForLayoutRebuild(ICanvasElement element)
|
||||
{
|
||||
if (this.m_PerformingLayoutUpdate)
|
||||
{
|
||||
Debug.LogError(string.Format("Trying to remove {0} from rebuild list while we are already inside a rebuild loop. This is not supported.", element));
|
||||
}
|
||||
else
|
||||
{
|
||||
element.LayoutComplete();
|
||||
CanvasUpdateRegistry.instance.m_LayoutRebuildQueue.Remove(element);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600019D RID: 413 RVA: 0x00008294 File Offset: 0x00006694
|
||||
private void InternalUnRegisterCanvasElementForGraphicRebuild(ICanvasElement element)
|
||||
{
|
||||
if (this.m_PerformingGraphicUpdate)
|
||||
{
|
||||
Debug.LogError(string.Format("Trying to remove {0} from rebuild list while we are already inside a rebuild loop. This is not supported.", element));
|
||||
}
|
||||
else
|
||||
{
|
||||
element.GraphicUpdateComplete();
|
||||
CanvasUpdateRegistry.instance.m_GraphicRebuildQueue.Remove(element);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600019E RID: 414 RVA: 0x000082D0 File Offset: 0x000066D0
|
||||
public static bool IsRebuildingLayout()
|
||||
{
|
||||
return CanvasUpdateRegistry.instance.m_PerformingLayoutUpdate;
|
||||
}
|
||||
|
||||
// Token: 0x0600019F RID: 415 RVA: 0x000082F0 File Offset: 0x000066F0
|
||||
public static bool IsRebuildingGraphics()
|
||||
{
|
||||
return CanvasUpdateRegistry.instance.m_PerformingGraphicUpdate;
|
||||
}
|
||||
|
||||
// Token: 0x040000C6 RID: 198
|
||||
private static CanvasUpdateRegistry s_Instance;
|
||||
|
||||
// Token: 0x040000C7 RID: 199
|
||||
private bool m_PerformingLayoutUpdate;
|
||||
|
||||
// Token: 0x040000C8 RID: 200
|
||||
private bool m_PerformingGraphicUpdate;
|
||||
|
||||
// Token: 0x040000C9 RID: 201
|
||||
private readonly IndexedSet<ICanvasElement> m_LayoutRebuildQueue = new IndexedSet<ICanvasElement>();
|
||||
|
||||
// Token: 0x040000CA RID: 202
|
||||
private readonly IndexedSet<ICanvasElement> m_GraphicRebuildQueue = new IndexedSet<ICanvasElement>();
|
||||
|
||||
// Token: 0x040000CB RID: 203
|
||||
private static readonly Comparison<ICanvasElement> s_SortLayoutFunction = new Comparison<ICanvasElement>(CanvasUpdateRegistry.SortLayoutList);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user