ソースコード using System.Collections.Generic; using System.Linq; public static class IListExt { public static void Deconstruct<T> ( this IList<T> self, out T first, out IList<T> rest ) { first = self.Count > 0 ? self[ 0 ] : default; rest = self.Sk</t></t></t>…
はじめに C# 7.0 新機能の分解(Deconstruction)を Unity のいくつかの型で使用できるようにするパッケージ 「Uni Deconstruction」を GitHub に公開しました バージョン Unity 2018.3.11f1 インストール "com.baba_s.uni_deconstruction": "https://github…
ソースコード using System.Collections.Generic; public static class KeyValuePairExt { public static void Deconstruct<TKey, TValue> ( this KeyValuePair<TKey, TValue> self, out TKey key, out TValue value ) { key = self.Key; value = self.Value; } } 使用例 通常 foreach ( </tkey,></tkey,>…
ソースコード using UnityEngine; public static class Vector2Ext { public static void Deconstruct ( this Vector2 self, out float x, out float y ) { x = self.x; y = self.y; } } 使用例 通常 var vec = new Vector2( 1, 2 ); Deconstruction var ( x…
ソースコード using UnityEngine; public static class Vector2IntExt { public static void Deconstruct ( this Vector2Int self, out int x, out int y ) { x = self.x; y = self.y; } } 使用例 通常 var vec = new Vector2Int( 1, 2 ); Deconstruction va…
ソースコード using UnityEngine; public static class Vector3Ext { public static void Deconstruct ( this Vector3 self, out float x, out float y, out float z ) { x = self.x; y = self.y; z = self.z; } } 使用例 通常 var vec = new Vector3( 1, 2,…
ソースコード 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,…
ソースコード using UnityEngine; public static class Vector4Ext { public static void Deconstruct ( this Vector4 self, out float x, out float y, out float z, out float w ) { x = self.x; y = self.y; z = self.z; w = self.w; } } 使用例 通常 var…
ソースコード using System; public static class DateTimeExt { public static void Deconstruct ( this DateTime self, out int year, out int month, out int day ) { year = self.Year; month = self.Month; day = self.Day; } } 使用例 通常 var dt = D…
ソースコード using UnityEngine; public static class ColorExt { public static void Deconstruct ( this Color self, out float r, out float g, out float b ) { r = self.r; g = self.g; b = self.b; } public static void Deconstruct ( this Color se…
ソースコード using UnityEngine; public static class Color32Ext { public static void Deconstruct ( this Color32 self, out byte r, out byte g, out byte b ) { r = self.r; g = self.g; b = self.b; } public static void Deconstruct ( this Color32…
ソースコード 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 R…
ソースコード public static class NullableExt { public static void Deconstruct<T> ( this T? self, out bool hasValue, out T value ) where T : struct { hasValue = self.HasValue; value = self ?? default; } } 使用例 var now = DateTime.Now; var ( h</t>…