Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AssetBundle と TextureCompression のおはなし

AssetBundle と TextureCompression のおはなし

Tetsuya Mori

October 23, 2013
Tweet

More Decks by Tetsuya Mori

Other Decks in Programming

Transcript

  1. Who am I ? • “৿ɹ఩࠸” ͱਃ͠·͢ɻ • a.k.a. ΋ΜΓ͌

    / T: @monry / F: ຊ໊ • 29ࡀ / ˁ / Oܕ / ఱṝ࠲ / طࠗ / झຯ: ߹ এ • झຯ͸ʮ͓ञʯͱʮ߹এʯͰ͢ɻ
  2. લఏ • େલఏͱͯ͠ɺ2D ͷ͓࿩͠Ͱ͢ʂ • ΋ͬͱݴ͏ͱ NGUI ʹݶఆͯ͠·͢ • iOS

    / Android ͳϞόΠϧ؀ڥ • Unity 4.x (Pro) / NGUI 2.6.x • Pro ൛͡Όͳ͍ͱ AssetBundle Λ Build Ͱ͖ͳ͍ • AssetBundle ͷ࿩͕8ׂͰ͢ :-P • ؒҧͬͨ͜ͱݴ͏͔΋஌Ε·ͤΜ͕ɺποίϛେ׻ܴͰ͢ʂʂ
  3. AssetBundle ͷ֓ཁ • ͦ΋ͦ΋ AssetBundle ͬͯ…ʁ • Asset Λ Bundle

    ͨ͠Ϟϊ • ૉࡐΛవΊͯҰͭͷϑΝΠϧͱͯ͠ѻ͏ ͨΊͷٕज़ • Α͋͘Δॳճμ΢ϯϩʔυͱ͔ • ιγϟήͷΧʔυͷը૾ͱ͔
  4. AssetBundle ͷ௕ॴ • Unity ͕ղऍग़དྷΔϞϊͳΒ٧Ί์୊ • ͨͩ͠ɺiOS ͸ JIT ࣮ߦෆՄ

    • WWW ΫϥεΛܦ༝ͯ͠औಘ • Ωϟογϡͱ͔Α͠ͳʹ΍ͬͯ͘ΕΔ • όʔδϣχϯάʹ΋ରԠ
  5. AssetBundle ͷ୹ॴ • جຊతʹαʔόඞཁ • Content-Type: application/vnd.unity Λཁฦ٫ • ϑΝΠϧ໊ϢχʔΫ

    • basename Ͱ൑ఆ͞ΕΔ • σΟϨΫτϦ۷ͬͯ؅ཧͱ͔ᶡ • ϓϥοτϑΥʔϜຖʹผϑΝΠϧ
  6. AssetBundle ͷ؀ڥ • ॳճϦιʔεμ΢ϯϩʔυ • 2ճ໨Ҏ߱͸ Cache ೚ͤ Amazon S3

    Amazon CloudFront App (Cache) App (Memory) Amazon S3 Amazon CloudFront App (Cache) App (Memory)
  7. AssetBundle ͷ؀ڥ • νʔϜ։ൃ͢ΔͳΒ git Ͱ؅ཧ • όΠφϦ͔ͩΒඍົͬͪΌඍົ • Asset

    Server (ཁ Team License) ΋ΞϦ͔ • Editor Script ඞਢ • άάΕ͹͍ͬͺ͍స͕ͬͯ·͢ • ͜ͷษڧձͷաڈͷηογϣϯʹ΋
  8. AssetBundle ͷ؀ڥ • iOS / Android ͷ྆ํʹରԠͤ͞Δ৔߹ɺ Team License ങͬͱ͚ʂ

    • BuildPipeline.BuildAssetBundle() ͷࡍʹ Import Asset ͕૸ΔͨΊɺϦιʔε਺ ͕ଟ͍ͱΊͬͪΌ଴ͭɻ • ͷͰɺCache Server ඞਢɻ
  9. AssetBundle ͷઃܭ • ཻ౓ (ฐࣾͷ৔߹) • Atlas / Texture /

    AudioClip ΛݸผʹϏϧυ • 1ը໘ (≠γʔϯ) ಺ʹ࠷େ10ݸΛ໨҆ • ॳճDL࣌ͷΩϟογϡʹ݁ߏґଘ • Ͳ͏ʹ͔͍ͨ͠Μ͚ͩͲͶ…ɻ
  10. AssetBundle ͷઃܭ • ߋ৽ස౓ (ฐࣾͷ৔߹) • ݪଇతʹ iOS ͷਃ੥εέδϡʔϧ͕ج ४

    • ͦ΋ͦ΋ߋ৽ස౓͕ߴ͍Ϟϊ͸ API ͱ ͔ܦ༝ͨ͠ํ͕؅ཧָ͕ • BASE64 ͳςΩετΛ৯ΘͤΔͱ͔
  11. AssetBundle ͷઃܭ • ॳճDL͢ΔωλҰཡ (ฐࣾͷ৔߹) • ׶͑ͯΞϓϦ಺ (Assets/Resources/) ʹ .txt

    (TSV ͳ TextAsset) Λอ࣋ • ϑΝΠϧ໊<TAB>όʔδϣϯ<LF> • ຖճىಈ࣌ʹ͜ͷϦετΛνΣοΫ • WWW.LoadFromCacheOrDownload ʹ೚ͤͯ Cache ͕༗͢ΔόʔδϣϯͱҟͳΔͳΒ DL
  12. AssetBundle ͷߏங • Editor Script Ͱ͕Μ͹Δɻ Supporting Files/  種別/   シーン名/

       画面名/     ファイル名 ͜ͷߏ଄ܾΊଧͪͰσΟϨΫτϦ಺ͷ ϑΝΠϧΛ૸ࠪ
  13. AssetBundle ͷ഑৴ • S3 Λ Origin ͱͨ͠ CloudFront • “όʔδϣϯ൪߸/ϓϥοτϑΥʔϜ/”

    ͳ σΟϨΫτϦҎԼʹ഑ஔ • Editor Script Ͱॻ͖ग़ͨ͠σΟϨΫτϦ Λؙͬͱ PUT ग़དྷΔͱָͪΜ
  14. ஫ҙ఺ • ద੾ͳࠩ෼ϏϧυΛߦΘͳ͍ͱμϝ • Կ͔ྑ͍Ҋແ͍͔ͬ͢ʁ͆ • WWW ͸λΠϜΞ΢τͷ࣮૷͕ແ͍ͷͰɺࣗલ Ͱ૊Ήඞཁ͋Γ •

    CloudFront ࢖͏৔߹ɺ։ൃத͸ Origin ͔Β௚઀ DL ͨ͠ํ͕ྑ͍ • CF ଆͷ Cache Invalidation ͱ͔େมͩ͠ɻ
  15. Texture Compression • Ͱɺ࠷దͳͷ͸ʁ • iOS ͸ PowerVR (PVR) ʹ͠ͱ͚͹

    OK • RGBA Compressed PVRTC 4 bits
 ͕Φεεϝ • ͩ͜ΘΔͳΒ Texture ผʹ࣮ػͰݟ ͭͭద੾ʹબΜͰͶ
  16. Texture Compression • WebPlayer / Standalone / etc… ͸ʁ •

    ·ͩ࡞ͬͨ͜ͱແ͍ͷͰ෼͔Γ·ͤ Μʂ (ŝžŕ • ೡΖ৘ใަ׵͠·͠ΐ͏ʂ
  17. ·ͱΊ • AssetBundle • Editor Script ͕؊ཁ • ͪΌΜͱӡ༻ݟਾ͑ͯઃܭ͢΂͠ •

    Texture Compression • Android ͷαϙʔτ࣍ୈ • υϥεςΟοΫͳ൑அ΋ඞཁ͔΋