mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 06:08:16 +08:00
Fix RectTransform.GetWorldCorners in il2cpp
This commit is contained in:
parent
b03349a3e0
commit
dec113d2ee
@ -8,31 +8,22 @@ namespace UnityExplorer.UI.Widgets.InfiniteScroll
|
||||
{
|
||||
public static class UIExtension
|
||||
{
|
||||
public static Vector3[] GetCorners(this RectTransform rectTransform)
|
||||
public static void GetCorners(this RectTransform rect, Vector3[] corners)
|
||||
{
|
||||
Vector3[] corners = new Vector3[4];
|
||||
rectTransform.GetWorldCorners(corners);
|
||||
return corners;
|
||||
}
|
||||
public static float MaxY(this RectTransform rectTransform)
|
||||
{
|
||||
return rectTransform.GetCorners()[1].y;
|
||||
Vector3 bottomLeft = new Vector3(rect.position.x, rect.position.y - rect.rect.height, 0);
|
||||
|
||||
corners[0] = bottomLeft;
|
||||
corners[1] = bottomLeft + new Vector3(0, rect.rect.height, 0);
|
||||
corners[2] = bottomLeft + new Vector3(rect.rect.width, rect.rect.height, 0);
|
||||
corners[3] = bottomLeft + new Vector3(rect.rect.width, 0, 0);
|
||||
}
|
||||
|
||||
public static float MinY(this RectTransform rectTransform)
|
||||
{
|
||||
return rectTransform.GetCorners()[0].y;
|
||||
}
|
||||
public static float MaxY(this RectTransform rect) => rect.position.y - rect.rect.height;
|
||||
|
||||
public static float MaxX(this RectTransform rectTransform)
|
||||
{
|
||||
return rectTransform.GetCorners()[2].x;
|
||||
}
|
||||
public static float MinY(this RectTransform rect) => rect.position.y;
|
||||
|
||||
public static float MinX(this RectTransform rectTransform)
|
||||
{
|
||||
return rectTransform.GetCorners()[0].x;
|
||||
}
|
||||
public static float MaxX(this RectTransform rect) => rect.position.x - rect.rect.width;
|
||||
|
||||
public static float MinX(this RectTransform rect) => rect.position.x;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user