What is it? Unity Package, which allows to create parallel hierarchy of .asmdef
compilation files. Through this package, you can setup huge amount of .asmdef files.
This package is UnityEditor only
Why? With HUGE amount of code, it's necessary to decompose all of this code to
separate systems. And one of the best way to do this - with .asmdef files. In this way, you can
architect your project with more flexibility and incapsulation of logic. But default interface for .asmdef
files is not great for that. This package solve this problem
I have several reasons, why you should use it, instead of default .asmdef
- This is overhead for
.asmdef, you still works with.asmdef, but with improvements - It automates manual linking of many
.asmdeffiles. On default.asmdef, with every new project.asmdef, you must think to link it manually. With this solution - you just need to createAssemblyBuilderand add links to otherAssemblyBuilder
How to install it?
- Via UPM (git url) -
https://github.com/vertoker/assemblybuilder.git?path=/Assets/AssemblyBuilder - Via
manifest.json- add new line"com.vertoker.assemblybuilder": "https://github.com/vertoker/assemblybuilder.git?path=/Assets/AssemblyBuilder" - Via
git clone(if you want to contribute here) -git clone https://github.com/vertoker/assemblybuilder.git - Via
.ziparchive - just download package manually, extract and move to your project intoAssets/Pluginsconcrete folderAssets/AssemblyBuilder
How to work with it?
- Create new / Select existed
.asmdeffile - Create new
AssemblyBuilderasset (Scripting/AssemblyBuilder/...) - Add selected
.asmdeffile into newAssemblyBuilder - Add
parentsinto thisAssemblyBuilder - (optional) Setup
inherit modeof thisAssemblyBuilder - (optional) Add into overall
AssemblyBuilderCollectionasset - Click button
Build
Steps 2-3 can be done in one action: select .asmdef files and use
Create/Scripting/AssemblyBuilder/AssemblyBuilder from AssemblyDefinition (Shift+Ctrl+F11).
It creates AssemblyBuilder near every selected file, with .asmdef file already added
Step 7 can also be done from main menu, without selecting anything in project:
Tools/AssemblyBuilder/Build Allfinds every builder in project, detects roots of their hierarchy and builds them. Every builder is built exactly once, so it doesn't matter, how many collections contain itTools/AssemblyBuilder/Build Selectedbuilds only builders selected in project window, same asBuildbutton of inspector
Root is a builder, which no AssemblyBuilderCollection contains, building it covers
whole it's branch. parents are not a part of build hierarchy, they only give references,
so a parent is still built as it's own root
What you should know
- Use
readonlyoption for builder, which.asmdeffiles you don't want to change. It's usually files fromupmand other external packages in project itself - Use
public parentsandprivate parentsto create incapsulation in your inheritance tree. Even.asmdeffiles must have dependencies, which other.asmdeffiles should doesn't know about - Use
public parentsby default - Use
inherit modeto control depth of inheritance:DeepInherit(default) collects every parent through whole hierarchy,Inheritcollects only nearest parents, without parents of parents,NoInheritcollects nothing and clearsreferencesfield inherit modeof builder defines only it's ownreferencesfield.inherit modeof it's parents doesn't affect this builder, so you can safely change it in any asset- Cyclic
parentsare not allowed,.asmdeffiles can't reference each other in a circle. Builder detects it, writes error into console and stops inheritance on this branch, but hierarchy still must be fixed manually AssemblyBuilderallows to add several.asmdeffiles, but recommendation: use uniqueAssemblyBuilderfor every.asmdeffileAssemblyBuilderalso can be used without.asmdeffile, in inheritance recursion, it uses as group of otherAssemblyBuilder's, just add it intopublic parentsAssemblyBuilderCollectioncan be added intopublic parentsandprivate parentstoo. There it works as transparent group: it stands for builders inside it, not for a layer of inheritance, so it gives the same result as adding these builders one by one. Nested collections are unwrapped the same way- Use several
AssemblyBuilderCollectionassets, to collect allAssemblyBuilderassets in your project. This allows to setup all dependencies with singleBuildclick. Collections can contain other collections, and oneAssemblyBuildercan be added into several of them, it's built only once anyway.Builders Countfield shows amount of unique builders inside collection - At the current moment, it changes only
referencesfield in.asmdeffiles, therefore everything else must be setup manually (but it can be changed)
This package is in development, I open to any MR that you sent to project