ソースコード
using UnityEngine;
public static class RectExt
{
public static void Deconstruct
(
this Rect self,
out Vector2 position,
out Vector2 size
)
{
position = self.position;
size = self.size;
}
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;
}
}
使用例
通常
var rect = new Rect( 1, 2, 3, 4 );
Deconstruction
var ( position, size ) = new Rect( 1, 2, 3, 4 );
var ( x, y, width, height ) = new Rect( 1, 2, 3, 4 );