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
[AWS JAPAN 生成AIハッカソン] Dialog の紹介
yoshimi0227
0
150
ABEMA のコンテンツ制作を最適化!生成 AI x クラウド映像編集システム / abema-ai-editor
cyberagentdevelopers
PRO
1
180
生成AIとAWS CDKで実現! 自社ブログレビューの効率化
ymae
2
330
ガチ勢によるPipeCD運用大全〜滑らかなCI/CDを添えて〜 / ai-pipecd-encyclopedia
cyberagentdevelopers
PRO
3
210
いまさらのStorybook
ikumatadokoro
0
140
【若手エンジニア応援LT会】AWSで繋がり、共に成長! ~コミュニティ活動と新人教育への挑戦~
kazushi_ohata
0
180
カメラを用いた店内計測におけるオプトインの仕組みの実現 / ai-optin-camera
cyberagentdevelopers
PRO
1
120
マネジメント視点でのre:Invent参加 ~もしCEOがre:Inventに行ったら~
kojiasai
0
470
Gradle: The Build System That Loves To Hate You
aurimas
2
150
スプリントゴールにチームの状態も設定する背景とその効果 / Team state in sprint goals why and impact
kakehashi
2
100
Jr. Championsになって、強く連携しながらAWSをもっと使いたい!~AWSに対する期待と行動~
amixedcolor
0
190
Amazon_CloudWatch_ログ異常検出_導入ガイド
tsujiba
4
1.6k
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
264
13k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
41
2.1k
Faster Mobile Websites
deanohume
304
30k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Into the Great Unknown - MozCon
thekraken
31
1.5k
What's new in Ruby 2.0
geeforr
342
31k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.2k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Designing on Purpose - Digital PM Summit 2013
jponch
115
6.9k
Making the Leap to Tech Lead
cromwellryan
132
8.9k
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; }
ਠҁͥΚ͚ͭѺ҂