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
StudyUnityFromAnti-pattern
Search
Cova8bitdots
November 20, 2019
Programming
0
2.3k
StudyUnityFromAnti-pattern
Unity の使い方のアンチパターンを紹介。
そこからどう解消すべきかを紹介しています
Cova8bitdots
November 20, 2019
Tweet
Share
More Decks by Cova8bitdots
See All by Cova8bitdots
Latest_Information_of_CICD_for_UnityAppWithAppleVisionPro
cova8bitdots
0
28
HandGestureTool for AppleVisionPro
cova8bitdots
0
71
NinjaGazeTyping 制作秘話
cova8bitdots
0
270
UnityとGoogleCloudFunction を連携して社内サービスを作った話
cova8bitdots
0
130
Unity-chan.Terrastal!!
cova8bitdots
0
310
ExampleOfTilemap2D
cova8bitdots
0
89
unity_lt_2021_Dec.pdf
cova8bitdots
0
740
HowToUseAudioMixer
cova8bitdots
0
110
TrapOfSpriteAtlas
cova8bitdots
0
4.9k
Other Decks in Programming
See All in Programming
コンテナをたくさん詰め込んだシステムとランタイムの変化
makihiro
1
120
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
DevFest Tokyo 2025 - Flutter のアプリアーキテクチャ現在地点
wasabeef
5
900
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
nekko cloudにおけるProxmox VE利用事例
irumaru
3
430
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
770
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
200
Jakarta EE meets AI
ivargrimstad
0
240
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
120
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
130
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
2
460
Symfony Mapper Component
soyuka
2
730
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
111
49k
Bash Introduction
62gerente
608
210k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
Building Applications with DynamoDB
mza
91
6.1k
KATA
mclloyd
29
14k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
97
Statistics for Hackers
jakevdp
796
220k
Transcript
Ξϯνύλʔϯ͔ΒֶͿ UNITYͷ͍ํ Gotanda.unity #14
Ξϯνύλʔϯྫ Public ม Prefab ͷ SerializeField Awake / Start
ิؒؔ Shader
Ξϯνύλʔϯྫ Public ม SerializeField / Prefab Awake / Start
ิؒؔ Shader
PUBLICม ▸ MonoBehaviour ܧঝΫϥεͰSerializeରʹͳΔ ▸ Unity Ͱ Serialize ରʹͳΔͨΊInspector͔Βฤू͕Մೳ
▸ উखʹฤूͤͨ͘͞ͳ͍࣌͋Δ ▸ ֎෦ʹΑΓ؆୯ʹॻ͖͑Մೳ ▸ ϓϩύςΟͰpublic ͳSetter Λఏڙ͍ͯ͠Δ߹ಉ༷ ▸ ΧϓηϧԽ(ใӅṭ)తʹඇৗʹϚζΠ جຊతʹ֎෦ΫϥεʹΑΔૢ࡞ةݥ
PUBLICม ղফ๏ ▸ MonoBehaviour ܧঝΫϥεͰSerializeରʹͳΔ ▸ [SerializeField] private / protected
ʹ͠·͠ΐ͏ ▸ Public มఆٛۃྗආ͚Δ ▸ SDKͱ͔ͰฏؾͰͬͯͨΓ͠·͢ΑͶ…(খ) ▸ ֎෦ʹΑΓ؆୯ʹॻ͖͑Մೳ ▸ Getter ͷެ։OK ▸ Setter ϝιουͰදݱ ▸ τϨʔαϏϦςΟͷ؍ΑΓ ϓϩύςΟΑΓϝιουͷํ͕Φεεϝ
PUBLICม PUBLICมͷར༻έʔε ▸ σʔλߏ (ΤϯςΟςΟ) ͷදݱ ▸ ग़དྷΕGetter/Setter ܦ༝͕·͍͕͠ ߹ʹΑͬͯެ։͠ͳ͚Ε͍͚ͳ͍͜ͱ͋Δ
▸ ΠϯλʔϑΣʔεܦ༝OK ▸ μϛʔίʔυ/αϯϓϧίʔυ࡞࣌ʹ༻͍Δ ▸ ग़དྷΕΘͳ͍ํ͕ྑ͍ ▸ αΫοͱઆ໌͢Δʹ͏͜ͱ͋Δ
Ξϯνύλʔϯྫ Public ม Prefab ͷ SerializeField Awake / Start
ิؒؔ Shader
PUBLICม ͜͜ʹଞऀʹґଘ͍ͯ͠ΔΦϒδΣΫτ͕͋Δ͡ΌΖ
PUBLICม ͜ΕΛPrefabԽͯ͠ಈతੜʹ͠Α͏ͱ͢Δͱ
PUBLICม ͜͏͡Όʂ
PUBLICม ▸ ԿͰ͔ΜͰࢀরΛInspector Ͱͷઃఆͯ͠͠·͏ ▸ ࣗͷPrefabҎ֎ͷཁૉ ▸ ґଘ͕ؔΊͪΌͪ͘Ό ▸
ॳظԽʹऑ͍ ▸ PrefabԽͨ͠ͱ͖ʹґଘ͕ണ͕ΕΔ ▸ ϖλϖλషΔཁૉ͕ଟ͍ͱΞλονҰۤ࿑
PUBLICม ղܾ๏ ▸ Inspector Ͱొ͖͢ͷ ▸ ࣗҎԼͷཁૉ ▸ ಈతੜ͢ΔPrefab ▸
ґଘੑͷղܾ ▸ ͪΌΜͱઃܭ͢Δʂ ▸ Ͳ͏ͯ͠ݫ͍͠߹Zenject ͳͲͷDI ίϯςφΛ༻͍Δ
Ξϯνύλʔϯྫ Public ม Prefab ͷ SerializeField Awake / Start
ิؒؔ Shader
AWAKE / START ▸ ͱΓ͋͑ͣॳظԽAwake/StartͰߦ͏ ▸ ֤ॴͰݺͼ͗ͯ͢Awake ͷ ࣮ߦॱʹґଘੑ͕ੜ͡Δ
▸ Θͳ͍Awake()/Start()/Update() ▸ ͕ଟ͍ͱݺͼग़͠ίετ͕ അࣛʹͳΒͳ͍(ಛʹUpdate)
AWAKE / START ▸ ґଘੑͷ͋ΔॳظԽ ▸ ॳظԽؔΛ༻ҙ͢Δ
▸ ॳظԽॲཧΛཧ͢Δ ͷղফ๏
AWAKE / START ▸ Θͳ͍Awake()/Start()/Update() ▸ ফ͢!! ͷղফ๏
Ξϯνύλʔϯྫ Public ม Prefab ͷ SerializeField Awake / Start
ิؒؔ ໊લۭؒ Shader
ิؒؔ ▸ Ґஔߋ৽Ͱ͜Μͳίʔυ͕ ▸ Lerp/Slerp ֶతʹʮʯΛܭࢉ͢Δؔ
▸ ͔֬ʹdeltaTime ͷׂ߹Ͱগͣͭ͠ඪʹۙͮ͘ ▸ ແݶ͔͚࣌ؒͳ͍ͱ࠷ऴʹͳΒͳ͍ ▸ ͦͦ0.033/0.016 ͣͭۙͮ͘ॲཧద͔ʁ ▸ ॲཧམͪͳͲ͢Δͱׂۙͮ͘߹ಈతʹมΘͬͯ͠·͏
ิؒؔ ▸ Lerp ͷ͍ํΛѲ͢Δ ▸ ͪΌΜͱυΩϡϝϯτΛಡΈ·͠ΐ͏ https://docs.unity3d.com/ja/current/ScriptReference/Vector3.Lerp.html ▸ ୈࡾҾΛ0.0~1.0
ʹมԽ͢Δίʔυʹ͢Δ ex) Coroutine Ͱͷ࣮ྫ ղܾ๏
Ξϯνύλʔϯྫ Public ม Prefab ͷ SerializeField Awake / Start
ิؒؔ Shader
SHADER ▸ ϐΫηϧγΣʔμʔͰॲཧͷॏ͍ؔΛ༻͍Δ ▸ ifจ ▸ ݅ذॏ͍ॲཧ ▸ ࡾ֯ؔ(
Sin,Cos,Tan ) ▸ ܭࢉࣗମ͕ॏ͍ ▸ Log, Sqrt ͳͲ
SHADER ▸ ϐΫηϧγΣʔμʔͰͷॲཧͷॏ͍ؔ ▸ ifจ ▸ ܰྔͳֶؔͰΘΓͷදݱ ex) ceil(clamp(_value,
0, 1)) _value ͕ෛ:0, ਖ਼:1 uvͰv ͕0.5 Ҏ্͔Ͳ͏͔ˠ ceil(clamp(i.uv.y - 0.5, 0, 1)) ▸ ࡾ֯ؔ( Sin,Cos,Tan ) ▸ ࡾ֯ؔςʔϒϧΛ࡞/ςΫενϟʹॻ͖ࠐΜͰ͓͘ ▸ r=Sin, g=Cos, b = Tan ▸ Log, Sqrt ͳͲ ▸ ۃྗΘͳ͍ ▸ Sqrt ͷΘΓʹೋͰൺֱͳͲ ղফ๏
࠷ޙʹ ▸ υΩϡϝϯτͪΌΜͱಡΈ·͠ΐ͏ ▸ Θ͔Βͳ͍͚ͲͬͯΈͨNG ▸ ઃܭΛͪΌΜͱߟ͑·͠ΐ͏ ▸ ಛʹӡ༻ίϯςϯπͳͲޙʑͰͬ͠ฦ͕͖͠·͢ ▸
ٕज़తෛ࠴ͱ͖߹͍·͠ΐ͏ ▸ ύϑΥʔϚϯεΛؾʹ͠·͠ΐ͏ ▸ ৭ʑݕূهࣄͳͲΛ୳ͯ͠Έ·͠ΐ͏ ▸ ͳ͚ΕࣗͰܭଌͯ͠Έ·͠ΐ͏ ▸ ग़དྷΕͦͷ݁ՌΛγΣΞͯ͠Β͑Δͱ ΈΜͳ͕ͤʹͳΓ·͢ ·ͱΊ