scripts
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using UnityEngine.Experimental.UIElements.StyleEnums;
|
||||
|
||||
namespace UnityEngine.Experimental.UIElements
|
||||
{
|
||||
// Token: 0x0200035D RID: 861
|
||||
public static class VisualElementExtensions
|
||||
{
|
||||
// Token: 0x060034F3 RID: 13555 RVA: 0x0005679C File Offset: 0x0005499C
|
||||
public static Vector2 GlobalToBound(this VisualElement ele, Vector2 p)
|
||||
{
|
||||
Vector3 vector = ele.globalTransform.inverse.MultiplyPoint3x4(new Vector3(p.x, p.y, 0f));
|
||||
return new Vector2(vector.x - ele.position.position.x, vector.y - ele.position.position.y);
|
||||
}
|
||||
|
||||
// Token: 0x060034F4 RID: 13556 RVA: 0x00056828 File Offset: 0x00054A28
|
||||
public static Vector2 LocalToGlobal(this VisualElement ele, Vector2 p)
|
||||
{
|
||||
Vector3 vector = ele.globalTransform.MultiplyPoint3x4(p + ele.position.position);
|
||||
return new Vector2(vector.x, vector.y);
|
||||
}
|
||||
|
||||
// Token: 0x060034F5 RID: 13557 RVA: 0x00056878 File Offset: 0x00054A78
|
||||
public static Rect GlobalToBound(this VisualElement ele, Rect r)
|
||||
{
|
||||
Matrix4x4 inverse = ele.globalTransform.inverse;
|
||||
Vector2 vector = inverse.MultiplyPoint3x4(r.position);
|
||||
r.position = vector - ele.position.position;
|
||||
r.size = inverse.MultiplyPoint3x4(r.size);
|
||||
return r;
|
||||
}
|
||||
|
||||
// Token: 0x060034F6 RID: 13558 RVA: 0x000568F4 File Offset: 0x00054AF4
|
||||
public static Rect LocalToGlobal(this VisualElement ele, Rect r)
|
||||
{
|
||||
Matrix4x4 globalTransform = ele.globalTransform;
|
||||
r.position = globalTransform.MultiplyPoint3x4(ele.position.position + r.position);
|
||||
r.size = globalTransform.MultiplyPoint3x4(r.size);
|
||||
return r;
|
||||
}
|
||||
|
||||
// Token: 0x060034F7 RID: 13559 RVA: 0x00056964 File Offset: 0x00054B64
|
||||
public static Vector2 ChangeCoordinatesTo(this VisualElement src, VisualElement dest, Vector2 point)
|
||||
{
|
||||
return dest.GlobalToBound(src.LocalToGlobal(point));
|
||||
}
|
||||
|
||||
// Token: 0x060034F8 RID: 13560 RVA: 0x00056988 File Offset: 0x00054B88
|
||||
public static Rect ChangeCoordinatesTo(this VisualElement src, VisualElement dest, Rect rect)
|
||||
{
|
||||
return dest.GlobalToBound(src.LocalToGlobal(rect));
|
||||
}
|
||||
|
||||
// Token: 0x060034F9 RID: 13561 RVA: 0x000569AC File Offset: 0x00054BAC
|
||||
public static void StretchToParentSize(this VisualElement elem)
|
||||
{
|
||||
elem.positionType = PositionType.Absolute;
|
||||
elem.positionLeft = 0f;
|
||||
elem.positionTop = 0f;
|
||||
elem.positionRight = 0f;
|
||||
elem.positionBottom = 0f;
|
||||
}
|
||||
|
||||
// Token: 0x060034FA RID: 13562 RVA: 0x000569E4 File Offset: 0x00054BE4
|
||||
public static T GetFirstOfType<T>(this VisualElement self) where T : class
|
||||
{
|
||||
T t = self as T;
|
||||
T t2;
|
||||
if (t != null)
|
||||
{
|
||||
t2 = t;
|
||||
}
|
||||
else
|
||||
{
|
||||
t2 = self.GetFirstAncestorOfType<T>();
|
||||
}
|
||||
return t2;
|
||||
}
|
||||
|
||||
// Token: 0x060034FB RID: 13563 RVA: 0x00056A24 File Offset: 0x00054C24
|
||||
public static T GetFirstAncestorOfType<T>(this VisualElement self) where T : class
|
||||
{
|
||||
for (VisualElement visualElement = self.parent; visualElement != null; visualElement = visualElement.parent)
|
||||
{
|
||||
T t = visualElement as T;
|
||||
if (t != null)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return (T)((object)null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user