├── Runtime ├── Kogane.Deconstruction.asmdef ├── Kogane.Deconstruction.asmdef.meta ├── RectDeconstruction.cs.meta ├── Color32Deconstruction.cs.meta ├── ColorDeconstruction.cs.meta ├── DateTimeDeconstruction.cs.meta ├── NullableDeconstruction.cs.meta ├── Vector2Deconstruction.cs.meta ├── Vector3Deconstruction.cs.meta ├── Vector4Deconstruction.cs.meta ├── KeyValuePairDeconstruction.cs.meta ├── Vector2IntDeconstruction.cs.meta ├── Vector3IntDeconstruction.cs.meta ├── Vector2Deconstruction.cs ├── Vector2IntDeconstruction.cs ├── NullableDeconstruction.cs ├── Vector3IntDeconstruction.cs ├── KeyValuePairDeconstruction.cs ├── Vector3Deconstruction.cs ├── ColorDeconstruction.cs ├── RectDeconstruction.cs ├── Color32Deconstruction.cs ├── DateTimeDeconstruction.cs └── Vector4Deconstruction.cs ├── LICENSE.md.meta ├── README.md.meta ├── package.json.meta ├── Runtime.meta ├── package.json ├── LICENSE.md └── README.md /Runtime/Kogane.Deconstruction.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Kogane.Deconstruction" 3 | } 4 | -------------------------------------------------------------------------------- /LICENSE.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2bcf0ff4cc56404459f1f5c76ddd8dc6 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 756db5e299a56cf4f87943c4afb22696 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c640347c9c24014a8c1f910db03c791 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a16cca3aa9ab37d4ba279ed89301ee97 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Kogane.Deconstruction.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f1014cc5e38b4f74b9509d67b659f102 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.baba-s.kogane-deconstruction", 3 | "displayName": "Kogane Deconstruction", 4 | "version": "1.0.0", 5 | "unity": "2022.1", 6 | "author": "baba-s", 7 | "description": "", 8 | "dependencies": {} 9 | } -------------------------------------------------------------------------------- /Runtime/RectDeconstruction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53559f526f8d2594ab4a0e439b517f18 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Color32Deconstruction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e6f4ef506fe41ee41844aa3de12386a8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/ColorDeconstruction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a9971b908e7e7148b125a10382f98f7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/DateTimeDeconstruction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d7cae7dbadfc6d043a7f9e05a49c0bd7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/NullableDeconstruction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1deb95718d7716b4bac67824a5ef9a49 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Vector2Deconstruction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8dbbc1d00e22da42aa343a54a4e7e17 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Vector3Deconstruction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e0b42fa3570045240b88b515af3d055d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Vector4Deconstruction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8dc1645029191124a80837fac9d36e75 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/KeyValuePairDeconstruction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8a6d346be8235e4c846365532ab85ce 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Vector2IntDeconstruction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d825fb45610155c48806ca803461abbf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Vector3IntDeconstruction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 17be843ee6b98674daf38d0bb20fb6bd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Vector2Deconstruction.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Kogane 4 | { 5 | public static class Vector2Deconstruction 6 | { 7 | public static void Deconstruct 8 | ( 9 | this Vector2 self, 10 | out float x, 11 | out float y 12 | ) 13 | { 14 | x = self.x; 15 | y = self.y; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/Vector2IntDeconstruction.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Kogane 4 | { 5 | public static class Vector2IntDeconstruction 6 | { 7 | public static void Deconstruct 8 | ( 9 | this Vector2Int self, 10 | out int x, 11 | out int y 12 | ) 13 | { 14 | x = self.x; 15 | y = self.y; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/NullableDeconstruction.cs: -------------------------------------------------------------------------------- 1 | namespace Kogane 2 | { 3 | public static class NullableDeconstruction 4 | { 5 | public static void Deconstruct 6 | ( 7 | this T? self, 8 | out bool hasValue, 9 | out T value 10 | ) where T : struct 11 | { 12 | hasValue = self.HasValue; 13 | value = self ?? default; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Runtime/Vector3IntDeconstruction.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Kogane 4 | { 5 | public static class Vector3IntDeconstruction 6 | { 7 | public static void Deconstruct 8 | ( 9 | this Vector3Int self, 10 | out int x, 11 | out int y, 12 | out int z 13 | ) 14 | { 15 | x = self.x; 16 | y = self.y; 17 | z = self.z; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/KeyValuePairDeconstruction.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Kogane 4 | { 5 | public static class KeyValuePairDeconstruction 6 | { 7 | public static void Deconstruct 8 | ( 9 | this KeyValuePair self, 10 | out TKey key, 11 | out TValue value 12 | ) 13 | { 14 | key = self.Key; 15 | value = self.Value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/Vector3Deconstruction.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Kogane 4 | { 5 | public static class Vector3Deconstruction 6 | { 7 | public static void Deconstruct 8 | ( 9 | this Vector3 self, 10 | out float x, 11 | out float y 12 | ) 13 | { 14 | x = self.x; 15 | y = self.y; 16 | } 17 | 18 | public static void Deconstruct 19 | ( 20 | this Vector3 self, 21 | out float x, 22 | out float y, 23 | out float z 24 | ) 25 | { 26 | x = self.x; 27 | y = self.y; 28 | z = self.z; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Runtime/ColorDeconstruction.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Kogane 4 | { 5 | public static class ColorDeconstruction 6 | { 7 | public static void Deconstruct 8 | ( 9 | this Color self, 10 | out float r, 11 | out float g, 12 | out float b 13 | ) 14 | { 15 | r = self.r; 16 | g = self.g; 17 | b = self.b; 18 | } 19 | 20 | public static void Deconstruct 21 | ( 22 | this Color self, 23 | out float r, 24 | out float g, 25 | out float b, 26 | out float a 27 | ) 28 | { 29 | r = self.r; 30 | g = self.g; 31 | b = self.b; 32 | a = self.a; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /Runtime/RectDeconstruction.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Kogane 4 | { 5 | public static class RectDeconstruction 6 | { 7 | public static void Deconstruct 8 | ( 9 | this Rect self, 10 | out Vector2 position, 11 | out Vector2 size 12 | ) 13 | { 14 | position = self.position; 15 | size = self.size; 16 | } 17 | 18 | public static void Deconstruct 19 | ( 20 | this Rect self, 21 | out float x, 22 | out float y, 23 | out float width, 24 | out float height 25 | ) 26 | { 27 | x = self.x; 28 | y = self.y; 29 | width = self.width; 30 | height = self.height; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Runtime/Color32Deconstruction.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Kogane 4 | { 5 | public static class Color32Deconstruction 6 | { 7 | public static void Deconstruct 8 | ( 9 | this Color32 self, 10 | out byte r, 11 | out byte g, 12 | out byte b 13 | ) 14 | { 15 | r = self.r; 16 | g = self.g; 17 | b = self.b; 18 | } 19 | 20 | public static void Deconstruct 21 | ( 22 | this Color32 self, 23 | out byte r, 24 | out byte g, 25 | out byte b, 26 | out byte a 27 | ) 28 | { 29 | r = self.r; 30 | g = self.g; 31 | b = self.b; 32 | a = self.a; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /Runtime/DateTimeDeconstruction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Kogane 4 | { 5 | public static class DateTimeDeconstruction 6 | { 7 | public static void Deconstruct 8 | ( 9 | this DateTime self, 10 | out int year, 11 | out int month, 12 | out int day 13 | ) 14 | { 15 | year = self.Year; 16 | month = self.Month; 17 | day = self.Day; 18 | } 19 | 20 | public static void Deconstruct 21 | ( 22 | this DateTime self, 23 | out int year, 24 | out int month, 25 | out int day, 26 | out int hour, 27 | out int minute, 28 | out int second 29 | ) 30 | { 31 | year = self.Year; 32 | month = self.Month; 33 | day = self.Day; 34 | hour = self.Hour; 35 | minute = self.Minute; 36 | second = self.Second; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Runtime/Vector4Deconstruction.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Kogane 4 | { 5 | public static class Vector4Deconstruction 6 | { 7 | public static void Deconstruct 8 | ( 9 | this Vector4 self, 10 | out float x, 11 | out float y 12 | ) 13 | { 14 | x = self.x; 15 | y = self.y; 16 | } 17 | 18 | public static void Deconstruct 19 | ( 20 | this Vector4 self, 21 | out float x, 22 | out float y, 23 | out float z 24 | ) 25 | { 26 | x = self.x; 27 | y = self.y; 28 | z = self.z; 29 | } 30 | 31 | public static void Deconstruct 32 | ( 33 | this Vector4 self, 34 | out float x, 35 | out float y, 36 | out float z, 37 | out float w 38 | ) 39 | { 40 | x = self.x; 41 | y = self.y; 42 | z = self.z; 43 | w = self.w; 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 baba_s 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kogane Deconstruction 2 | 3 | C# 7.0 新機能の分解(Deconstruction)を Unity の Vector2、Vector3、Vector4、Color、Rect などのいくつかの型で使用できるようにするパッケージ 4 | 5 | ## 使用例 6 | 7 | ### KeyValuePair 8 | 9 | ```cs 10 | var table = new Dictionary(); 11 | 12 | foreach ( var ( key, value ) in table ) 13 | { 14 | } 15 | ``` 16 | 17 | ### Vector2 18 | 19 | ```cs 20 | var ( x, y ) = new Vector2( 1, 2 ); 21 | ``` 22 | 23 | ### Vector2Int 24 | 25 | ```cs 26 | var ( x, y ) = new Vector2Int( 1, 2 ); 27 | ``` 28 | 29 | ### Vector3 30 | 31 | ```cs 32 | var ( x, y ) = new Vector3( 1, 2, 3 ); 33 | ``` 34 | 35 | ```cs 36 | var ( x, y, z ) = new Vector3( 1, 2, 3 ); 37 | ``` 38 | 39 | ### Vector3Int 40 | 41 | ```cs 42 | var ( x, y, z ) = new Vector3Int( 1, 2, 3 ); 43 | ``` 44 | 45 | ### Vector4 46 | 47 | ```cs 48 | var ( x, y ) = new Vector4( 1, 2, 3, 4 ); 49 | ``` 50 | 51 | ```cs 52 | var ( x, y, z ) = new Vector4( 1, 2, 3, 4 ); 53 | ``` 54 | 55 | ```cs 56 | var ( x, y, z, w ) = new Vector4( 1, 2, 3, 4 ); 57 | ``` 58 | 59 | ### Color 60 | 61 | ```cs 62 | var ( r, g, b ) = new Color( 1, 0.75f, 0.5f, 0.25f ); 63 | ``` 64 | 65 | ```cs 66 | var ( r, g, b, a ) = new Color( 1, 0.75f, 0.5f, 0.25f ); 67 | ``` 68 | 69 | ### Color32 70 | 71 | ```cs 72 | var ( r, g, b ) = new Color32( 255, 192, 128, 64 ); 73 | ``` 74 | 75 | ```cs 76 | var ( r, g, b, a ) = new Color32( 255, 192, 128, 64 ); 77 | ``` 78 | 79 | ### Rect 80 | 81 | ```cs 82 | var ( x, y, width, height ) = new Rect( 1, 2, 3, 4 ); 83 | ``` 84 | 85 | ```cs 86 | var ( position, size ) = new Rect( 1, 2, 3, 4 ); 87 | ``` 88 | 89 | ### DateTime 90 | 91 | ```cs 92 | var ( year, month, day ) = new DateTime( 2019, 1, 2, 3, 4, 5 ); 93 | ``` 94 | 95 | ```cs 96 | var ( year, month, day, hour, minute, second ) = new DateTime( 2019, 1, 2, 3, 4, 5 ); 97 | ``` 98 | 99 | ### null 許容型 100 | 101 | ```cs 102 | var ( hasValue, value ) = new int?(); 103 | ``` 104 | 105 | ```cs 106 | var ( hasValue, value ) = new int?( 25 ); 107 | ``` 108 | --------------------------------------------------------------------------------