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 を公開しています。

Tetsuya Mori
PRO

July 25, 2018
Tweet

More Decks by Tetsuya Mori

Other Decks in Programming

Transcript

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

    View Slide

  2. 2
    ͜Μ͹Μ͸ʂ

    View Slide

  3. 3
    ಥવͰ͕͢

    View Slide

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

    View Slide

  5. 5

    View Slide

  6. 6
    {
    "name": "[email protected]",
    "references": [
    "[email protected]_utility_lifecyclehandler",
    "[email protected]_common_dialog",
    "[email protected]_common_downloader",
    "[email protected]_common_pavilionloader",
    "[email protected]_common_projects",
    "[email protected]_management",
    "[email protected]_core",
    "[email protected]_generics",
    "[email protected]_routing",
    "[email protected]_arguments",
    "[email protected]_management",
    "[email protected]",
    "[email protected]",
    "[email protected]_setting",
    "[email protected]_monobehaviour",
    "[email protected]",
    "[email protected]_observablelifecyclemonobehaviour",
    "[email protected]_observableunitywebrequest",
    "[email protected]_manipulation_api",
    "pretendland_academy",
    "pretendland_ecc",
    "pretendland_gummi",
    "pretendland_ippudo",
    "pretendland_kao",
    "pretendland_nissincisco",
    "pretendland_sugi",
    "pretendland_sushiro"
    ],
    "optionalUnityReferences": [],
    "includePlatforms": [],
    "excludePlatforms": [],
    "allowUnsafeCode": false
    }

    View Slide

  7. 7
    ։ൃ࣌ͷίϯύΠϧ͕଎͘ͳΔ

    ʢ͔΋͠Εͳ͍ʣ

    Assembly Definition

    ʹ͍ͭͯղઆ͠·͢ʂ

    View Slide

  8. ࣗݾ঺հ
    8

    View Slide

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

    View Slide

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

    View Slide

  11. w ࢠͲ΋޲͚εϚϗΞϓϦ

    ։ൃͳͲ
    w ೥͋ͨΓ͔Β

    6OJUZΨοπϦ
    w ͬ͜͝ϥϯυ

    ྦྷܭສ%-
    w "QQ4UPSF(PPHMF1MBZ

    ʹͯࢠͲ΋޲͚ΧςΰϦ

    ϥϯΩϯά501
    11
    ͓͠͝ͱ
    ࣗݾ঺հ

    View Slide

  12. ΞδΣϯμ
    12

    View Slide

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

    View Slide

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

    View Slide

  15. Assembly Definition ͱ͸ʁ
    15

    View Slide

  16. 16
    Assembly

    Λ

    Definition

    ͢ΔͨΊͷػೳ

    View Slide

  17. 17
    Assembly ?
    Assembly Definition ͱ͸ʁ
    ग़య.4%/ʮ/&5ͷΞηϯϒϦͱ໊લۭؒͷཧղͱ࢖༻ʯ
    lΞηϯϒϦ͸ɺػೳͷ࿦ཧత୯ҐΛ

    ߏ੒͢ΔܕͱϦιʔεͷू·ΓͰ͢ɻz

    View Slide

  18. 18
    Assembly ?
    Assembly Definition ͱ͸ʁ
    wૈ͘ݴ͑͹ʮϓϩάϥϜͷմʯ
    w"TTFNCMZ%FpOJUJPO͸ɺ

    ͜ͷմΛ࡞ΔͨΊͷઃఆϑΝΠϧ

    View Slide

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

    View Slide

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

    View Slide

  21. 21
    Assembly Definition ͷجຊ
    Assembly Definition ͱ͸ʁ

    hoge.asmdef

    hoge.dll

    View Slide

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

    hoge.dll

    View Slide

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

    hoge.dll

    fuga.dll

    View Slide

  24. 24
    ίϯύΠϧ࣌ؒͷ୹ॖʁ
    Assembly Definition ͱ͸ʁ

    View Slide

  25. ίϯύΠϧ࣌ؒͷ୹ॖʁ
    Assembly Definition ͱ͸ʁ
    wεΫϦϓτͷมߋΛݕ஌͢Δͱ

    ౎౓"TTFNCMZ$4IBSQEMMͱ͍͏

    ڊେͳEMMʹίϯύΠϧ͠௚͍ͯͨ͠
    w"TTFNCMZ͕෼͔ΕΔͱɺ

    มߋͱ͸ແؔ܎ͳ"TTFNCMZͷ

    ίϯύΠϧ͕ߦΘΕͳ͘ͳΔ

    View Slide

  26. 26
    Ϟδϡʔϧͷૄ݁߹Խʁ
    Assembly Definition ͱ͸ʁ
    wࠓ·Ͱ͸୯Ұͷ"TTFNCMZʹ

    શεΫϦϓτؚ͕·Ε͍ͯͨͷͰɺ

    ϥΠϒϥϦ։ൃऀ͕ҙਤ͠ͳ͍

    ࢀরͳͲ΋Մೳͩͬͨ
    w"TTFNCMZΛ෼ׂ͢Δ͜ͱͰɺ

    ҙਤ͠ͳ͍ࢀরΛߦ͑ͳ͘ͳΔͷͰ

    ݁Ռͱͯ͠ૄ݁߹Խʹܨ͕Δʢ͜ͱ΋͋Δʣ

    View Slide

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

    View Slide

  28. Assembly Definition ͷ࢖͍ํ
    28

    View Slide

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

    View Slide

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

    View Slide

  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

    View Slide

  32. 32
    AD ొ৔લ
    Assembly Definition ͷ࢖͍ํ

    View Slide

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

    ͱಉ֊૚σΟϨΫτϦҎԼͷ*.cs

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  39. Assembly Definition ͷ Tips
    39

    View Slide

  40. 40
    Editor Assembly
    Tips
    •UnityEditor Λࢀর͢Δ"TTFNCMZ
    wϏϧυʹ͸ؚΊͨ͘ͳ͍

    ʢͱ͍͏ؚ͔ΊΔͱΤϥʔʹͳΔʣ

    View Slide

  41. 41
    Editor Assembly
    Tips

    View Slide

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

    View Slide

  43. 43
    Test Assembly
    Tips

    View Slide

  44. 44
    unsafe ίʔυ
    Tips

    View Slide

  45. 45
    unsafe ίʔυ
    Tips
    wVOTBGFͳίʔυ΋औΓѻ͑Δ
    wJM$QQ4FU0QUJPOͱ͔࢖͏৔߹͸ɺ

    ผ్ࢀরઃఆΛߦ͏ඞཁ͕͋Δ

    View Slide

  46. 46
    .NET Framework Version
    Tips
    w/&5ͷόʔδϣϯ͸ݸผબ୒Ͱ͖ͳ͍
    wProjectSettings.assetͷઃఆʹґଘ͢Δ
    wόʔδϣϯΛݻఆ͍ͨ͠৔߹͸

    "TTFNCMZ%FpOJUJPOΛ࢖Θͣʹ

    ࣗલͰEMMίϯύΠϧ͢Δ͔͠ແͦ͞͏

    View Slide

  47. 47
    AssemblyDefinition
    ×
    AssetBundle
    Tips
    w"TTFU#VOEMFΛ༻͍͍ͯΔ৔߹ɺ

    ͪΐͬͱ࿩͕ϠϠίγΫͳΔ
    w"%Խ͢Δͱɺ4DFOFͳͲͷ"TTFU͕ࢀর͢Δ

    $PNQPOFOU΍4DSJQUBCMF0CKFDUͷ

    "TTFNCMZ৘ใ͕มԽ͢ΔίτʹͳΔ
    wجຊతʹ"TTFU#VOEMFͷ࠶ߏங͕ඞཁ
    wϒϩάॻ͍ͨͷͰɺ࢔ࡉ͸ͦͪΒΛ͝ࢀর͍ͩ͘͞

    View Slide

  48. 48
    static Ϋϥεɾϝιου
    Tips
    w௚઀తʹ࢖͍ͬͯͳ͍ϋζͳͷʹ

    ʮͦͷ"TTFNCMZࢀরͰ͖ͳ͍Αʂʯ

    ΤϥʔͰౖΒΕΔ͜ͱ͕͋Δ
    w͜Ε͸ɺ਌ΫϥεͷTUBUJDϝιουΛ

    ࢀর͍ͯ͠Δ৔߹ͳͲʹى͖͕ͪ

    View Slide

  49. •class Hoge :
    SingletonMonoBehaviour {}
    •Hoge.Instance;
    w͜Ε͸࣮࣭తʹ͸
    SingletonMonoBehaviour.Instance Λ

    ࢀর͍ͯ͠ΔͷͰɺ

    SingletonMonoBehaviourؚ͕·ΕΔ

    "TTFNCMZ΁ͷࢀর͕ඞཁʹͳΔ
    49
    static Ϋϥεɾϝιου
    Tips

    View Slide

  50. 50
    partial Ϋϥε
    Tips
    w$ʹ͸QBSUJBMͱ͍͏ɺΫϥεͳͲͷ

    ఆٛΛ෼ׂͰ͖ΔΑ͏ͳ࢓૊Έ͕͋Δ
    w͜Ε͸ɺಉҰ"TTFNCMZ಺ͰͷΈ༗ޮ
    w"TTFNCMZΛ෼ׂ͢ΔͱQBSUJBMఆ͕ٛ

    ޮ͔ͳ͘ͳΔͷͰ஫ҙ

    View Slide

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

    ੾Γସ͑ͨΓ͢Δͱ௚Δίτ͕ଟ͍

    View Slide

  52. w5IFBTTPDJBUFETDSJQUDBO
    OPUCFMPBEFEʜ

    ͱ͔ݴΘΕΔ
    wCBUDINPEFͷιϨͱ͍ۙʁ
    wݪҼෆ໌
    w௚͠ํ͸6OJUZͷ

    όʔδϣϯΛ੾Γସ͑ͯىಈ
    w

    52
    εΫϦϓτണ͕Ε
    Tips

    View Slide

  53. ·ͱΊ
    53

    View Slide

  54. w"TTFNCMZ%FpOJUJPOΛ༻͍Δͱ

    ίϯύΠϧ͕଎͘ͳΔʢ͔΋ʣ
    wͪΐͬͱΫη͕ڧ͍͚Ͳ

    ࣮༻Ϩϕϧʹ͸ୡͯ͠Δ
    54
    ·ͱΊ

    View Slide

  55. Appendix
    55

    View Slide

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

    View Slide

  57. 57
    Thank you for your
    attention!!

    View Slide