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

あらためて AssemblyDefinition についてまとめてみた/About AssemblyDefinition

あらためて AssemblyDefinition についてまとめてみた/About AssemblyDefinition

2018/07/25 (Wed) に開催された Gotanda.unity #7 での登壇資料です。

P.29, P.37, P.41 の画像については、 http://monry.hatenablog.com/entry/2018/07/26/124434 にて Animated GIF を公開しています。

7b13f432547b92d04c79b749adb535e0?s=128

Tetsuya Mori

July 25, 2018
Tweet

Transcript

  1. גࣜձࣾΩοζελʔ CTO ৿ɹ఩࠸ ͋ΒͨΊͯ Assembly Definition ʹ͍ͭͯ·ͱΊͯΈͨ - Ԟٛʂ͋ͤΜͿΓ͌Ͱ͌;͌ʹ͡ΐΜ!! -

  2. 2 ͜Μ͹Μ͸ʂ

  3. 3 ಥવͰ͕͢

  4. 4 Assembly Definition ͔ͭͬͯ·͔͢ʁ

  5. 5

  6. 6 { "name": "kidsstar@pretendland", "references": [ "kidsstar@firebase_utility_lifecyclehandler", "kidsstar@pretendland_common_dialog", "kidsstar@pretendland_common_downloader", "kidsstar@pretendland_common_pavilionloader",

    "kidsstar@pretendland_common_projects", "umm@assetbundle_management", "umm@cafu_core", "umm@cafu_generics", "umm@cafu_routing", "umm@commandline_arguments", "umm@context_management", "umm@git", "umm@jenkins", "umm@project_setting", "umm@singleton_monobehaviour", "umm@unirx", "umm@unirx_observablelifecyclemonobehaviour", "umm@unirx_observableunitywebrequest", "umm@xcode_manipulation_api", "pretendland_academy", "pretendland_ecc", "pretendland_gummi", "pretendland_ippudo", "pretendland_kao", "pretendland_nissincisco", "pretendland_sugi", "pretendland_sushiro" ], "optionalUnityReferences": [], "includePlatforms": [], "excludePlatforms": [], "allowUnsafeCode": false }
  7. 7 ։ൃ࣌ͷίϯύΠϧ͕଎͘ͳΔ
 ʢ͔΋͠Εͳ͍ʣ
 Assembly Definition
 ʹ͍ͭͯղઆ͠·͢ʂ

  8. ࣗݾ঺հ 8

  9. w৿ɹ఩࠸ʢBLB΋ΜΓ͌ઌੜʣ w೥࡛ۄݝ࢈ wגࣜձࣾΩοζελʔ$50 wࠓ݄ࡀʹͳΔ່ʹκοίϯ-07& w͓ञͱ߹এͱϓϩάϥϛϯά͕झຯ w5XJUUFS!NPOSZ(JU)VC!NPOSZ 9 Who am I

    ? ࣗݾ঺հ
  10. 10 Who am I ? ϚϯΨͰΘ͔Δ6OJUZ޷ධ࿈ࡌதʂ ࣗݾ঺հ

  11. w ࢠͲ΋޲͚εϚϗΞϓϦ
 ։ൃͳͲ w ೥͋ͨΓ͔Β
 6OJUZΨοπϦ w ͬ͜͝ϥϯυ
 ྦྷܭສ%- w

    "QQ4UPSF(PPHMF1MBZ
 ʹͯࢠͲ΋޲͚ΧςΰϦ
 ϥϯΩϯά501 11 ͓͠͝ͱ ࣗݾ঺հ
  12. ΞδΣϯμ 12

  13. w"TTFNCMZ%FpOJUJPOͱ͸ʁ w"TTFNCMZ%FpOJUJPOͷ࢖͍ํ w"TTFNCMZ%FpOJUJPOͷ5JQT 13 ͓͠ͳ͕͖ ΞδΣϯμ

  14. w"TTFNCMZ%FpOJUJPOͱ͸ʁ w"TTFNCMZ%FpOJUJPOͷ࢖͍ํ w"TTFNCMZ%FpOJUJPOͷ5JQT 14 ͓͠ͳ͕͖ ΞδΣϯμ

  15. Assembly Definition ͱ͸ʁ 15

  16. 16 Assembly
 Λ
 Definition
 ͢ΔͨΊͷػೳ

  17. 17 Assembly ? Assembly Definition ͱ͸ʁ ग़య.4%/ʮ/&5ͷΞηϯϒϦͱ໊લۭؒͷཧղͱ࢖༻ʯ lΞηϯϒϦ͸ɺػೳͷ࿦ཧత୯ҐΛ
 ߏ੒͢ΔܕͱϦιʔεͷू·ΓͰ͢ɻz

  18. 18 Assembly ? Assembly Definition ͱ͸ʁ wૈ͘ݴ͑͹ʮϓϩάϥϜͷմʯ w"TTFNCMZ%FpOJUJPO͸ɺ
 ͜ͷմΛ࡞ΔͨΊͷઃఆϑΝΠϧ

  19. 19 Կ͕خ͍͠ͷʁ Assembly Definition ͱ͸ʁ wίϯύΠϧ࣌ؒͷ୹ॖ wϞδϡʔϧͷૄ݁߹Խʢ෭࣍తʣ

  20. 20 Assembly Definition ͷجຊ Assembly Definition ͱ͸ʁ w6OJUZͰ௥Ճ w5FTU"TTFNCMJFTͱ͔VOTBGFίʔυ ͱ͔ͷରԠ͸6OJUZ͔Β

  21. 21 Assembly Definition ͷجຊ Assembly Definition ͱ͸ʁ hoge.asmdef ⚙ hoge.dll

  22. 22 Assembly Definition ͷجຊ Assembly Definition ͱ͸ʁ Assets/ ├hoge.asmdef ├Foo.cs

    └Fuga/ └Bar.cs ⚙ hoge.dll
  23. 23 Assembly Definition ͷجຊ Assembly Definition ͱ͸ʁ Assets/ ├hoge.asmdef ├Foo.cs

    └Fuga/ ├fuga.asmdef └Bar.cs ⚙ hoge.dll ⚙ fuga.dll
  24. 24 ίϯύΠϧ࣌ؒͷ୹ॖʁ Assembly Definition ͱ͸ʁ 㱺

  25. ίϯύΠϧ࣌ؒͷ୹ॖʁ Assembly Definition ͱ͸ʁ wεΫϦϓτͷมߋΛݕ஌͢Δͱ
 ౎౓"TTFNCMZ$4IBSQEMMͱ͍͏
 ڊେͳEMMʹίϯύΠϧ͠௚͍ͯͨ͠ w"TTFNCMZ͕෼͔ΕΔͱɺ
 มߋͱ͸ແؔ܎ͳ"TTFNCMZͷ
 ίϯύΠϧ͕ߦΘΕͳ͘ͳΔ

  26. 26 Ϟδϡʔϧͷૄ݁߹Խʁ Assembly Definition ͱ͸ʁ wࠓ·Ͱ͸୯Ұͷ"TTFNCMZʹ
 શεΫϦϓτؚ͕·Ε͍ͯͨͷͰɺ
 ϥΠϒϥϦ։ൃऀ͕ҙਤ͠ͳ͍
 ࢀরͳͲ΋Մೳͩͬͨ w"TTFNCMZΛ෼ׂ͢Δ͜ͱͰɺ


    ҙਤ͠ͳ͍ࢀরΛߦ͑ͳ͘ͳΔͷͰ
 ݁Ռͱͯ͠ૄ݁߹Խʹܨ͕Δʢ͜ͱ΋͋Δʣ
  27. w"TTFNCMZ%FpOJUJPOͱ͸ʁ w"TTFNCMZ%FpOJUJPOͷ࢖͍ํ w"TTFNCMZ%FpOJUJPOͷ5JQT 27 ͓͠ͳ͕͖ ΞδΣϯμ

  28. Assembly Definition ͷ࢖͍ํ 28

  29. 29 .asmdef ϑΝΠϧΛ࡞Δ Assembly Definition ͷ࢖͍ํ

  30. 30 .asmdef ϑΝΠϧΛ࡞Δ Assembly Definition ͷ࢖͍ํ Ҏ্ɻ

  31. 31 AD ొ৔લ Assembly Definition ͷ࢖͍ํ •Assembly-CSharp.dll •Assets/**/*.cs •Assembly-CSharp-Editor.dll •Assets/**/Editor/**/*.cs

    •Assembly-CSharp-firstpass.dll •Assets/Plugins/**/*.cs •Assembly-CSharp-Editor-firstpass.dll •Assets/Plugins/**/Editor/**/*.cs
  32. 32 AD ొ৔લ Assembly Definition ͷ࢖͍ํ

  33. 33 AD ొ৔ޙ Assembly Definition ͷ࢖͍ํ •Assembly-CSharp.dll •.asmdef ͕ଘࡏ͠ͳ͍σΟϨΫτϦҎԼͷ *.cs

    •<Assembly>.dll •Assets/**/<Assembly>.asmdef
 ͱಉ֊૚σΟϨΫτϦҎԼͷ*.cs
  34. 34 AD ొ৔ޙ Assembly Definition ͷ࢖͍ํ

  35. 35 AD ొ৔ޙ Assembly Definition ͷ࢖͍ํ

  36. 36 ґଘ؅ཧ Assembly Definition ͷ࢖͍ํ ͋Δ"TTFNCMZ͸ ଞͷ"TTFNCMZͷ ΫϥεΛඞཁͱ͢Δ ґଘ

  37. 37 ґଘ؅ཧ Assembly Definition ͷ࢖͍ํ

  38. w"TTFNCMZ%FpOJUJPOͱ͸ʁ w"TTFNCMZ%FpOJUJPOͷ࢖͍ํ w"TTFNCMZ%FpOJUJPOͷ5JQT 38 ͓͠ͳ͕͖ ΞδΣϯμ

  39. Assembly Definition ͷ Tips 39

  40. 40 Editor Assembly Tips •UnityEditor Λࢀর͢Δ"TTFNCMZ wϏϧυʹ͸ؚΊͨ͘ͳ͍
 ʢͱ͍͏ؚ͔ΊΔͱΤϥʔʹͳΔʣ

  41. 41 Editor Assembly Tips

  42. 42 Test Assembly Tips •NUnit Λࢀর͢Δ"TTFNCMZ w௨ৗͷ"TTFNCMZ͸NUnitͷࢀরෆՄ

  43. 43 Test Assembly Tips

  44. 44 unsafe ίʔυ Tips

  45. 45 unsafe ίʔυ Tips wVOTBGFͳίʔυ΋औΓѻ͑Δ wJM$QQ4FU0QUJPOͱ͔࢖͏৔߹͸ɺ
 ผ్ࢀরઃఆΛߦ͏ඞཁ͕͋Δ

  46. 46 .NET Framework Version Tips w/&5ͷόʔδϣϯ͸ݸผબ୒Ͱ͖ͳ͍ wProjectSettings.assetͷઃఆʹґଘ͢Δ wόʔδϣϯΛݻఆ͍ͨ͠৔߹͸
 "TTFNCMZ%FpOJUJPOΛ࢖Θͣʹ
 ࣗલͰEMMίϯύΠϧ͢Δ͔͠ແͦ͞͏

  47. 47 AssemblyDefinition × AssetBundle Tips w"TTFU#VOEMFΛ༻͍͍ͯΔ৔߹ɺ
 ͪΐͬͱ࿩͕ϠϠίγΫͳΔ w"%Խ͢Δͱɺ4DFOFͳͲͷ"TTFU͕ࢀর͢Δ
 $PNQPOFOU΍4DSJQUBCMF0CKFDUͷ
 "TTFNCMZ৘ใ͕มԽ͢ΔίτʹͳΔ

    wجຊతʹ"TTFU#VOEMFͷ࠶ߏங͕ඞཁ wϒϩάॻ͍ͨͷͰɺ࢔ࡉ͸ͦͪΒΛ͝ࢀর͍ͩ͘͞
  48. 48 static Ϋϥεɾϝιου Tips w௚઀తʹ࢖͍ͬͯͳ͍ϋζͳͷʹ
 ʮͦͷ"TTFNCMZࢀরͰ͖ͳ͍Αʂʯ
 ΤϥʔͰౖΒΕΔ͜ͱ͕͋Δ w͜Ε͸ɺ਌ΫϥεͷTUBUJDϝιουΛ
 ࢀর͍ͯ͠Δ৔߹ͳͲʹى͖͕ͪ

  49. •class Hoge : SingletonMonoBehaviour<Hoge> {} •Hoge.Instance; w͜Ε͸࣮࣭తʹ͸ SingletonMonoBehaviour.Instance Λ
 ࢀর͍ͯ͠ΔͷͰɺ


    SingletonMonoBehaviourؚ͕·ΕΔ
 "TTFNCMZ΁ͷࢀর͕ඞཁʹͳΔ 49 static Ϋϥεɾϝιου Tips
  50. 50 partial Ϋϥε Tips w$ʹ͸QBSUJBMͱ͍͏ɺΫϥεͳͲͷ
 ఆٛΛ෼ׂͰ͖ΔΑ͏ͳ࢓૊Έ͕͋Δ w͜Ε͸ɺಉҰ"TTFNCMZ಺ͰͷΈ༗ޮ w"TTFNCMZΛ෼ׂ͢ΔͱQBSUJBMఆ͕ٛ
 ޮ͔ͳ͘ͳΔͷͰ஫ҙ

  51. 51 -batchmode Tips w$*ͳͲΛ͢ΔࡍʹඞਢʹͳΔҾ਺ wԿΒ͔ͷ৚݅Ͱ"TTFNCMZ͕࠶ίϯύΠϧ͞ Εͳ͘ͳΔ͜ͱ͕͋Δ w.JTTJOH4DSJQUTతͳΤϥʔ͕େྔൃੜ wݪҼෆ໌͕ͩ6OJUZͷόʔδϣϯΛ
 ੾Γସ͑ͨΓ͢Δͱ௚Δίτ͕ଟ͍

  52. w5IFBTTPDJBUFETDSJQUDBO OPUCFMPBEFEʜ
 ͱ͔ݴΘΕΔ wCBUDINPEFͷιϨͱ͍ۙʁ wݪҼෆ໌ w௚͠ํ͸6OJUZͷ
 όʔδϣϯΛ੾Γସ͑ͯىಈ w 52 εΫϦϓτണ͕Ε

    Tips
  53. ·ͱΊ 53

  54. w"TTFNCMZ%FpOJUJPOΛ༻͍Δͱ
 ίϯύΠϧ͕଎͘ͳΔʢ͔΋ʣ wͪΐͬͱΫη͕ڧ͍͚Ͳ
 ࣮༻Ϩϕϧʹ͸ୡͯ͠Δ 54 ·ͱΊ

  55. Appendix 55

  56. wࠓ೔͓࿩ͨ͠͠಺༰ͷαϯϓϧΛ (JU)VCʹެ։͓ͯ͠Γ·͢ w IUUQTHJUIVCDPNNPOSZ"TTFNCMZ%FpOJUJPO@4BNQMF 56 ͓·͚

  57. 57 Thank you for your attention!!