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
24
HandGestureTool for AppleVisionPro
cova8bitdots
0
64
NinjaGazeTyping 制作秘話
cova8bitdots
0
260
UnityとGoogleCloudFunction を連携して社内サービスを作った話
cova8bitdots
0
120
Unity-chan.Terrastal!!
cova8bitdots
0
290
ExampleOfTilemap2D
cova8bitdots
0
84
unity_lt_2021_Dec.pdf
cova8bitdots
0
720
HowToUseAudioMixer
cova8bitdots
0
110
TrapOfSpriteAtlas
cova8bitdots
0
4.9k
Other Decks in Programming
See All in Programming
C++でシェーダを書く
fadis
6
4.1k
Jakarta EE meets AI
ivargrimstad
0
180
CSC509 Lecture 11
javiergs
PRO
0
180
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
170
弊社の「意識チョット低いアーキテクチャ」10選
texmeijin
5
24k
みんなでプロポーザルを書いてみた
yuriko1211
0
260
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
340
Ethereum_.pdf
nekomatu
0
460
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
130
as(型アサーション)を書く前にできること
marokanatani
10
2.7k
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
Building Adaptive Systems
keathley
38
2.3k
Documentation Writing (for coders)
carmenintech
65
4.4k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Speed Design
sergeychernyshev
25
620
Done Done
chrislema
181
16k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
Building Applications with DynamoDB
mza
90
6.1k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
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 ▸ ઃܭΛͪΌΜͱߟ͑·͠ΐ͏ ▸ ಛʹӡ༻ίϯςϯπͳͲޙʑͰͬ͠ฦ͕͖͠·͢ ▸
ٕज़తෛ࠴ͱ͖߹͍·͠ΐ͏ ▸ ύϑΥʔϚϯεΛؾʹ͠·͠ΐ͏ ▸ ৭ʑݕূهࣄͳͲΛ୳ͯ͠Έ·͠ΐ͏ ▸ ͳ͚ΕࣗͰܭଌͯ͠Έ·͠ΐ͏ ▸ ग़དྷΕͦͷ݁ՌΛγΣΞͯ͠Β͑Δͱ ΈΜͳ͕ͤʹͳΓ·͢ ·ͱΊ