コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【C#】Vector3Int の代入を簡略化する Deconstruction

ソースコード

using UnityEngine;

public static class Vector3IntExt
{
    public static void Deconstruct
    (
        this Vector3Int self,
        out  int        x,
        out  int        y,
        out  int        z
    )
    {
        x = self.x;
        y = self.y;
        z = self.z;
    }
}

使用例

通常

var vec = new Vector3Int( 1, 2, 3 );

Deconstruction

var ( x, y, z ) = new Vector3Int( 1, 2, 3 );