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

複雑化するAssetBundleの配信からロードまでを基盤化した話/CEDEC2017

QualiArts
August 30, 2017

 複雑化するAssetBundleの配信からロードまでを基盤化した話/CEDEC2017

http://cedec.cesa.or.jp/2017/session/PRD/s58e06b7e0013a/
https://cedil.cesa.or.jp/cedil_sessions/view/1638
Unityを利用する多くの会社がAssetBundleの管理に頭を悩ませているのではないでしょうか?私たちはそれらの処理を社内の共通基盤化し、開発の大幅効率化を実現しました。
本セッションではどのようにしてその基盤を作ったのか、配信方法からクライアントのSDK内部で行っている処理までを紹介します。
スケーラブルなサーバの実装から効率的なAssetのロードまでABの管理の全体を解説します。

QualiArts

August 30, 2017
Tweet

More Decks by QualiArts

Other Decks in Technology

Transcript

  1. AssetBundleͷ໰୊ ؅ཧ - ੈ୅؅ཧ͕ࠔ೉
 - Assetͷྔ͕ଟ͍ͷͰ؅ཧ͕େม ΫϥΠΞϯτ - ಉҰAssetBundle͸ෳ਺ಉ࣌ʹϩʔυͰ͖ͳ͍
 -

    ୺຤ʹΩϟογϡࡁΈͷݹ͍AssetBundleΛ࡟আ͢Δखஈ͕ެࣜʹ͸ແ͍ ֤λΠτϧͰݸผʹ։ൃ͍͕ͯͨ͠ɺࣗࣾͰج൫Λ։ൃ͢Δ͜ͱʹɻ 11
  2. ࠓ·ͰͷήʔϜ 12 σβΠφʔ SVN jenkins AssetBundle build Game Server ΞϓϦ

    σβΠφʔ SVN jenkins AssetBundle build Game Server ΞϓϦ
  3. ࣮ݱΠϝʔδ 13 σβΠφʔ σβΠφʔ SVN jenkins AssetBundle build Game Server

    ΞϓϦ Assetbundle ഑৴ج൫ SDK Game Server ΞϓϦ SDK ΞϓϦ SDK Game Server CLI ؅ཧը໘
  4. αʔόઃܭ 19 σβΠφʔ σβΠφʔ SVN jenkins AssetBundle build Game Server

    ΞϓϦ Assetbundle ഑৴ج൫ SDK Game Server ΞϓϦ SDK ΞϓϦ SDK Game Server CLI ؅ཧը໘
  5. ಥൃతͳτϥϑΟοΫ ӡ༻Λָʹ͍ͨ͠
 - ߏ੒؅ཧ͕ෆཁ
 - ٕज़ͷशಘίετ γϯϓϧ
 - DockerFileͷΈ
 -

    ։ൃ͔Βຊ൪·ͰมΘΒͳ͍؀ڥ GKE͕࢖͍͍ͨʂ 27 ίϯςφܕԾ૝ԽγεςϜDockerΛ࠾༻ͨ͠ཧ༝
  6. ಥൃతͳτϥϑΟοΫ ϚωʔδυαʔϏε
 - Ϋϥελͷ؅ཧ ؂ࢹ
 - StackDriverͱͷ࿈ܞ ϩά
 - CloudLogging

    OSS
 - ๛෋ͳ৘ใ
 - ׆ൃͳίϛϡχςΟ 28 GoogleContainerEngine Google Container EngineΛ࠾༻ͨ͠ཧ༝
  7. AssetBundleͷੈ୅؅ཧ 33 ϑΝΠϧA 1 શମ 0 શମ 1 ϑΝΠϧB 1

    ϑΝΠϧAͱϑΝΠϧBΛ௥ՃɺϦϏδϣϯ͸̍ʹ
  8. AssetBundleͷੈ୅؅ཧ 34 ϑΝΠϧA 1 શମ 0 શମ 1 ϑΝΠϧB 1

    ϑΝΠϧA 1 શମ 2 ϑΝΠϧB 1 ϑΝΠϧC 2 ϑΝΠϧCΛ௥ՃɺϦϏδϣϯ͸̎ʹ
  9. AssetBundleͷੈ୅؅ཧ 35 ϑΝΠϧA 1 શମ 0 શମ 1 ϑΝΠϧB 1

    ϑΝΠϧA 1 શମ 2 ϑΝΠϧB 1 ϑΝΠϧC 2 ϑΝΠϧA 3 શମ 3 ϑΝΠϧB 1 ϑΝΠϧC 2 ϑΝΠϧAΛߋ৽ɺϦϏδϣϯ͸̏ʹ
  10. AssetBundleͷੈ୅؅ཧ 36 ϑΝΠϧA 1 શମ 0 શମ 1 ϑΝΠϧB 1

    ϑΝΠϧA 1 શମ 2 ϑΝΠϧB 1 ϑΝΠϧC 2 ϑΝΠϧA 3 શମ 3 ϑΝΠϧB 1 ϑΝΠϧC 2 ϑΝΠϧA 3 શମ 4 ϑΝΠϧB 4 ϑΝΠϧC 2 ϑΝΠϧD 4 ϑΝΠϧBΛߋ৽ɺϑΝΠϧDΛ௥ՃɺϦϏδϣϯ͸̐ʹ
  11. AssetBundleͷੈ୅؅ཧ 37 ϑΝΠϧA 3 શମ 4 ϑΝΠϧB 4 ϑΝΠϧC 2

    ϑΝΠϧD 4 ୺຤ 0 ͢΂ͯͷϑΝΠϧΛऔಘ
  12. AssetBundleͷੈ୅؅ཧ 38 ϑΝΠϧA 3 શମ 4 ϑΝΠϧB 4 ϑΝΠϧC 2

    ϑΝΠϧD 4 ୺຤ 0 ୺຤ 2 ϦϏδϣϯ̏Ҏ্Λऔಘ
  13. AssetBundleͷੈ୅؅ཧ 39 ϑΝΠϧA 3 શମ 4 ϑΝΠϧB 4 ϑΝΠϧC 2

    ϑΝΠϧC 4 ୺຤ 0 ୺຤ 2 ୺຤ 4 Կ΋औಘ͠ͳ͍
  14. ࣮ݱΠϝʔδ 42 σβΠφʔ σβΠφʔ SVN jenkins AssetBundle build Game Server

    ΞϓϦ Assetbundle ഑৴ج൫ SDK Game Server ΞϓϦ SDK ΞϓϦ SDK Game Server CLI ؅ཧը໘
  15. CLI 43 σβΠφʔ σβΠφʔ SVN jenkins AssetBundle build Game Server

    ΞϓϦ Assetbundle ഑৴ج൫ SDK Game Server ΞϓϦ SDK ΞϓϦ SDK Game Server CLI ؅ཧը໘ Command Line Interface $ AssetBundleΛUpload͢Δػೳ $ AssetBundleʹTagΛ͚ͭΔػೳ $ AssetBundleͷࠩ෼Λ֬ೝ͢Δػೳ . . .
  16. ؅ཧπʔϧ 44 σβΠφʔ σβΠφʔ SVN jenkins AssetBundle build Game Server

    ΞϓϦ Assetbundle ഑৴ج൫ SDK Game Server ΞϓϦ SDK ΞϓϦ SDK Game Server CLI ؅ཧը໘
  17. DevɺStgɺPrd 48 ֤؀ڥͷ໾ׂ AssetBundleͷಈ͖ OCTO-Dev 9/1 ϦϦʔε GameDev 9/3 ϦϦʔε

    GameDev 9/7 ϦϦʔε GameDev 10/1 ϦϦʔε GameDev OCTO-Stg OCTO-Prd Jenkins Upload Copy Sync ɾɾɾ GameStg GamePrd
  18. Copy 49 OCTO-Dev 9/1 ϦϦʔε GameDev 9/3 ϦϦʔε GameDev 9/7

    ϦϦʔε GameDev 10/1 ϦϦʔε GameDev OCTO-Stg OCTO-Prd Jenkins Upload Copy Sync ɾɾɾ GameStg GamePrd
  19. Copy 50 ؀ڥ̍ fileA www.example.com/fileA revision:1 fileB www.example.com/fileB revision:2 fileC

    www.example.com/fileC revision:3 fileD www.example.com/fileD revision:4 fileA www.example.com/fileA revision:1 ؀ڥ̎
  20. Copy 51 ؀ڥ̍ fileA www.example.com/fileA revision:1 fileB www.example.com/fileB revision:2 fileC

    www.example.com/fileC revision:3 fileD www.example.com/fileD revision:4 fileA www.example.com/fileA revision:1 fileB www.example.com/fileB revision:2 fileD www.example.com/fileD revision:2 ؀ڥ̎ revision͸৽ͨʹৼΒΕΔ͕ࢀরϑΝΠϧ͸ಉҰ
 ඞཁͳAsset͚ͩΛϐοΫΞοϓՄೳ
  21. Sync 52 OCTO-Dev 9/1 ϦϦʔε GameDev 9/3 ϦϦʔε GameDev 9/7

    ϦϦʔε GameDev 10/1 ϦϦʔε GameDev OCTO-Stg OCTO-Prd Jenkins Upload Copy Sync ɾɾɾ GameStg GamePrd
  22. Sync 53 ؀ڥ̍ fileA www.example.com/fileA revision:1 fileB www.example.com/fileB revision:1 fileC

    www.example.com/fileC revision:2 fileD www.example.com/fileD revision:3 fileE www.example.com/fileE revision:3 fileA www.example.com/fileA revision:1 fileB www.example.com/fileB revision:1 ؀ڥ̎
  23. Sync 54 ࠩ෼Λrevision΋ؚΊͯ׬શʹίϐʔ
 ςετ׬ྃͨ͠΋ͷΛݶΓͳ͘ಉ͡ঢ়ଶͰຊ൪ʹίϐʔͰ͖Δɻ fileA www.example.com/fileA revision:1 fileB www.example.com/fileB revision:1

    fileC www.example.com/fileC revision:2 fileD www.example.com/fileD revision:3 fileE www.example.com/fileE revision:3 fileA www.example.com/fileA revision:1 fileB www.example.com/fileB revision:1 fileC www.example.com/fileC revision:2 fileD www.example.com/fileD revision:3 fileE www.example.com/fileE revision:3 ؀ڥ̍ ؀ڥ̎
  24. ·ͱΊ 55 CopyͱSyncػೳΛ࢖͍෼͚Δ͜ͱͰϑϨΩγϒϧͳӡ༻͕Մೳʹ ϛε΋ൃੜ͠ʹ͍͘ OCTO-Dev 9/1 ϦϦʔε GameDev 9/3 ϦϦʔε

    GameDev 9/7 ϦϦʔε GameDev 10/1 ϦϦʔε GameDev OCTO-Stg OCTO-Prd Jenkins Upload Copy Sync ɾɾɾ GameStg GamePrd
  25. Unity SDK ΞδΣϯμ 1. ͸͡Ίʹ a. ΫϥΠΞϯτ՝୊ b. ඞཁͳػೳ c.

    ։ൃϙϦγʔ 2. ॳظԽ 3. AssetBundleϩʔυ 4. ௨৴શൠ 5. ௨৴API 58
  26. Unity SDK ΞδΣϯμ 1. ͸͡Ίʹ 2. ॳظԽ a. ॳظԽͷྲྀΕ b.

    ϩʔΧϧDB c. Ωϟογϡ؅ཧ 3. AssetBundleϩʔυ 4. ௨৴શൠ 5. ௨৴API 67
  27. ΫϥΠΞϯτ Ωϟογϡ ϩʔΧϧ%# 0$50
 6OJUZ4%, ಡΈॻ͖ ݕࡧΠϯσοΫε "TTFU#VOEMF ϝλσʔλ "TTFU#VOEMF

    (PPHMF$MPVE4UPSBHF SDKॳظԽ 68 ετϨʔδ ॳظԽͰ΍͍ͬͯΔ͜ͱ • ϩʔΧϧDBϩʔυɾߋ৽ • Ωϟογϡ૸ࠪ
  28. ΫϥΠΞϯτͷॳظԽͷྲྀΕ 69 4%, ϩʔΧϧ%#ʹؔ͢Δॲཧ Ωϟογϡʹؔ͢Δॲཧ ΞϓϦىಈ 4%,
 ॳظԽ ϩʔΧϧ%# ಡΈࠐΈ

    ࠷৽ࠩ෼औಘ ϩʔΧϧ%#
 ߋ৽ Ωϟογϡ
 ૸ࠪ Ωϟογϡ
 ൃݟ ΠϯσοΫε ొ࿥ Ωϟογϡ
 ࡟আ ਖ਼ৗ ҟৗ ݟ͔ͭΒͳ͘ͳΔ·Ͱϧʔϓ
  29. ΫϥΠΞϯτͷॳظԽͷྲྀΕ 70 4%, ϩʔΧϧ%#ʹؔ͢Δॲཧ Ωϟογϡʹؔ͢Δॲཧ ΞϓϦىಈ 4%,
 ॳظԽ ϩʔΧϧ%# ಡΈࠐΈ

    ࠷৽ࠩ෼औಘ ϩʔΧϧ%#
 ߋ৽ Ωϟογϡ
 ૸ࠪ Ωϟογϡ
 ൃݟ ΠϯσοΫε ొ࿥ Ωϟογϡ
 ࡟আ ਖ਼ৗ ҟৗ ݟ͔ͭΒͳ͘ͳΔ·Ͱϧʔϓ
  30. ϩʔΧϧDBͱ͸ʁ ΞϓϦͰ࢖͏શͯͷAssetBundleͳͲͷϝλσʔλΛੈ୅؅ཧ͢ΔDB • OCTOಠࣗ৘ใ ◦ ID ◦ λά৘ใ ◦ ঢ়ଶɿ৽نɾߋ৽ɾ࡟আ

    • AssetBundle৘ใ ◦ ґଘؔ܎ ◦ Unity AssetBundle CRC • ϑΝΠϧ৘ใ ◦ ϑΝΠϧαΠζ ◦ MD5ϋογϡ 71
  31. • byte[]͸ࢀরܕͰ͋ΔͨΊʢΞυϨε෼ʣ • ഑ྻࣗମͷΦʔόʔϔου • ϝϞϦΞϥΠϝϯτ౎߹ͷύσΟϯά ͳͥ૝ఆΑΓແବ͕ଟ͍͔ʁ 75 class Hoge

    { byte[] md5 = new byte[16]; } Πϯελϯε Φʔόʔϔου CZUFT CZUF<> CZUFT CZUF<> ΞυϨε CZUFT Πϯελϯε Φʔόʔϔου CZUFT ܕ৘ใ 5ZQF CZUFT ௕͞ JOU CZUFT QBEEJOH CZUFT ϝϞϦ
 ώʔϓྖҬ )PHFCZUFT CZUF<>CZUFT CZUF<> ΞυϨε CZUFT Πϯελϯε Φʔόʔϔου CZUFT ܕ৘ใ 5ZQF CZUFT ௕͞ JOU CZUFT QBEEJOH CZUFT ࢀর ແବͳ෦෼
  32. • ϑΟʔϧυͱͯ͠ͷstruct͸ɺHogeʹ಺แ͞ΕΔͨΊΦʔόʔϔουແ͠ • ݻఆ௕഑ྻͷ୅ΘΓʹɺྗٕͰ1όΠτͣͭల։͢Δ structͰ࠷దԽ͢Δͱ 76 class Hoge { MD5Struct

    md5; } struct MD5Struct { byte b0, b1, b2, …, b15; } Πϯελϯε Φʔόʔϔου CZUFT ϝϞϦ
 ώʔϓྖҬ )PHFCZUFT .%4USVDUCZUFT C  C  C  C  C  C  C  C  C  C  C   C   C   C   C   C  
  33. ΫϥΠΞϯτͷॳظԽͷྲྀΕ 77 4%, ϩʔΧϧ%#ʹؔ͢Δॲཧ Ωϟογϡʹؔ͢Δॲཧ ΞϓϦىಈ 4%,
 ॳظԽ ϩʔΧϧ%# ಡΈࠐΈ

    ࠷৽ࠩ෼औಘ ϩʔΧϧ%#
 ߋ৽ Ωϟογϡ
 ૸ࠪ Ωϟογϡ
 ൃݟ ΠϯσοΫε ొ࿥ Ωϟογϡ
 ࡟আ ਖ਼ৗ ҟৗ ݟ͔ͭΒͳ͘ͳΔ·Ͱϧʔϓ
  34. Unity SDK ΞδΣϯμ 1. ͸͡Ίʹ 2. ॳظԽ 3. AssetBundleϩʔυ a.

    ྲྀΕ b. ϩʔυ؅ཧ c. Resourceػೳ 4. ௨৴શൠ 5. ௨৴API 81
  35. AssetBundleϩʔυ·ͰͷྲྀΕ 82 ϩʔυ؅ཧ "TTFU#VOEMF
 ϩʔυϦΫΤετ Ωϟογϡ ࡁΈ͔Ͳ͏͔ʁ "TTFU#VOEMF
 μ΢ϯϩʔυ Ωϟογϡʹ


    อଘ Ωϟογϡ
 ͔Βϩʔυ "TTFU#VOEMF ϝϞϦొ࿥ "TTFU#VOEMF
 Ξϯϩʔυ :&4 /0 ϩʔυࡁΈ͔
 Ͳ͏͔ʁ /0 ϝϞϦ͔Β
 "TTFU#VOEMFऔಘ :&4 ήʔϜʹ
 "TTFU#VOEMF౉͢ ඞཁͳ͚Ε͹
  36. ϩʔυ؅ཧͷख๏ ࢀর਺Ͱࣗಈతʹղ์؅ཧ ࢀর਺㲈ϩʔυ͠Α͏ͱͨ͠ճ਺ - Ξϯϩʔυ͠Α͏ͱͨ͠ճ਺ • Unityʹ͸ɺಉ͡AssetBundleΛผʹϩʔυͯ͠͸͍͚ͳ੍͍໿͕͋Δ ◦ طʹϩʔυࡁΈͷ৔߹͸ɺΩϟογϡ͍ͯ͠ΔAssetBundleΛฦ͢ •

    ࢀর਺ΛΧ΢ϯτ͠ɺࢀর͕0ʹͳͬͨΒΞϯϩʔυ͢ΔΑ͏ʹ • GameObjectͷੜࢮʹ࿈ಈͤͯ͞ɺࢀর਺Λ૿ݮͤ͞Δิॿ༻ͷίϯϙʔωϯτ 83 Asset
 Bundle Game
 Object ࢀর਺ʹ3
  37. Unity SDK ΞδΣϯμ 1. ͸͡Ίʹ 2. ॳظԽ 3. AssetBundleϩʔυ 4.

    ௨৴શൠ a. δϨϯϚ b. λΠϜΞ΢τ੍ޚ 5. ௨৴API 85
  38. ௨৴λΠϜΞ΢τͷ໰୊ 87 60ඵλΠϜΞ΢τͰ50MBͷϑΝΠϧΛμ΢ϯϩʔυ͢Δ৔߹ 10Mbps
 (஗Ίͷ4G૝ఆ) 2Mbps
 (3G૝ఆ) 40ඵ 200ඵ λΠϜΞ΢τϧʔϓ

    ௨৴ͷλΠϜΞ΢τΛઈର͚࣌ؒͩͰߦ͏ͱɺ
 େ͖͍ϑΝΠϧΛ௿଎ͳ௨৴؀ڥͰμ΢ϯϩʔυ׬ྃͰ͖ͳ͘ͳΔ໰୊͕͋Δ
  39. Unity SDK ΞδΣϯμ 1. ͸͡Ίʹ 2. ॳظԽ 3. AssetBundleϩʔυ 4.

    ௨৴શൠ 5. ௨৴API a. APIͷબ୒ࢶͱಛ௃ b. ޮ཰తͳϑΝΠϧμ΢ϯϩʔυ c. APIͷ࢖͍෼͚ 89
  40. ௨৴APIͷ࢖͍෼͚ 102 ωΠςΟϒϓϥάΠϯ UnityWebRequest֦ு UnityWebRequest ϑΝΠϧʹอଘ͢Δ
 ύϑΥʔϚϯε ̋ ˚ ✕

    ϑΝΠϧʹอଘ͠ͳ͍
 ύϑΥʔϚϯε ˚ ˚ ˚ ࣮૷ίετ ✕ ˚ ̋ ϑΝΠϧʹอଘ͢Δ ϑΝΠϧʹอଘ͠ͳ͍ iOS/Android ωΠςΟϒϓϥάΠϯ UnityWebRequest ͦͷଞ UnityWebRequest֦ு
  41. SDKฤ·ͱΊ • શମ ◦ ٕज़νϟϨϯδ ◦ ύϑΥʔϚϯε޲্͸Ϣʔβʔମݧ޲্ʹܨ͕Δ • ୺຤ϩʔΧϧ؅ཧ ◦

    ϝλσʔλΛಠࣗ؅ཧ͢Δ͜ͱͰɺॊೈͳੈ୅؅ཧ͕Մೳʹ ◦ ಠࣗͷΩϟογϡ؅ཧʹΑͬͯɺήʔϜͷࣗ༝౓޲্ • ௨৴ ◦ ωΠςΟϒϓϥάΠϯͰޮ཰తͳϑΝΠϧμ΢ϯϩʔυ͕Ͱ͖ͨ ◦ جຊ͸UnityWebRequestͰ໰୊ͳ͠ ※௨৴APIͷݕূৄࡉ͸ԼهαΠόʔΤʔδΣϯτެࣜΤϯδχΞϒϩάʹͯ
 ʮUnityʹ͓͚Δ௨৴APIΛ৭ʑࢼͯ͠᠘Λ౿Μͩ࿩ʯ
 https://developers.cyberagent.co.jp/blog/archives/6649/ 103