Files
2026-06-04 11:42:34 +02:00

106 lines
2.5 KiB
C#

using System;
using UnityEngine.Scripting;
namespace UnityEngine
{
// Token: 0x0200027D RID: 637
internal class ScrollViewState
{
// Token: 0x06002BDA RID: 11226 RVA: 0x0003A194 File Offset: 0x00038394
[RequiredByNativeCode]
public ScrollViewState()
{
}
// Token: 0x06002BDB RID: 11227 RVA: 0x0003A1A0 File Offset: 0x000383A0
public void ScrollTo(Rect pos)
{
this.ScrollTowards(pos, float.PositiveInfinity);
}
// Token: 0x06002BDC RID: 11228 RVA: 0x0003A1B0 File Offset: 0x000383B0
public bool ScrollTowards(Rect pos, float maxDelta)
{
Vector2 vector = this.ScrollNeeded(pos);
bool flag;
if (vector.sqrMagnitude < 0.0001f)
{
flag = false;
}
else if (maxDelta == 0f)
{
flag = true;
}
else
{
if (vector.magnitude > maxDelta)
{
vector = vector.normalized * maxDelta;
}
this.scrollPosition += vector;
this.apply = true;
flag = true;
}
return flag;
}
// Token: 0x06002BDD RID: 11229 RVA: 0x0003A22C File Offset: 0x0003842C
private Vector2 ScrollNeeded(Rect pos)
{
Rect rect = this.visibleRect;
rect.x += this.scrollPosition.x;
rect.y += this.scrollPosition.y;
float num = pos.width - this.visibleRect.width;
if (num > 0f)
{
pos.width -= num;
pos.x += num * 0.5f;
}
num = pos.height - this.visibleRect.height;
if (num > 0f)
{
pos.height -= num;
pos.y += num * 0.5f;
}
Vector2 zero = Vector2.zero;
if (pos.xMax > rect.xMax)
{
zero.x += pos.xMax - rect.xMax;
}
else if (pos.xMin < rect.xMin)
{
zero.x -= rect.xMin - pos.xMin;
}
if (pos.yMax > rect.yMax)
{
zero.y += pos.yMax - rect.yMax;
}
else if (pos.yMin < rect.yMin)
{
zero.y -= rect.yMin - pos.yMin;
}
Rect rect2 = this.viewRect;
rect2.width = Mathf.Max(rect2.width, this.visibleRect.width);
rect2.height = Mathf.Max(rect2.height, this.visibleRect.height);
zero.x = Mathf.Clamp(zero.x, rect2.xMin - this.scrollPosition.x, rect2.xMax - this.visibleRect.width - this.scrollPosition.x);
zero.y = Mathf.Clamp(zero.y, rect2.yMin - this.scrollPosition.y, rect2.yMax - this.visibleRect.height - this.scrollPosition.y);
return zero;
}
// Token: 0x040007E5 RID: 2021
public Rect position;
// Token: 0x040007E6 RID: 2022
public Rect visibleRect;
// Token: 0x040007E7 RID: 2023
public Rect viewRect;
// Token: 0x040007E8 RID: 2024
public Vector2 scrollPosition;
// Token: 0x040007E9 RID: 2025
public bool apply;
}
}