Slide 1

Slide 1 text

Vector2Int΄԰䟵϶αϣ϶Ϸ֢͢Π͵͡͹͵扖Ѻ @RyotaMurohoshi 2017/12/09 (ࢿ) ̓ଙ๛ͶΞ̈́Unity ͠独;独΀ ΄LTय़տ 2017̓ϪϺΠͭͼΘ͚͚΄Ξ̈́

Slide 2

Slide 2 text

@RyotaMurohoshi

Slide 3

Slide 3 text

Unity 2017.2ͽ Vector2Intࣳ΀Ϳ ݱ圵Intᔮ䯤᭜᭄֛͢ےѺ 托ͭͥ΅ͩͩΨ憎ͼ΃ : h$ps:/ /qiita.com/RyotaMurohoshi/items/4341f51548d8c53559f5

Slide 4

Slide 4 text

Vector2Int : Vecotr2΄intᇇ Vector2Int positon = new Vector2Int(3, 2); int x = position.x; int y = position.y;

Slide 5

Slide 5 text

ΘͷΣΩSerializeΘͽͣΡ public class Example : MonoBehaviour { [SerializeField] Vector2Int position; }

Slide 6

Slide 6 text

ΘͷΣΩSerializeΘͽͣΡ

Slide 7

Slide 7 text

ͩ΢̵Θ͹;෱ͥΑͭ͡͹͵

Slide 8

Slide 8 text

ͳ͜Ͷ

Slide 9

Slide 9 text

Vector2Int;͡΄Intᔮ䯤᭜̵֛͢ Unity 2017.2΄ڹͽΘֵ͞ͼ԰䟵௔͘͢͹ͼ̵ ͳ΄ΔΔྋ憒΄Κͺ΁ᑏᤈͽͣΡ϶αϣ϶ϷΨ֢Σ͜Ѻ

Slide 10

Slide 10 text

Vector2Int΄԰䟵϶αϣ϶Ϸ֢͢Π͵͡͹͵扖Ѻ @RyotaMurohoshi 2017/12/09 (ࢿ) ̓ଙ๛ͶΞ̈́Unity ͠独;独΀ ΄LTय़տ 2017̓ϪϺΠͭͼΘ͚͚΄Ξ̈́

Slide 11

Slide 11 text

֢̿Π͵͡͹͵扖̀ ֢̿͹͵扖̀ͽ΅΀͚

Slide 12

Slide 12 text

ͩ΢΅Vector2Int΄԰䟵϶αϣ϶ϷΨ֢Σ͜; ᝒ櫞΁ፗᶎ̵ͭૡॢͭ㪥Π̵᩼͞ͳͭͼগ㶧ͭ͵̵ͳΩ΀扖

Slide 13

Slide 13 text

Vector2Int΄԰䟵϶αϣ϶Ϸ ԰䟵௔͹ͼ͚͹ͼΘ͚Σ͚Σ͘ΡΞ΃

Slide 14

Slide 14 text

ϊЄφπЄϖAPI԰䟵௔ (㵛ಋ΁޸ݷ) • UnityEngine.Vector2Int͹ͼྋ憒;ݶͮݷڹ独APIΨ೮ͺ • UNITY_2017_2_OR_NEWERΨֵ͚Unity 2017.2ڹ΄Ε΁䌏䖕 • Unity 2017.2΁ίϐϤϔЄϕͭͼΘ̵԰䟵䯤᭜֛Ψֵ͜πЄϖ ΅֜Θ䄜͞΀ͥͼΘ͚͚Ξ͜΁ͭ͵͚

Slide 15

Slide 15 text

τϷί϶αχ԰䟵௔ (㵛ಋ΁޸ݷ) Unity 2017.2ڹͽ̵԰䟵϶αϣ϶ϷΨτϷί϶αχ Unity 2017.2΁ϤϺυδμϕΨίϐϤϔЄϕͽͭ͵䦒̵ ڹ΁τϷί϶αχͭ͵㮔Ψͳ΄ΔΔֵ͞ΡΞ͜΁ͭ͵͚

