scripts
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
using System;
|
||||
|
||||
namespace UnityEngine
|
||||
{
|
||||
// Token: 0x0200026D RID: 621
|
||||
internal sealed class GUIGridSizer : GUILayoutEntry
|
||||
{
|
||||
// Token: 0x06002A64 RID: 10852 RVA: 0x00036A18 File Offset: 0x00034C18
|
||||
private GUIGridSizer(GUIContent[] contents, int xCount, GUIStyle buttonStyle, GUILayoutOption[] options)
|
||||
: base(0f, 0f, 0f, 0f, GUIStyle.none)
|
||||
{
|
||||
this.m_Count = contents.Length;
|
||||
this.m_XCount = xCount;
|
||||
this.ApplyStyleSettings(buttonStyle);
|
||||
this.ApplyOptions(options);
|
||||
if (xCount != 0 && contents.Length != 0)
|
||||
{
|
||||
float num = (float)(Mathf.Max(buttonStyle.margin.left, buttonStyle.margin.right) * (this.m_XCount - 1));
|
||||
float num2 = (float)(Mathf.Max(buttonStyle.margin.top, buttonStyle.margin.bottom) * (this.rows - 1));
|
||||
if (buttonStyle.fixedWidth != 0f)
|
||||
{
|
||||
this.m_MinButtonWidth = (this.m_MaxButtonWidth = buttonStyle.fixedWidth);
|
||||
}
|
||||
if (buttonStyle.fixedHeight != 0f)
|
||||
{
|
||||
this.m_MinButtonHeight = (this.m_MaxButtonHeight = buttonStyle.fixedHeight);
|
||||
}
|
||||
if (this.m_MinButtonWidth == -1f)
|
||||
{
|
||||
if (this.minWidth != 0f)
|
||||
{
|
||||
this.m_MinButtonWidth = (this.minWidth - num) / (float)this.m_XCount;
|
||||
}
|
||||
if (this.maxWidth != 0f)
|
||||
{
|
||||
this.m_MaxButtonWidth = (this.maxWidth - num) / (float)this.m_XCount;
|
||||
}
|
||||
}
|
||||
if (this.m_MinButtonHeight == -1f)
|
||||
{
|
||||
if (this.minHeight != 0f)
|
||||
{
|
||||
this.m_MinButtonHeight = (this.minHeight - num2) / (float)this.rows;
|
||||
}
|
||||
if (this.maxHeight != 0f)
|
||||
{
|
||||
this.m_MaxButtonHeight = (this.maxHeight - num2) / (float)this.rows;
|
||||
}
|
||||
}
|
||||
if (this.m_MinButtonHeight == -1f || this.m_MaxButtonHeight == -1f || this.m_MinButtonWidth == -1f || this.m_MaxButtonWidth == -1f)
|
||||
{
|
||||
float num3 = 0f;
|
||||
float num4 = 0f;
|
||||
foreach (GUIContent guicontent in contents)
|
||||
{
|
||||
Vector2 vector = buttonStyle.CalcSize(guicontent);
|
||||
num4 = Mathf.Max(num4, vector.x);
|
||||
num3 = Mathf.Max(num3, vector.y);
|
||||
}
|
||||
if (this.m_MinButtonWidth == -1f)
|
||||
{
|
||||
if (this.m_MaxButtonWidth != -1f)
|
||||
{
|
||||
this.m_MinButtonWidth = Mathf.Min(num4, this.m_MaxButtonWidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_MinButtonWidth = num4;
|
||||
}
|
||||
}
|
||||
if (this.m_MaxButtonWidth == -1f)
|
||||
{
|
||||
if (this.m_MinButtonWidth != -1f)
|
||||
{
|
||||
this.m_MaxButtonWidth = Mathf.Max(num4, this.m_MinButtonWidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_MaxButtonWidth = num4;
|
||||
}
|
||||
}
|
||||
if (this.m_MinButtonHeight == -1f)
|
||||
{
|
||||
if (this.m_MaxButtonHeight != -1f)
|
||||
{
|
||||
this.m_MinButtonHeight = Mathf.Min(num3, this.m_MaxButtonHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_MinButtonHeight = num3;
|
||||
}
|
||||
}
|
||||
if (this.m_MaxButtonHeight == -1f)
|
||||
{
|
||||
if (this.m_MinButtonHeight != -1f)
|
||||
{
|
||||
this.maxHeight = Mathf.Max(this.maxHeight, this.m_MinButtonHeight);
|
||||
}
|
||||
this.m_MaxButtonHeight = this.maxHeight;
|
||||
}
|
||||
}
|
||||
this.minWidth = this.m_MinButtonWidth * (float)this.m_XCount + num;
|
||||
this.maxWidth = this.m_MaxButtonWidth * (float)this.m_XCount + num;
|
||||
this.minHeight = this.m_MinButtonHeight * (float)this.rows + num2;
|
||||
this.maxHeight = this.m_MaxButtonHeight * (float)this.rows + num2;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06002A65 RID: 10853 RVA: 0x00036DF4 File Offset: 0x00034FF4
|
||||
public static Rect GetRect(GUIContent[] contents, int xCount, GUIStyle style, GUILayoutOption[] options)
|
||||
{
|
||||
Rect rect = new Rect(0f, 0f, 0f, 0f);
|
||||
EventType type = Event.current.type;
|
||||
if (type != EventType.Layout)
|
||||
{
|
||||
if (type == EventType.Used)
|
||||
{
|
||||
return GUILayoutEntry.kDummyRect;
|
||||
}
|
||||
rect = GUILayoutUtility.current.topLevel.GetNext().rect;
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayoutUtility.current.topLevel.Add(new GUIGridSizer(contents, xCount, style, options));
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
// Token: 0x170009BD RID: 2493
|
||||
// (get) Token: 0x06002A66 RID: 10854 RVA: 0x00036E88 File Offset: 0x00035088
|
||||
private int rows
|
||||
{
|
||||
get
|
||||
{
|
||||
int num = this.m_Count / this.m_XCount;
|
||||
if (this.m_Count % this.m_XCount != 0)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0400078B RID: 1931
|
||||
private readonly int m_Count;
|
||||
|
||||
// Token: 0x0400078C RID: 1932
|
||||
private readonly int m_XCount;
|
||||
|
||||
// Token: 0x0400078D RID: 1933
|
||||
private readonly float m_MinButtonWidth = -1f;
|
||||
|
||||
// Token: 0x0400078E RID: 1934
|
||||
private readonly float m_MaxButtonWidth = -1f;
|
||||
|
||||
// Token: 0x0400078F RID: 1935
|
||||
private readonly float m_MinButtonHeight = -1f;
|
||||
|
||||
// Token: 0x04000790 RID: 1936
|
||||
private readonly float m_MaxButtonHeight = -1f;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user