Awesome
Kogane Deconstruction
C# 7.0 新機能の分解(Deconstruction)を Unity の Vector2、Vector3、Vector4、Color、Rect などのいくつかの型で使用できるようにするパッケージ
使用例
KeyValuePair
var table = new Dictionary<int, string>();
foreach ( var ( key, value ) in table )
{
}
Vector2
var ( x, y ) = new Vector2( 1, 2 );
Vector2Int
var ( x, y ) = new Vector2Int( 1, 2 );
Vector3
var ( x, y ) = new Vector3( 1, 2, 3 );
var ( x, y, z ) = new Vector3( 1, 2, 3 );
Vector3Int
var ( x, y, z ) = new Vector3Int( 1, 2, 3 );
Vector4
var ( x, y ) = new Vector4( 1, 2, 3, 4 );
var ( x, y, z ) = new Vector4( 1, 2, 3, 4 );
var ( x, y, z, w ) = new Vector4( 1, 2, 3, 4 );
Color
var ( r, g, b ) = new Color( 1, 0.75f, 0.5f, 0.25f );
var ( r, g, b, a ) = new Color( 1, 0.75f, 0.5f, 0.25f );
Color32
var ( r, g, b ) = new Color32( 255, 192, 128, 64 );
var ( r, g, b, a ) = new Color32( 255, 192, 128, 64 );
Rect
var ( x, y, width, height ) = new Rect( 1, 2, 3, 4 );
var ( position, size ) = new Rect( 1, 2, 3, 4 );
DateTime
var ( year, month, day ) = new DateTime( 2019, 1, 2, 3, 4, 5 );
var ( year, month, day, hour, minute, second ) = new DateTime( 2019, 1, 2, 3, 4, 5 );
null 許容型
var ( hasValue, value ) = new int?();
var ( hasValue, value ) = new int?( 25 );