Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Vector2Intの互換ライブラリが作りたかった話!
Search
RyotaMurohoshi
December 09, 2017
Technology
0
920
Vector2Intの互換ライブラリが作りたかった話!
2017/12/09 (土) 【年末だよ】Unity お・と・な のLT大会 2017【ポロりしてもいいのよ】
の @RyotaMurohoshi の資料です。
RyotaMurohoshi
December 09, 2017
Tweet
Share
More Decks by RyotaMurohoshi
See All by RyotaMurohoshi
Unityの合同同人誌や合同商業誌を書いてる僕は感想やレビューや評価が欲しい
ryotamurohoshi
0
340
Unity 2021.1での Unityパッケージの名称変更について
ryotamurohoshi
0
620
Odin Validationはいいぞ!
ryotamurohoshi
2
840
Tilemapはいいぞ!2020 〜すごいぞ、プロジェクト専用拡張Brush〜
ryotamurohoshi
0
2.3k
Unityでも、新しいC#
ryotamurohoshi
0
1.2k
Riderはいいぞ!
ryotamurohoshi
1
3.2k
Riderのススメ〜俺はRiderここが好き〜
ryotamurohoshi
1
2.2k
Unity開発者に伝えたい.NETのこと
ryotamurohoshi
4
36k
ImportedLinqのススメ
ryotamurohoshi
0
1.3k
Other Decks in Technology
See All in Technology
Aurora_BlueGreenDeploymentsやってみた
tsukasa_ishimaru
1
120
AIを駆使したゲーム開発戦略: 新設AI組織の取り組み / sge-ai-strategy
cyberagentdevelopers
PRO
1
130
マネジメント視点でのre:Invent参加 ~もしCEOがre:Inventに行ったら~
kojiasai
0
460
フルカイテン株式会社 採用資料
fullkaiten
0
36k
サイバーエージェントにおける生成AIのリスキリング施策の取り組み / cyber-ai-reskilling
cyberagentdevelopers
PRO
2
200
わたしとトラックポイント / TrackPoint tips
masahirokawahara
1
240
プロダクトエンジニアが活躍する環境を作りたくて 事業責任者になった話 ~プロダクトエンジニアの行き着く先~
gimupop
1
480
Apple/Google/Amazonの決済システムの違いを踏まえた定期購読課金システムの構築 / abema-billing-system
cyberagentdevelopers
PRO
1
220
Forget efficiency – Become more productive without the stress
ufried
0
130
Datachain会社紹介資料(2024年11月) / Company Deck
datachain
3
16k
CAMERA-Suite: 広告文生成のための評価スイート / ai-camera-suite
cyberagentdevelopers
PRO
3
270
顧客が本当に必要だったもの - パフォーマンス改善編 / Make what is needed
soudai
24
6.8k
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
26
5.2k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
A better future with KSS
kneath
238
17k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Side Projects
sachag
452
42k
Building Adaptive Systems
keathley
38
2.2k
Automating Front-end Workflow
addyosmani
1365
200k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
228
52k
Done Done
chrislema
181
16k
For a Future-Friendly Web
brad_frost
175
9.4k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Unsuck your backbone
ammeep
668
57k
Transcript
Vector2Int΄䟵϶αϣ϶Ϸ֢͢Π͵͡͵扖Ѻ @RyotaMurohoshi 2017/12/09 (ࢿ) ̓ଙ๛ͶΞ̈́Unity ͠独;独 ΄LTय़տ 2017̓ϪϺΠͭͼΘ͚͚΄Ξ̈́
@RyotaMurohoshi
Unity 2017.2ͽ Vector2IntࣳͿ ݱ圵Intᔮ䯤᭜᭄֛͢ےѺ 托ͭͥ΅ͩͩΨ憎ͼ : h$ps:/ /qiita.com/RyotaMurohoshi/items/4341f51548d8c53559f5
Vector2Int : Vecotr2΄intᇇ Vector2Int positon = new Vector2Int(3, 2); int
x = position.x; int y = position.y;
ΘͷΣΩSerializeΘͽͣΡ public class Example : MonoBehaviour { [SerializeField] Vector2Int position;
}
ΘͷΣΩSerializeΘͽͣΡ
̵ͩΘ;ͥΑͭ͡͵
ͳ͜Ͷ
Vector2Int;͡΄Intᔮ䯤᭜̵֛͢ Unity 2017.2΄ڹͽΘֵ͞ͼ䟵͘͢ͼ̵ ͳ΄ΔΔྋ憒΄ΚͺᑏᤈͽͣΡ϶αϣ϶ϷΨ֢Σ͜Ѻ
Vector2Int΄䟵϶αϣ϶Ϸ֢͢Π͵͡͵扖Ѻ @RyotaMurohoshi 2017/12/09 (ࢿ) ̓ଙ๛ͶΞ̈́Unity ͠独;独 ΄LTय़տ 2017̓ϪϺΠͭͼΘ͚͚΄Ξ̈́
֢̿Π͵͡͵扖̀ ֢̿͵扖̀ͽ΅͚
ͩ΅Vector2Int΄䟵϶αϣ϶ϷΨ֢Σ͜; ᝒ櫞ፗᶎ̵ͭૡॢͭ㪥Π̵᩼͞ͳͭͼগ㶧ͭ͵̵ͳΩ扖
Vector2Int΄䟵϶αϣ϶Ϸ 䟵ͼ͚ͼΘ͚Σ͚Σ͘ΡΞ
ϊЄφπЄϖAPI䟵 (㵛ಋݷ) • UnityEngine.Vector2Intͼྋ憒;ݶͮݷڹ独APIΨ೮ͺ • UNITY_2017_2_OR_NEWERΨֵ͚Unity 2017.2ڹ΄Ε䌏䖕 • Unity 2017.2ίϐϤϔЄϕͭͼΘ̵䟵䯤᭜֛Ψֵ͜πЄϖ
΅֜Θ䄜ͥ͞ͼΘ͚͚Ξͭ͜͵͚
τϷί϶αχ䟵 (㵛ಋݷ) Unity 2017.2ڹͽ̵䟵϶αϣ϶ϷΨτϷί϶αχ Unity 2017.2ϤϺυδμϕΨίϐϤϔЄϕͽͭ͵䦒̵ ڹτϷί϶αχͭ͵㮔Ψͳ΄ΔΔֵ͞ΡΞͭ͜͵͚
ϊЄφπЄϖAPI䟵 τϷί϶αχ䟵 ͩ΄2ͺΨΩ;ͯ͡Ρ΄ᝒ㴼ͭ͵
͘ΩΔΠᒈ͵͚ Unityͧ͠ΡτϷί϶αχTIPS
[Serializable] public class Player { [SerializeField] int hp; [SerializeField] string
name; }
class CharacterContainer : MonoBehaviour { [SerializeField] Player character; }
None
τЄЀϢήαϸ(*.unity独YAML୵ୗ)ͽ̵ ͩΩఽͮͽτϷί϶αχͫΡ Playerࣳͽ͘Ρఘ䁭΅ͿͩΘτϷί϶αχ͚ͫ character: hp: 300 name: "Yusha"
[Serializable] public class Player { [SerializeField] int hp; [SerializeField] string
name; } [Serializable] public class Enemy { [SerializeField] int hp; [SerializeField] string name; }
Player => Enemy 䨗ͣ䟵͞ class CharacterContainer : MonoBehaviour { //
䨗ͣ䟵͞ : [SerializeField] Player character; [SerializeField] Enemy character; }
None
τЄЀϢήαϸ(*.unity独YAML୵ୗ)ͽ̵ ͩΩఽͮͽτϷί϶αχͫ͵ΔΔѺѺѺ character: hp: 300 name: "Yusha"
τЄЀϢήαϸ(*.unity独YAML୵ୗ)ͽ΅̵ τϷί϶αχͫΡϢΰЄϸϖ(΄ࣳ;ݷڹ)͢ݶͮΟ ࣳᛔ֛͢䄜ΥͼΘ䟵͘͢Ρ
ͽ̵Vector2Int
Vector2Int΅τЄЀϢήαϸ(*.unity独YAML୵ୗ)ͽ̵ ͩΩఽͮͽτϷί϶αχͫΡ position: {x: 1, y: 3}
嘦扯Ѻ
[Serializable] public struct Dummy { [SerializeField] int x; [SerializeField] int
y; }
class Example : MonoBehaviour { [SerializeField] Dummy position; }
None
τЄЀϢήαϸ(*.unity独YAML୵ୗ)ͽ̵ ͩΩఽͮͽτϷί϶αχͫΡ position: x: 1 y: 3
Dummy => Vector2Int 䨗ͣ䟵͞ class Example : MonoBehaviour { //[SerializeField]
Dummy position; [SerializeField] Vector2Int position; }
None
τЄЀϢήαϸ(*.unity独YAML୵ୗ)ͽ̵ ͩΩఽͮͽτϷί϶αχͫΡ position { x: 1, y: 3 }
䟵϶αϣ϶ϷΘྋ憒΄Vector2Int;ݶ䯭̵ int΄x;yΨτϷί϶αχͽͣΆ͚͚Ѻ
#if !UNITY_2017_2_OR_NEWER namespace UnityEngine { [System.Serializable] public struct Vector2Int {
[SerializeField] int x; [SerializeField] int y; // ኼ } } #endif
SerializeField͢ͺ͚ͼΡ ϢΰЄϸϖ x独yΨਧ嬝 ͩΩఽͮͽ͚ͧΡѺ
͚͚ͧѺѺѺѺ
ͩͶΗѺѺѺ #if !UNITY_2017_2_OR_NEWER namespace UnityEngine { [System.Serializable] public struct Vector2Int
{ // ϢΰЄϸϖ [SerializeField] int x; [SerializeField] int y; // ኼ } } #endif
API䟵ጱ΅ͩͭ͜͵͚ Vector2Int positon = new Vector2Int(3, 2); // ϤϺϞϓΰ int
x = position.x; int y = position.y;
͚͚ͧ͢͡ 䶲͢՞ͣΔͭ͵Ҙ
ϊЄφπЄϖAPI䟵ጱ΅̵̿x̀ͼ̿ϤϺϞϓΰ̀͢ᥝ τϷί϶αχ䟵΅̵̿x̀ͼ̿ϢΰЄϸϖ̀͢ᥝ
C#ጱ΅ݶݷ΄ϢΰЄϸϖ;ϤϺϞϓΰΨϯϓ͚
ͺΩͶorz
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; }} }
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; }} }
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; }} }
ͺΩͶorz
τϷί϶αχݷ΅̵ϢΰЄϸϖݷͽͭ͡䷥ΗΟ͚ORZ FormerlySerializedAs΅አ᭔͢晅͜orz τϷί϶αχͯΡݷڹΨਧͯΡં͘͢Άorz
ͩΩ䱛ᚆ΅͚ͧͿ̵͘͵ΟΞ͡͵ [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; }} }
ͺΩͶorz
橀(?)΄ṹ悬Ψֵ͚͞͡手ͭͼΕΡ
Mono.Cecil ILΨͪΝͪΝ䨗ͣ䟵̵͞ෛ͵DLLΨ֢Ρͩ;͢ͽͣΡ
Mono.CecilΨͺ͡ͼ xͼϢΰЄϸϖ;ϤϺϞϓΰΨݶ䦒೮ͼΡΞ͜ ϢΰЄϸϖݷΨ䨗ͣ䟵͞ෛ͵DLLΨ֢ΠڊͯѺ
ϤϺϞϓΰ΅πЀϞαϸͯΡ;ILጱ΅ get_x;͚͜Ϯϊϐϖ;set_x;͚͜Ϯϊϐϖ֢͢ΟΡ x;͚͜ݷڹ΄ϮЀϝ͢ͽͣΡΥͧͽ΅̶͚ [System.Serializable] public class PropertyExample { [SerializeField ]
int _x; public int x { get { return _x; } set { _x = value; } } }
̿C#̀ጱ΅NGͽΘ̿.NET̀ጱ΅ ݶݷ΄privateϢΰЄϸϖ;publicϤϺϞϓΰΨ֢Ρͩ;΅ݢᚆ
// 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);
C#ͽ΅ᔰፗ΅䨗͚ͧͧͿ x;͚͜private ϢΰЄϸϖ& public ϤϺϞϓΰ y;͚͜private ϢΰЄϸϖ& public ϤϺϞϓΰ ݶ䦒ΘͺDLLΨMono.Cecilͽ֢ΡѺ
㵛͵Ѻ
ͧͿͩΨͯΡ; UNITY_2017_2_OR_NEWERֵ͚͢͞
ͺΩͶorz
ϢΰЄϸϖ;ϤϺϞϓΰ΅㳨ͶͧͿ Θͩ͜ͽ͚͚͡ORZ [System.Serializable] public struct Vector2Int { public int x;
public int y; } ϤϺϞϓΰ;ϢΰЄϸϖ΅㳨Ͷ͡Ο̵͚ΚͶͧͿ
Δ;Η(;͚͜ݷ΄ݍ)
Vector2Int΄䟵϶αϣ϶Ϸ֢͢Π͵͡͵扖Ѻ
Vector2Int;͡΄䟵ࣳ ཿ͚ͭΞ
• ϢΰЄϸϖ;ͳ΄ࣳ͢ݶͮΟτϷί϶αχ䟵͘Π • SerialzieField͢τϷί϶αχݷΨਧͽͣΆ͚͚΄ORZ • Θͭͥ΅SerialzieAs͘͢Ά͚͚΄ORZ • Mono.CecilΨֵ͞Άݶݷ΄ϢΰЄϸϖ;ϤϺϞϓΰΨͺͥΡ
Θͩ͜ͽ͚͚͡ORZ [System.Serializable] public struct Vector2Int { public int x; public
int y; }
ਠҁͥΚ͚ͭѺ҂