# Assembly Definitionについて ## 設定 昨日話題に出た「**Assembly Definition**」について触りだけまとめておきます。 Scriptsフォルダが以下のような構成になっているとします。 ``` Scripts ├── God │ └── GodScript.cs └── Stash └── StashScript.cs ``` **StashからGodを参照したいけど逆は嫌だ**。というときにAssembly Definitionがつかえます。 各フォルダにAssembly Definitionファイルを生成します。(Projectビューでフォルダ右クリック→Create→Assembly Definition) ``` Scripts ├── God │ ├── God.asmdef │ └── GodScript.cs └── Stash ├── Stash.asmdef └── StashScript.cs ``` Stash.asmdefには画像のように「**Assembly Definition References**」に**God.asmdefをアタッチ**します。 ![](https://i.imgur.com/0WOdb5e.png) これでアセンブリの分割と依存関係の設定は終わりです。 ## 結果 画像のように**StashからはGodにアクセスできますが**、 ![](https://i.imgur.com/B80jenL.png) **GodからStashへはアクセスできません**。 ![](https://i.imgur.com/70K0S0Z.png) Assembly Definitionファイルがないフォルダからは両方にアクセスできます。 ![](https://i.imgur.com/iKZlsld.png) ![](https://i.imgur.com/cpwhxmg.png) Assembly Definitionを設定すると以下のようにcsprojやDLLが分割されます(設定しない場合はAssembly-CSharp) ![](https://i.imgur.com/heg1j8E.png) ![](https://i.imgur.com/lKMFPGW.png) スクリプトがどのアセンブリに所属しているのかはUnityエディタでスクリプトを選択すると見ることができます。 ![](https://i.imgur.com/oHoXfNx.png)