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
24時間でゲームをつくるための Unity
Search
ねおりん
April 04, 2019
Programming
2
1.8k
24時間でゲームをつくるための Unity
https://cluster-vr-meetup.connpass.com/event/124095
ねおりん
April 04, 2019
Tweet
Share
More Decks by ねおりん
See All by ねおりん
アバターミーティングを支える技術
noir_neo
0
570
UIElements 最高! 一番好きなUIフレームワークです!
noir_neo
0
600
24時間くらいで作ったゲーム 2019年
noir_neo
0
1.2k
Multiuser AR Experience を ARKit + Unity で実装する
noir_neo
0
2.6k
これで安心! hubot 沼の堕ち方〜娘がいると開発が楽しいね!
noir_neo
0
340
MDLT#004
noir_neo
0
1.5k
FU2 展示反省
noir_neo
0
110
FU2進捗141004
noir_neo
0
140
FU2進捗140920
noir_neo
0
120
Other Decks in Programming
See All in Programming
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
110
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
540
「Chatwork」Android版アプリを 支える単体テストの現在
okuzawats
0
180
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
5
1.2k
フロントエンドのディレクトリ構成どうしてる? Feature-Sliced Design 導入体験談
osakatechlab
8
4.1k
急成長期の品質とスピードを両立するフロントエンド技術基盤
soarteclab
0
930
103 Early Hints
sugi_0000
1
230
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
270
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
770
たのしいparse.y
ydah
3
120
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
290
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.1k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
How STYLIGHT went responsive
nonsquared
95
5.2k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Transcript
24࣌ؒͰήʔϜΛͭ͘ΔͨΊ ͷ Unity 2019/4/4 cluster.unity #1 Ͷ͓ΓΜ (@noir_neo) 1
Ͷ͓ΓΜ • @noir_neo • ήʔϜΛͭ͘Δ • Ϋϥελʔגࣜձࣾ • ιϑτΣΞΤϯδχΞ •
όʔνϟϧϋτ(Ծ) 2
ਪ͠ͷVλϨϯτ 3
somunia • @she_is_wired • youtube.com/c/somuniaroom 4
24࣌ؒͰήʔϜΛͭ͘ΔͨΊ ͷ Unity ֓ཁ • 24࣌ؒͰήʔϜ࡞Δͭ • ݟͳͲ • ·ͱΊ
5
24࣌ؒͰήʔϜ࡞Δͭ • 24࣌ؒ(͘Β͍)ͰήʔϜ࡞Δ • Unity1िؒήʔϜδϟϜΛΖ͏ͱ͚ͯͨ͠Ͳɺ1ि͍ؒ ͳͬͯ͜ͱͰ࢝Ίͨ • ༑ୡͱ͔ಉ྅ͱͬͯΔશʹݸਓతͳ࠵͠ • ࣮ࡍʹίʔυॻ͍ͯΔͷ12࣌ؒఔ
• ͰΞσΟγϣφϧλΠϜΓ͕ͪ 6
24࣌ؒͰήʔϜ࡞Δͭ • ڈ10ճͬͨ ࠓ2ճ • Ұ൪ଟͬͯ͘Δߏ ΤϯδχΞ2 σβΠφʔ1 • جຊతʹՌ
WebGL Ϗϧυ 7
࠷ۙͷՌΛհ͠·͢ • େסഋ THE GREAT KANPAI • POPPO SHOOTER 2019
• RUN • sun-ma 8
9
10
11
12
13
14
ݟͳͲ • 24࣌ؒͰͤ͞ΔͨΊʹɺࢲୡ͕͍Ζ͍Ζࢼͯ͠ࠓͷॴͨͲ Γண͍ͯΔΞϨίϨ • ڠۀ͢Δʹ͋ͨͬͯͳΔ͓͘ޓ͍ͷ࡞ۀΛϒϩοΫ͠ͳ͍ • ͋ΔఔϝϯςφϏϦςΟࣺͯͯΛऔΔ • ͔͋͠͠·Γʹແடংͩͱ͠ͳ͍!
15
ݟͳͲ • ͜͜Ͱൃද͢Δ͜ͱϓϩμΫγϣϯίʔυͰ௨༻͠·ͤΜ • ήʔϜδϟϜͱ͔ϓϩτλΠϐϯάͷώϯτʹͳΕ͍ • Ͱ͖Δ͚ͩଟ͘ͷ tips Λհ͢ΔͨΊʹͻͱͭͻͱͭৄ͍͠આ ໌͠·ͤΜ
• ؾʹͳͬͨ͜ͱɺΑ͘Θ͔Βͳ͔ͬͨ͜ͱͳͲ͋ͱͰฉ͍ ͍ͯͩ͘͞! 16
ݟͳͲϦετ 1/2 • ઃܭࡶʹΔ • 1scene ͰλΠτϧʙϦβϧτ·ͰΔ • Zenject ϛχϚϜʹ͏
• UniRx ࠷ݶ class ؒͷΠϕϯτ௨Ͱ͏ • Input interface Ͱ͍͍ײ͡ʹ 17
ݟͳͲϦετ 2/2 • nested prefab ਆ • CPU ͷ࣮ Random
Ͱे • UniRx.Async ήʔϜશମͷεςʔτཧʹศར • Cloud Build ΘΓͱΦεεϝ • deploy ࣗಈԽ͓ͯ͜͠͏ 18
ઃܭࡶʹΔ • શମͷߏ֬ೝͱ୲ͷՄࢹԽͷͨΊʹ͢Δ • namespace ͱ class ͱґଘͷ͖͘Β͍ • property
ͱ͔શ෦ॻ͜͏ͱ͠ͳ͍ 19
20
21
1scene ͰλΠτϧʙϦβϧ τ·ͰΔ • ͦΜͳʹϦονͳλΠτϧ/ϦβϧτΛ࡞͍ͬͯΔՋͳ͍ • scene ભҠͱ͔ॻ͘͘Β͍ͳΒ UI ͷ
active Γସ͑Δ͚ͩͰ͍ ͍! • ੩తͰ͍͍ͷͱʹ͔͘ scene ʹ͓͍͍ͯ͘ • ίϯϑϦΫτ͢ΔͱࠈͳͷͰ prefab ʹ͢Δͷඞਢ!! 22
23
Zenject ϛχϚϜʹ͏ Zenject ͕ԿͰ͋Δ͔Έͳ͞ΜͬͯΔମͰߦ͖·͢ 24
Zenject Binding (ͱ Zen Auto Injecter) ੵۃతʹ͍ͬͯ͘ • scene ͷϧʔτΦϒδΣΫτಉ࢜ͷґଘ
SerializeField Ͱղܾ ͠ͳ͍΄͏͕ྑ͍ • γʔϯʹอଘ͞ΕΔͷͰίϯϑϦΫτϦεΫ͕ߴ͍ • Factory ॻ͘ྔ͕૿͑Δ͚ͩͰࢫΈ͕গͳ͍ • ࣮ߦίετؾʹ͍͚ͯ͠ͳ͍ 25
GameObjectContext player Λಈత ʹ࡞Δͱ͖ͳͲʹ༗ޮ͕ͩ… • ී௨ʹ Instantiate ͨ͠΄͏͕ૣ͍ •
input ͷࠩ͠ସ͑ΛͲ͏Δ͔͍͠ͱ͜Ζ • ཧ pure class ͰΓ͍͕ͨ GameObject Context Installer ʹ Ҿ͢ͷͱ͔ΊΜͲ͍͘͞ • Monobehaviour ʹͯ͠ GetComponent<IInputEventProvider>(); ͰेΆ͍ 26
UniRx ࠷ݶ class ؒͷΠ ϕϯτ௨Ͱ͏ UniRx ͕ԿͰ͋Δ͔Έͳ͞ΜͬͯΔମͰߦ͖·͢ 27
ґଘੑٯస͠Α͏ • interface Λաʹͬͯɺ24࣌ؒʹ͏Ε͍͜͠ͱͦΜͳ ʹͳ͍ • ݫີʹґଘੑٯసΛ͢Δඞཁͳ͍͕… • நʹґଘͤ͞ͳ͍ͱͯ͠ Observer
ύλʔϯͰґଘͷ͖ ٯʹ͓ͯ͘͠ • class ͷ͕͚͘͢ɺػೳՃ͕͍͢͠ɺίϯϑϦΫ τϦεΫԼ͕Δ 28
كʹΑ͘ݟΔίʔυ 29
public class PlayerCore : MonoBehaviour { [Inject] IInputEventProvider inputEventProvider; bool
CanJump { get; set; } // ໘ʹ͍͍ͭͯΔ͔ͱ͔ void Start() { inputEventProvider.Jump .Where(b => b && CanJump) .Subscribe(_ => Jump()) .AddTo(this); } 30
[SerializeField] PlayerMover mover; void Jump() { mover.Jump(); } } 31
δϟϯϓͨ͠ͱ͖ʹΞχϝʔγϣϯ Λͭͭ͠SE໐Β͍ͨ͠! 32
[SerializeField] PlayerMover mover; + [SerializeField] PlayerAnimator animator; + [SerializeField] SeEmitter
seEmitter; void Jump() { mover.Jump(); + animator.Jump(); + seEmitter.Jump(); } } 33
Γ͍ͨ͜ͱ͕૿͑Δͨͼʹ PlayerCore ʹॲཧ͕૿͍͑ͯ͘ 34
35
public class PlayerCore : MonoBehaviour { [Inject] IInputEventProvider inputEventProvider; bool
CanJump { get; set; } // ໘ʹ͍͍ͭͯΔ͔ͱ͔ public IObservable<Unit> OnJump => inputEventProvider.Jump .Where(b => b && CanJump) .AsUnitObservable(); } 36
public class PlayerMover : MonoBehaviour { [SerializeField] PlayerCore core; [SerializeField]
Rigidbody rb; void Start() { core.OnJump .ObserveOn(Scheduler.MainThreadFixedUpdate) .Subscribe(_ => rb.AddForce(0, jumpPower, 0, ForceMode.Impulse)) .AddTo(this); } } 37
public class PlayerAnimator : MonoBehaviour { [SerializeField] PlayerCore core; [SerializeField]
Animator animator; void Start() { core.OnJump .Subscribe(_ => animator.SetTrigger("Jump")) .AddTo(this); } } 38
39
Input interface Ͱ͍ ͍ײ͡ʹ 40
interface IInputEventProvider { IReadOnlyReactiveProperty<float> Move { get; } } 41
public class PlayerCore : MonoBehaviour { void Start() { var
input = GetComponent<IInputEventProvider>(); } } 42
public class PlayerInput : MonoBehaviour, IInputEventProvider { readonly ReactiveProperty<float> move
= new ReactiveProperty<float>(); IReadOnlyReactiveProperty<float> IInputEventProvider.Move => move; void Update() { move.Value = Input.GetAxis("Horizontal"); } } 43
public class CpuInput : MonoBehaviour, IInputEventProvider { readonly ReactiveProperty<float> move
= new ReactiveProperty<float>(); IReadOnlyReactiveProperty<float> IInputEventProvider.Move => move; void Update() { move.Value = Random.insideUnitCircle.x; } } 44
nested prefab ਆ • Ϟσϧͷࠩ͠ସ͕͑ඵͰऴΘΔ • 2PΧϥʔͱ͔ɺίʔυͰϚςϦΞϧม͑ΔΑΓѹతʹָ 45
• ϞσϧʹجૅతͳεΫϦϓτ͚ͩ͠ ͨͷΛ variant • 1PΧϥʔͷϚςϦΞϧઃఆͨ͠ͷ Λ variant' • 2PΧϥʔͷϚςϦΞϧઃఆͨ͠ͷ
Λ variant'' • ͜Ε2PΑΓ૿͑ͳ͍લఏͩͬͨ ͷͰ 46
CPU ͷ࣮ Random Ͱे 47
దʹ Update loop ʹ Random Ͱॻ ͍͓͚ͯͱΓ͋͑ͣͦΕͬΆ͘ͳΔ • value ͱ͔
Range ͚ͩͰͳ͘ɺ insideUnitCircle Λ͏ͱ͔ • ݅ʹԠͯ֬͡Λม͑ͨΓ 48
ʰେסഋʱͷ CPU ϓϨΠ ϠʔͷҐஔ͢ΒΒͳ͍ 1. ҰఆҎ্ʹ͍Δͱδϟϯϓ͢Δ্͕֬Δ 2. తਅΜதΛબͼ͘͢ • insideUnitCircle.x
Λ͍ͬͯΔ 3. తʹ͍ۙͮͨΒҰఆ֬Ͱ࣍ͷతΛܾΊΔ 49
UniRx.Async ήʔϜશମͷ εςʔτཧʹศར • λΠτϧը໘ͰʰελʔτʱϘλϯ͕ԡ͞ΕͨΒήʔϜ͕͡ ·ͬͯɺࢮΜͩΒϦβϧτΛදࣔ͢Δ • ॲཧҰຊಓ • async/await
Ͱॻ͘ͱ͍͍ײ͡ 50
async void Start() { await Title(); await StartGame(); await GameOver();
await Result(); } async UniTask Title() { titleUi.Show(); await titleUi.OnStartClickAsObservable.ToUniTask(); } 51
Cloud Build ΘΓͱΦεε ϝ • ݶΒΕͨ࣌ؒͱϚγϯϦιʔεͷதͰɺϏϧυʹୣΘΕΔͷ ͍ͬͨͳ͍ • ͱʹ͔͘Ϗϧυճ͓͔ͯ͠ͳ͍ͱɺஃͰʮΤσΟλͰ ಈ͘ͷʹϏϧυͰಈ͔ͳ͍!!ʯ͕ى͖͕ͪ(Կճ͔ͬͯΔ)
52
ͱΓ͋͑ͣ $9/month ͓͚ͬͯ • ࠷ۙΘΓͱ·ͱʹͳͬͨ • ͪΌΜͱ࠷৽ͷόʔδϣϯ͕͑Δ͠ • WebGL ͷ
custom template Θͤͯ΄͍͠ 53
͍ͨ͘ͳ͍ਓ • Ҏલࢲ͕͍ͬͯͨࣗಈϏϧυͷεΫϦϓτΛ͓͍͍ͩ͘͞ • git worktree Ͱ৽͍͠ϫʔΫεϖʔεΛ࡞ͬͯϏϧυͯ͠ gh- pages ϒϥϯνʹ
push ͢Δ • ϚγϯϦιʔε͏͚ͲɺϏϧυதʹ࡞ۀετοϓ͠ͳ͍ https:/ /github.com/noir-neo/unity-webgl-ghpages/blob/master/ build.sh 54
deploy ࣗಈԽ͓ͯ͜͠͏ • static ͳϦϯΫ͕΄͍͠ • ࠷ऴՌΛެ։͓ͯ͘͠ͷʹɺ github pages ૬ੑ͕͍͍
• zip ΛσϓϩΠ͢Δ shell • ͱʹ͔͘ऴΘΓࠒόλόλ͢ΔͷͰɺࣗಈԽͰ͖Δ෦ ͓ͯ͘͠ https:/ /gist.github.com/noir-neo/ 3a2071dc6d8ea8300caed4bc2bb2de26 55
24࣌ؒͰήʔϜ࡞Δͭએ • աڈͷ࡞ूͯͳϒϩάʹ • http:/ /noir-neo.hatenablog.com • ιʔεͯ͢ github ʹ
• https:/ /github.com/one-night-game-jam • ຖճ twitch Ͱ৴ͯ͠Δ • https:/ /www.twitch.tv/noirneo 56
·ͱΊ • ࣌ؒͰήʔϜΛͤ͞ΔͨΊͷ tips ूΛհ͠·ͨ͠ • جຊతͳઃܭͷߟ͑ํͱɺͦͷ࣮ྫɺ͋ͱϏϧυ Έ͍ͨͳ Ͱͨ͠ •
ήʔϜδϟϜͱ͔ϓϩτλΠϐϯά͢Δͱ͖ͷώϯτʹͳΕ ͍Ͱ͢ 57