Slide 16

Slide 16 text

ϊЄφπЄϖAPI԰䟵௔ τϷί϶αχ԰䟵௔ ͩ΄2ͺΨ΀Ω;ͯ͡Ρ΄΁ᝒ㴼ͭ͵

Slide 17

Slide 17 text

͘ΩΔΠ஀΁ᒈ͵΀͚ Unity΁ͧ͠ΡτϷί϶αχTIPS

Slide 18

Slide 18 text

[Serializable] public class Player { [SerializeField] int hp; [SerializeField] string name; }

Slide 19

Slide 19 text

class CharacterContainer : MonoBehaviour { [SerializeField] Player character; }

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

τЄЀϢήαϸ(*.unity独YAML୵ୗ)ͽ̵ ͩΩ΀ఽͮͽτϷί϶αχͫ΢Ρ Playerࣳͽ͘Ρఘ䁭΅Ϳͩ΁ΘτϷί϶αχͫ΢΀͚ character: hp: 300 name: "Yusha"

Slide 22

Slide 22 text

[Serializable] public class Player { [SerializeField] int hp; [SerializeField] string name; } [Serializable] public class Enemy { [SerializeField] int hp; [SerializeField] string name; }

Slide 23

Slide 23 text

Player => Enemy ΁䨗ͣ䟵͞ class CharacterContainer : MonoBehaviour { // 䨗ͣ䟵͞ : [SerializeField] Player character; [SerializeField] Enemy character; }

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

τЄЀϢήαϸ(*.unity独YAML୵ୗ)ͽ̵ ͩΩ΀ఽͮͽτϷί϶αχͫ΢͵ΔΔѺѺѺ character: hp: 300 name: "Yusha"

Slide 26

Slide 26 text

τЄЀϢήαϸ(*.unity独YAML୵ୗ)ͽ΅̵ τϷί϶αχͫ΢ΡϢΰЄϸϖ(΄ࣳ;ݷڹ)͢ݶͮ΀Ο ࣳᛔ֛͢䄜Υ͹ͼΘ԰䟵௔͘͢Ρ

Slide 27

Slide 27 text

ͽ̵Vector2Int

Slide 28

Slide 28 text

Vector2Int΅τЄЀϢήαϸ(*.unity独YAML୵ୗ)ͽ̵ ͩΩ΀ఽͮͽτϷί϶αχͫ΢Ρ position: {x: 1, y: 3}

Slide 29

Slide 29 text

嘦扯Ѻ

Slide 30

Slide 30 text

[Serializable] public struct Dummy { [SerializeField] int x; [SerializeField] int y; }

Slide 31

Slide 31 text

class Example : MonoBehaviour { [SerializeField] Dummy position; }

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

τЄЀϢήαϸ(*.unity独YAML୵ୗ)ͽ̵ ͩΩ΀ఽͮͽτϷί϶αχͫ΢Ρ position: x: 1 y: 3

Slide 34

Slide 34 text

Dummy => Vector2Int ΁䨗ͣ䟵͞ class Example : MonoBehaviour { //[SerializeField] Dummy position; [SerializeField] Vector2Int position; }

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

τЄЀϢήαϸ(*.unity独YAML୵ୗ)ͽ̵ ͩΩ΀ఽͮͽτϷί϶αχͫ΢Ρ position { x: 1, y: 3 }

Slide 37

Slide 37 text

԰䟵϶αϣ϶ϷΘྋ憒΄Vector2Int;ݶ䯭̵ int΄x;yΨτϷί϶αχͽͣ΢Ά͚͚Ѻ

Slide 38

Slide 38 text

#if !UNITY_2017_2_OR_NEWER namespace UnityEngine { [System.Serializable] public struct Vector2Int { [SerializeField] int x; [SerializeField] int y; // ኼ } } #endif

Slide 39

Slide 39 text

SerializeField͢ͺ͚ͼΡ ϢΰЄϸϖ x独yΨਧ嬝 ͩΩ΀ఽͮͽ͚ͧΡѺ

Slide 40

Slide 40 text

͚ͧ΀͚ѺѺѺѺ

Slide 41

Slide 41 text

ͩ΢ͶΗѺѺѺ #if !UNITY_2017_2_OR_NEWER namespace UnityEngine { [System.Serializable] public struct Vector2Int { // ϢΰЄϸϖ [SerializeField] int x; [SerializeField] int y; // ኼ } } #endif

Slide 42

Slide 42 text

API԰䟵௔ጱ΁΅ͩͭ͜͵͚ Vector2Int positon = new Vector2Int(3, 2); // ϤϺϞϓΰ int x = position.x; int y = position.y;

Slide 43

Slide 43 text

΀΁͚ͧ͢΀͚͡ 䶲͢՞ͣΔͭ͵Ҙ

Slide 44

Slide 44 text

ϊЄφπЄϖAPI԰䟵ጱ΁΅̵̿x̀͹ͼ̿ϤϺϞϓΰ̀͢஠ᥝ τϷί϶αχ԰䟵௔΁΅̵̿x̀͹ͼ̿ϢΰЄϸϖ̀͢஠ᥝ

Slide 45

Slide 45 text

C#ጱ΁΅ݶݷ΄ϢΰЄϸϖ;ϤϺϞϓΰΨϯϓ΀͚

Slide 46

Slide 46 text

ͺΩͶorz

Slide 47

Slide 47 text

x独y;͚͜ϢΰЄϸϖݷͽ΀͚;τϷί϶αχ΄԰䟵௔͢orz [System.Serializable] public struct Vector2Int { [SerializeField] int _x; public int x { get { return _x; } set { _x = value; }} [SerializeField] int _y; public int y { get { return _y; } set { _y = value; }} }

Slide 48

Slide 48 text

x独y;͚͜ϤϺϞϓΰݷͽ΀͚;API΄԰䟵௔͢orz [System.Serializable] public struct Vector2Int { [SerializeField] int x; public int X { get { return x; } set { x = value; }} [SerializeField] int y; public int Y { get { return y; } set { y = value; }} }

Slide 49

Slide 49 text

C#ͽ΅̵ݶӞ΄ݷڹ΄ϢΰЄϸϖ;ϤϺϞϓΰΨਧ嬝ͽͣ΀͚ [System.Serializable] public struct Vector2Int { [SerializeField] int x; public int x { get { return x; } set { x = value; }} [SerializeField] int y; public int y { get { return y; } set { y = value; }} }

Slide 50

Slide 50 text

ͺΩͶorz

Slide 51

Slide 51 text

τϷί϶αχݷ΅̵ϢΰЄϸϖݷͽͭ͡䷥ΗΟ΢΀͚ORZ FormerlySerializedAs΅አ᭔͢晅͜orz τϷί϶αχͯΡݷڹΨ೰ਧͯΡં௔͘͢΢Άorz

Slide 52

Slide 52 text

ͩΩ΀䱛ᚆ΅΀͚ͧ΢Ϳ̵͘͹͵ΟΞ͡͹͵ [System.Serializable] public struct Vector2Iny { [SerializedAs("x")] // ͩΩ΀ఽͮͽݷڹΨ೰ਧͭ͵͡͹͵ [SerializeField] int _x; public int x { get { return _x; } set { _x = value; }} [SerializedAs("y")] // ͩΩ΀ఽͮͽݷڹΨ೰ਧͭ͵͡͹͵ [SerializeField] int _y; public int y { get { return _y; } set { _y = value; }} }

Slide 53

Slide 53 text

ͺΩͶorz

Slide 54

Slide 54 text

橀(?)΄ṹ悬Ψֵ͞΀͚͡手ͭͼΕΡ

Slide 55

Slide 55 text

Mono.Cecil ILΨͪ΁Νͪ΁Ν䨗ͣ䟵̵͞ෛ͵΀DLLΨ֢Ρͩ;͢ͽͣΡ

Slide 56

Slide 56 text

Mono.CecilΨͺ͡͹ͼ x͹ͼϢΰЄϸϖ;ϤϺϞϓΰΨݶ䦒΁೮ͼΡΞ͜΁ ϢΰЄϸϖݷΨ䨗ͣ䟵͞ෛ͵΀DLLΨ֢ΠڊͯѺ

Slide 57

Slide 57 text

ϤϺϞϓΰ΅πЀϞαϸͯΡ;ILጱ΁΅ get_x;͚͜Ϯϊϐϖ;set_x;͚͜Ϯϊϐϖ֢͢Ο΢Ρ x;͚͜ݷڹ΄ϮЀϝ͢ͽͣΡΥͧͽ΅΀̶͚ [System.Serializable] public class PropertyExample { [SerializeField ] int _x; public int x { get { return _x; } set { _x = value; } } }

Slide 58

Slide 58 text

̿C#̀ጱ΁΅NGͽΘ̿.NET̀ጱ΁΅ ݶݷ΄privateϢΰЄϸϖ;publicϤϺϞϓΰΨ֢Ρͩ;΅ݢᚆ

Slide 59

Slide 59 text

// Mono.CecilͽDLL΄Ӿ΄ࣳ΄قϢΰЄϸϖ΄ض毣΄`_`Ψ;͹͵ݷᑍ΁䄜ๅͯΡπЄϖ var targetAssembly = AssemblyDefinition.ReadAssembly(sourceAssemblyPath); foreach (var type in targetAssembly.Modules.SelectMany(x => x.Types)){ foreach (var field in type.Fields) { var fieldReference = field.Module.Import(field); fieldReference.Name = fieldReference.Name.TrimStart('_'); } } sourceAssembly.Write(resultAssemblyPath);

Slide 60

Slide 60 text

C#ͽ΅ᔰፗ΁΅䨗ͧ΀͚ͧ΢Ϳ x;͚͜private ϢΰЄϸϖ& public ϤϺϞϓΰ y;͚͜private ϢΰЄϸϖ& public ϤϺϞϓΰ ݶ䦒΁ΘͺDLLΨMono.Cecilͽ֢΢ΡѺ

Slide 61

Slide 61 text

㵛͹͵Ѻ

Slide 62

Slide 62 text

ͧ΢Ϳͩ΢ΨͯΡ; UNITY_2017_2_OR_NEWERֵ͢͞΀͚

Slide 63

Slide 63 text

ͺΩͶorz

Slide 64

Slide 64 text

ϢΰЄϸϖ;ϤϺϞϓΰ΅㳨Ͷͧ΢Ϳ Θͩ͜΢ͽ͚͚͡ORZ [System.Serializable] public struct Vector2Int { public int x; public int y; } ϤϺϞϓΰ;ϢΰЄϸϖ΅㳨Ͷ͡Ο̵͚ΚͶͧͿ

Slide 65

Slide 65 text

Δ;Η(;͚͜ݷ΄ݍ፜)

Slide 66

Slide 66 text

Vector2Int΄԰䟵϶αϣ϶Ϸ֢͢Π͵͡͹͵扖Ѻ

Slide 67

Slide 67 text

Vector2Int;͡΄԰䟵ࣳ ཿ͚ͭΞ΃

Slide 68

Slide 68 text

• ϢΰЄϸϖ;ͳ΄ࣳ͢ݶͮ΀ΟτϷί϶αχ԰䟵௔͘Π • SerialzieField͢τϷί϶αχݷΨ೰ਧͽͣ΢Ά͚͚΄΁ORZ • Θͭͥ΅SerialzieAs͘͢΢Ά͚͚΄΁ORZ • Mono.CecilΨֵ͞Άݶݷ΄ϢΰЄϸϖ;ϤϺϞϓΰΨͺͥ΢Ρ

Slide 69

Slide 69 text

Θͩ͜΢ͽ͚͚͡ORZ [System.Serializable] public struct Vector2Int { public int x; public int y; }

Slide 70

Slide 70 text

ਠҁͥΚ͚ͭѺ҂