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
21
HandGestureTool for AppleVisionPro
cova8bitdots
0
55
NinjaGazeTyping 制作秘話
cova8bitdots
0
260
UnityとGoogleCloudFunction を連携して社内サービスを作った話
cova8bitdots
0
120
Unity-chan.Terrastal!!
cova8bitdots
0
290
ExampleOfTilemap2D
cova8bitdots
0
83
unity_lt_2021_Dec.pdf
cova8bitdots
0
710
HowToUseAudioMixer
cova8bitdots
0
100
TrapOfSpriteAtlas
cova8bitdots
0
4.8k
Other Decks in Programming
See All in Programming
飲食業界向けマルチプロダクトを実現させる開発体制とリアルな現状
hiroya0601
1
390
PagerDuty を軸にした On-Call 構築と運用課題の解決 / PagerDuty Japan Community Meetup 4
horimislime
1
110
Honoの来た道とこれから
yusukebe
19
3k
Universal Linksの実装方法と陥りがちな罠
kaitokudou
1
220
役立つログに取り組もう
irof
26
8.7k
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
390
JaSST 24 九州:ワークショップ(は除く)実践!マインドマップを活用したソフトウェアテスト+活用事例
satohiroyuki
0
260
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
250
[PyCon Korea 2024 Keynote] 커뮤니티와 파이썬, 그리고 우리
beomi
0
110
2万ページのSSG運用における工夫と注意点 / Vue Fes Japan 2024
chinen
3
1.3k
Vue SFCのtemplateでTypeScriptの型を活用しよう
tsukkee
3
1.5k
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
140
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
3
370
Scaling GitHub
holman
458
140k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
22k
Rails Girls Zürich Keynote
gr2m
93
13k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Done Done
chrislema
181
16k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
BBQ
matthewcrist
85
9.3k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Making the Leap to Tech Lead
cromwellryan
132
8.9k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.6k
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 ▸ ઃܭΛͪΌΜͱߟ͑·͠ΐ͏ ▸ ಛʹӡ༻ίϯςϯπͳͲޙʑͰͬ͠ฦ͕͖͠·͢ ▸
ٕज़తෛ࠴ͱ͖߹͍·͠ΐ͏ ▸ ύϑΥʔϚϯεΛؾʹ͠·͠ΐ͏ ▸ ৭ʑݕূهࣄͳͲΛ୳ͯ͠Έ·͠ΐ͏ ▸ ͳ͚ΕࣗͰܭଌͯ͠Έ·͠ΐ͏ ▸ ग़དྷΕͦͷ݁ՌΛγΣΞͯ͠Β͑Δͱ ΈΜͳ͕ͤʹͳΓ·͢ ·ͱΊ