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.9k
TrapOfSpriteAtlas
SpriteAtlas の利用上の注意点をまとめました
Cova8bitdots
December 07, 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
StudyUnityFromAnti-pattern
cova8bitdots
0
2.3k
Other Decks in Programming
See All in Programming
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
300
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
[Do iOS '24] Ship your app on a Friday...and enjoy your weekend!
polpielladev
0
110
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.2k
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
340
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
1k
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
230
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.3k
最新TCAキャッチアップ
0si43
0
190
ヤプリ新卒SREの オンボーディング
masaki12
0
130
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
Building Adaptive Systems
keathley
38
2.3k
Unsuck your backbone
ammeep
668
57k
Six Lessons from altMBA
skipperchong
27
3.5k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
What's new in Ruby 2.0
geeforr
343
31k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
A Philosophy of Restraint
colly
203
16k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Building an army of robots
kneath
302
43k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
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 Ͱͷར༻Մೳ ɾམͱ݀͠ʹҾ͔͔ͬΔͱ࠷ѱϏϧυ͢Βग़དྷͳ͘ͳΔ ɾ༻๏ɺ༻ྔਖ਼͍͘͠·͠ΐ͏