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
930
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
370
Unity 2021.1での Unityパッケージの名称変更について
ryotamurohoshi
0
630
Odin Validationはいいぞ!
ryotamurohoshi
2
860
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
OCI Vault 概要
oracle4engineer
PRO
0
9.7k
Next.jsとNuxtが混在? iframeでなんとかする!
ypresto
1
130
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
110
Adopting Jetpack Compose in Your Existing Project - GDG DevFest Bangkok 2024
akexorcist
0
120
Platform Engineering for Software Developers and Architects
syntasso
1
520
SDN の Hype Cycle を一通り経験してみて思うこと / Going through the Hype Cycle of SDN
mshindo
1
140
Terraform Stacks入門 #HashiTalks
msato
0
360
Zennのパフォーマンスモニタリングでやっていること
ryosukeigarashi
0
240
【Pycon mini 東海 2024】Google Colaboratoryで試すVLM
kazuhitotakahashi
2
560
プロダクト活用度で見えた真実 ホリゾンタルSaaSでの顧客解像度の高め方
tadaken3
0
210
BLADE: An Attempt to Automate Penetration Testing Using Autonomous AI Agents
bbrbbq
0
330
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
2
230
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Raft: Consensus for Rubyists
vanstee
136
6.6k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Designing for Performance
lara
604
68k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Thoughts on Productivity
jonyablonski
67
4.3k
What's in a price? How to price your products and services
michaelherold
243
12k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
130
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Speed Design
sergeychernyshev
25
620
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; }
ਠҁͥΚ͚ͭѺ҂