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
TrapOfSpriteAtlas
Search
Cova8bitdots
December 07, 2019
Programming
0
4.8k
TrapOfSpriteAtlas
SpriteAtlas の利用上の注意点をまとめました
Cova8bitdots
December 07, 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
StudyUnityFromAnti-pattern
cova8bitdots
0
2.3k
Other Decks in Programming
See All in Programming
カラム追加で増えるActiveRecordのメモリサイズ イメージできますか?
asayamakk
4
1.6k
僕がつくった48個のWebサービス達
yusukebe
18
17k
Kaigi on Rails 2024 - Rails APIモードのためのシンプルで効果的なCSRF対策 / kaigionrails-2024-csrf
corocn
5
3.4k
カスタムしながら理解するGraphQL Connection
yanagii
1
1.2k
破壊せよ!データ破壊駆動で考えるドメインモデリング / data-destroy-driven
minodriven
16
4.1k
Dev ContainersとGitHub Codespacesの素敵な関係
ymd65536
1
130
レガシーな Android アプリのリアーキテクチャ戦略
oidy
1
170
色々なIaCツールを実際に触って比較してみる
iriikeita
0
270
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
350
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
1
290
現場で役立つモデリング 超入門
masuda220
PRO
13
2.9k
Android 15 でアクションバー表示時にステータスバーが白くなってしまう問題
tonionagauzzi
0
140
Featured
See All Featured
A better future with KSS
kneath
238
17k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.2k
Designing for humans not robots
tammielis
249
25k
Music & Morning Musume
bryan
46
6.1k
Code Review Best Practice
trishagee
64
17k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
290
A Philosophy of Restraint
colly
203
16k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Designing the Hi-DPI Web
ddemaree
280
34k
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
Making Projects Easy
brettharned
115
5.9k
Transcript
Unity ͓ɾͱɾͳͷLTେձ 2019 SpriteAtlasͷམͱ݀͠
·͓ͣ͞Β͍ ATLASͬͯͳΜ͚ͩͬʁ ɾAtlas(ਤா) ɹෳը૾ΛύοΫͯ͠Ұͭͷը૾ʹͨ͠ͷ
·͓ͣ͞Β͍ UNITY ʹ͓͚ΔATLAS ɾUnity2017 ͔ΒSpriteAtlas͕ಋೖ͞Εͨ ɹ(SpritePacker ͳΜͯແ͔ͬͨɻ͍͍Ͷʁ) ɾNGUI, TexturePacker ͷ֎෦Ξηοτʹ
ɹཔΒͳͯ͘ྑ͘ͳͬͨ
མͱ݀͠ ࣮ࡍʹͬͯΈͯ (ͬͺΓ) མͱ͕݀͋ͬͨ͠ 1. SpriteAtlasManager ͷΠϕϯτొλΠϛϯά 2. SpriteAtlasͷReleaseλΠϛϯά 3.
Profiler ͷදࣔใ 4. ੩తͳUIͰͷར༻ํ๏ 5. ςΫενϟαΠζ͕ഒ
མͱ݀͠Ϧετ 1. SpriteAtlasManager ͷΠϕϯτొλΠϛϯά 2. SpriteAtlasͷReleaseλΠϛϯά 3. Profiler ͷදࣔใ 4.
੩తͳUIͰͷར༻ํ๏ 5. ςΫενϟαΠζ͕ഒ
SPRITEATLASMANAGER ͷΠϕϯτొλΠϛϯά AwakeͰίʔϧόοΫΛొ 1. ىಈSceneͰSpriteAtlasΛ༻͍Δ 2. Scene ϩʔυ࣌ʹSpriteAtlasManager. atlasRequested͕ݺΕΔ 3.
Awake ͕Δ SpriteAtlasͷϩʔυॲཧ͕Βͳ͍
SPRITEATLASMANAGER ͷΠϕϯτొλΠϛϯά ղܾํ๏ 1. ͦͦBootSceneͱ͔ʹUIΛஔ͔ͳ͍ 2. BootSceneͷલʹPreBootSceneతͳͷΛ༻ҙ 3. [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] ଐੑΛ͚ͭͨϝιουΛ༻ҙͯͦ͜͠ͰίʔϧόοΫΛొ
ͨͩ͠ɺ্هଐੑΛ͚ͭͯϝιουSceneʹ͋Δͳ͍ؔΘΒͣ ίʔϧ͞ΕΔͷͰҙ
མͱ݀͠Ϧετ 1. SpriteAtlasManager ͷΠϕϯτొλΠϛϯά 2. SpriteAtlasͷReleaseλΠϛϯά 3. Profiler ͷදࣔใ 4.
੩తͳUIͰͷར༻ํ๏ 5. ςΫενϟαΠζ͕ഒ
SPRITEATLASͷRELEASEλΠϛϯά ‣ ͋ΔSpriteAtlas ͷඞཁλΠϛϯάSpriteAtlasManager.atlasRequested ͰΘ͔Δ ‣ ͋ΔSpriteAtlas͕ෆཁʹͳΔλΠϛϯάෆ໌ ‣ ΞϓϦʹؚΉϦιʔεͷ߹ Resources.UnloadUnsedAssetsͰղ์Մೳ
‣ AssetBundle, Addressables ͷ߹…
SPRITEATLASͷRELEASEλΠϛϯά ‣ AssetBundle, Addressablesͷ߹ࣗલͰϦιʔεղ์Λ͠ͳ͍ͱNG 1. AtlasొλΠϛϯάͰࣗલͰཧ 2. SceneΓସ͑࣌ʹUnloadΛݺͿ
མͱ݀͠Ϧετ 1. SpriteAtlasManager ͷΠϕϯτొλΠϛϯά 2. SpriteAtlasͷReleaseλΠϛϯά 3. Profiler ͷදࣔใ 4.
੩తͳUIͰͷར༻ํ๏ 5. ςΫενϟαΠζ͕ഒ
PROFILER ͷදࣔใ Α͠ProfilerͰϝϞϦঢ়گݟͯΈΔ͔
PROFILER ͷදࣔใ ͑ʁ॥ࢀরͯ͠ΔΜ͚ͩͲʁ
PROFILER ͷදࣔใ ͔ͬͯΦϒδΣΫτશ෦Destroyͯ͠ UnloadUnusedAssetݺΜͰͬͯΔ
PROFILER ͷදࣔใ ެࣜʹ͍߹Θͤͨ ʻ͜Εόάʁ ҙਤతͰʼ https://docs.unity3d.com/Manual/ProfilerMemory.html ϚχϡΞϧʹ࣮ػͱEditor ҧ͏ͬͯॻ͍ͯΔͬ͠ΐʁ ͏ΜɻΘ͔ͬͨɻ (
… ͍͜Εͯ͠Α)
PROFILER ͷදࣔใ ิɿ ࣮ػͰResourcesݺͼग़͠ͷ߹ UnloadUnsedAssetͰͪΌΜͱϝϞϦ͔Βফ͑Δ༷ ͋͘·ͰEditor࠶ੜ࣌ͷڍಈͷ
མͱ݀͠Ϧετ 1. SpriteAtlasManager ͷΠϕϯτొλΠϛϯά 2. SpriteAtlasͷReleaseλΠϛϯά 3. Profiler ͷදࣔใ 4.
੩తͳUIͰͷར༻ํ๏ 5. ςΫενϟαΠζ͕ഒ
੩తͳUIͰͷར༻ํ๏ AtlasΛηοτͯ͠NGUIͱ͔Έ͍ͨʹ Popup ͰSpriteΛબͼ͍ͨͳ͊ AtlasΛઃఆͰ͖ΔImageΛ֦ுͨ͠ ಠࣗΫϥε࡞ͬͯEditor֦ு͢Δ͔ (Clone) ͍ͬͯͭͯΔ͚ͲઃఆͰ͖ͨΘ
੩తͳUIͰͷར༻ํ๏ UnityΛ࠶ىಈͯ͠ΈΔ ͳΜ͔Ͱͨ Ϗϧυͯ͠ΈΔ Unity2017: ϏϧυΤϥʔ+SceneͷอଘෆՄ Unity2019: Ϗϧυ௨Δ͕SceneͷอଘෆՄ
੩తͳUIͰͷར༻ํ๏ ͍ͦͦํ͕ҧ͏!! SpriteAtlasͷڍಈ 1. ίϯϙʔωϯτʹAtlasΛઃఆ͠ͳͯྑ͍ 2. ैདྷ௨ΓImageʹAtlasʹొͨ͠SpriteຊମΛී௨ʹઃఆͯ͠OK 3. Play࣌/Build࣌ʹ2. ͷSprite͕SpriteAtlasͷࢀরʹஔ͖ΘΔ
Atlas Λొ͖࣌͢ɿ ϥϯλΠϜͰAtlasΛࢀরͯ͠ಈతʹΓସ͍͑ͨ߹
མͱ݀͠Ϧετ 1. SpriteAtlasManager ͷΠϕϯτొλΠϛϯά 2. SpriteAtlasͷReleaseλΠϛϯά 3. Profiler ͷදࣔใ 4.
੩తͳUIͰͷར༻ํ๏ 5. ςΫενϟαΠζ͕ഒ
ςΫενϟαΠζ͕ഒ SpriteAtlas ͱొͨ͠ςΫενϟΛResourcesҎԼʹஔ͍ͨ ྆ํͱΞϓϦʹؚ·ΕͯςΫενϟαΠζ͕ഒ
ςΫενϟαΠζ͕ഒ ॴΛ͚ͯͪΌΜͱཧ͠Α͏ AssetBundle Addressables͚͓ͯ͘ ※Include in Build ͷνΣοΫ֎͢͜ͱ ΞϓϦʹؚΉAtlasResourcesҎԼʹ Atlasʹొ͢Δը૾
Resouces ҎԼʹஔ͔ͳ͍!!
࠷ޙʹ ·ͱΊ ɾམͱ݀͠Λཧղ͢ΕۀͰར༻Մೳ ɹɾAssetBundle/Addressables Ͱͷར༻Մೳ ɾམͱ݀͠ʹҾ͔͔ͬΔͱ࠷ѱϏϧυ͢Βग़དྷͳ͘ͳΔ ɾ༻๏ɺ༻ྔਖ਼͍͘͠·͠ΐ͏