forked from laicasaane/unity-supplements
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectExtensions.cs
More file actions
77 lines (68 loc) · 2.52 KB
/
Copy pathRectExtensions.cs
File metadata and controls
77 lines (68 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
namespace UnityEngine
{
public static class RectExtensions
{
public static void Deconstruct(this Rect self, out float x, out float y, out float width, out float height)
{
x = self.x;
y = self.y;
width = self.width;
height = self.height;
}
public static void Deconstruct(this RectInt self, out int x, out int y, out int width, out int height)
{
x = self.x;
y = self.y;
width = self.width;
height = self.height;
}
public static void Deconstruct(this Rect self, out Vector2 position, out Vector2 size)
{
position = self.position;
size = self.size;
}
public static void Deconstruct(this RectInt self, out Vector2Int position, out Vector2Int size)
{
position = self.position;
size = self.size;
}
public static void Deconstruct(this RectOffset self, out int left, out int right, out int top, out int bottom)
{
left = self.left;
right = self.right;
top = self.top;
bottom = self.bottom;
}
public static Rect With(this Rect self, float? x = null, float? y = null, float? width = null, float? height = null)
=> new Rect(
x ?? self.x,
y ?? self.y,
width ?? self.width,
height ?? self.height
);
public static RectInt With(this RectInt self, int? x = null, int? y = null, int? width = null, int? height = null)
=> new RectInt(
x ?? self.x,
y ?? self.y,
width ?? self.width,
height ?? self.height
);
public static Rect With(this Rect self, Vector2? position = null, Vector2? size = null)
=> new Rect(
position ?? self.position,
size ?? self.size
);
public static RectInt With(this RectInt self, Vector2Int? position = null, Vector2Int? size = null)
=> new RectInt(
position ?? self.position,
size ?? self.size
);
public static RectOffset With(this RectOffset self, int? left = null, int? right = null, int? top = null, int? bottom = null)
=> new RectOffset(
left ?? self.left,
right ?? self.right,
top ?? self.top,
bottom ?? self.bottom
);
}
}