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
UniduxIntroduction
Search
mattak
July 23, 2016
Programming
560
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
UniduxIntroduction
2016-07-23 Unibook & LT conference.
mattak
July 23, 2016
More Decks by mattak
See All by mattak
人間はどこまでさぼれるか? AIコーディングで人の関与を計測してみた
mattak
0
11
最近やった作業環境改善施策10個
mattak
0
310
UnixTime is Simple
mattak
0
270
おっさんが停滞しないために
mattak
32
19k
tech invest
mattak
1
370
Nodux - node base redux framework
mattak
0
1.6k
what_is_technical_investment
mattak
0
190
unitypackage distribution
mattak
0
890
Unity energy usage
mattak
0
990
Other Decks in Programming
See All in Programming
PHPだって関数型したい 〜できること、できないこと〜 / fp-in-php
jsoizo
0
160
エンジニアにデザインハーネスを 〜デザインプロセスを規定するためのハーネス〜 / Design harness from an engineer's perspective
rkaga
2
910
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
140
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
190
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
14
6.7k
The Bowling Game- From Imperative to Functional Programming - Part 1
philipschwarz
PRO
0
280
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
160
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
430
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
180
Contextとはなにか
chiroruxx
1
390
Strategic Design in the Frontend: Moduliths & Micro Frontends @DDDEurope
manfredsteyer
PRO
0
140
Featured
See All Featured
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.3k
Evolving SEO for Evolving Search Engines
ryanjones
0
240
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.2k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.4k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
320
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Building Applications with DynamoDB
mza
96
7.1k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.5k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Typedesign – Prime Four
hannesfritz
42
3.1k
Transcript
6OJUZͰ6*࡞Δ࣌ͷ ΞʔΩςΫνϟ UnibookৼΓฦΓʴՆͷLTେձʂ 2016-07-23 @mattak 1
ࣗݾհ 2
3 ID: @mattak 位置ゲームエンジニア Unity⼒: にわか github.com/mattak/ qiita.com/mattak@github
ಥવͰ͕͢ɺ 4
6*࡞Δͱ͖ʹ ͲΜͳײ͡Ͱ ίʔυॻ͍ͯ·͢ʁ 5
6* 6 Tab切り替え 数値の反映 Collectionの表⺬ Gauge表⺬ ViewのOn/OFF …
͜Μͳײ͡ͷ6*͕ ૿͍͑ͯ͘ͱ ίʔσΟϯάϧʔϧʹ ࠔΔɻɻɻ 7
ίʔσΟϯάϧʔϧ ඞཁʁ 8 規模⼩/短期/1⼈/メンテなしの場合 - コーディングルールがなくても成⽴ 規模⼤/⻑期/複数⼈/メンテありの場合 - コーディングルールがないとやってられない
ௐͯΈͨ 9 https://speakerdeck.com/mattak/application-architecture-for-unity-ui
݁Ռ 10 UnityでUI周りのアーキテクチャ考えてる事例少なそう ↓ UnityのUIアーキテクチャを考えて ライブラリにしました
11 github.com/mattak/Unidux
3FEVYΞʔΩςΫνϟ Λࢀߟʹ͠·ͨ͠ 12
ελʔΊ͙ΜͰ ͍ͩ͘͞ 13 github.com/mattak/Unidux
؆୯ʹ ϥΠϒϥϦͷઆ໌ 14
ཁૉͷؔ 15
16 GameObject Action Reducer State Dispatcher(ActionCreator) Renderer(View)
17 GameObject Event情報 状態更新ロジック 状態 Event発⽕者 Viewの変化
$PPLJF$MJDLFSͷྫ 18
19 GameObject +1 count = count+1 count Button押下 text =
count
-JTU7JFXͷྫ 20
21 GameObject {name:”poppo”} List.Add( {name:”poppo”} ) List Start() ListView更新
࣮ྫ 22
23 ActionCreator、Renderer、Uniduxを配置
"DUJPO 24 public enum CountAction { Increment, Decrement }
4UBUF 25 public class State : StateBase<State> { public int
Count { get; set; } }
"DUJPO$SFBUPS 26 public class CountDispatcher : MonoBehaviour { public CountAction
ActionType = CountAction.Increment; void Start() { var button = this.GetComponent<Button>(); button.onClick.AddListener(() => Unidux.Instance.Store.Dispatch(ActionType)); } }
3FEVDFS 27 public static class CountReducer { public static State
Reduce(State state, CountAction action) { switch (action) { case CountAction.Increment: state.Count++; break; case CountAction.Decrement: state.Count--; break; } return state; } }
3FOEFSFS 28 public class CountRenderer : MonoBehaviour { void OnEnable()
{ var store = Unidux.Instance.Store; this.AddDisableTo(store, Render); Render(store.State); } void Render(State state) { var text = this.GetComponent<Text>(); text.text = state.Count.ToString(); } }
6OJEVYDT 29 public class Unidux : SingletonMonoBehaviour<Unidux> { private Store<State>
_store; public Store<State> Store { get { if (null == _store) { _store = new Store<State>(new State()); _store.AddReducer<CountAction>(CountReducer.Reduce); } return _store; } } void Update() { this.Store.Update(); } }
ৄ͘͠ 30 github.com/mattak/Unidux
Կ͕͏Ε͍͠ʁ 31
32 特徴 - クラス間が疎結合になる (メンテ, テスト容易に) - 記述ルールが統⼀される - 状態がStateに集約される
(記録、デバック容易に) - イベントサイクルが⼀⽅向 (可読性アップ) デメリット - 単純なものの記述量が少し増える - 短期書きなぐり系には冗⻑ (ゲームジャムとか)
ήʔϜδϟϜͰ ͍͍ײ͡ʹ ίʔυॻ͖͍ͨɾɾɾ 33
34 github.com/mattak/Unibus
35 - ObserverPatternを気軽に書けるライブラリ - AndroidのEventBusに相当 - Uniduxのイベント通知部分だけほしい Unibus
36 Bus.Instance.Dispatch("message"); イベント送信 イベント受信 void OnEvent(string message) { var text
= this.GetComponent<Text>(); text.text = message; }
ͬͪ͜ ελʔΊ͙ΜͰ ͍ͩ͘͞ 37 github.com/mattak/Unibus
·ͱΊ 38 github.com/mattak/Unidux スター恵んでください よろしくおねがいします github.com/mattak/Unibus
Ҏ্Ͱ͢ɻ ͋Γ͕ͱ͏ ͍͟͝·ͨ͠ʂʂ 39