During my journal on DOTS programming. I found it hard to organize my code because every system may touch a bunch of different components. It’s not very clear which category one system should belongs to (However it’s clear which category a component belongs to).
If I organize the code by “object class” like Character / Spell / Props categories, which category should “MoveSystem” fall into ?
Maybe organize the code by “functional” like Movement / Physics / Network is more clear ?
IMO there’s only 1 hard rule you should follow the rest is really personal preference. The rule being
You should separate your Components and Authoring into a separate assembly from your Systems.
Why? So that when you make logic changes in your systems subscenes don’t need to rebake.
Now you can separate your components and authoring into 2 separate assemblies or keep them together it doesn’t matter it’s up to you; they just need to be separate from (non-baking) systems.
This seemed like a good idea. So I tried to just put a few systems into a ‘system_assembly’ and a few authoring components into a ‘authoring_assembly’. So now you get a big pile of errors, because you are missing assembly references.
So I add a reference from my System assembly to my Authoring assembly.
I also add a big list of Unity.Entities, Unity.Burst, ect. to both of my new assemblies.
So far so good? (I think).
But now I am stuck, because I cannot reference anything that was in unity’s default assembly. (Assembly-CSharp). So does this meen I need to ‘assemalate’ the entire project? (put entire project into custom assemblys) Before I can see if it works?
If the answer is ‘yes’, I can work with that. If there is a better way please let me know.
Generally yeah it’s good practice to put all your code inside assemblies. It’s a bit of a pain if you end up making a lot of separate modules of assemblies…
So a long time ago I wrote a tool to generate and add references automatically to a bunch of assemblies (as always found in my core library.)
How I can handle making so many assemblies without going insane
Thanks for the info. Because its already quite a big project, I wanted to be able to improve the structure over time. This is great work for the last 15 minutes of the day, since it can break the entire build .
So what I did was create 3 assembly definition assets. [Systems → Authoring-> Global], where Systems can reach everything, but nothing can reach systems (except for systems). I’ve added a Assembly Definition Reference Asset to all the folders containing my own code and referenced the SystemAssemblyAsset in all of them. Now everything compiles again.
Now I take some components and put them in a sub folder together with a new AssemblyAssetReference that references the AuthoringAssemblyAsset. This way I can slowly peal off the components from the main assembly while still having a working game.
So the only downside is that you need more Assembly references in the SystemAssemblyAsset than you would have in the optimal split. This is the list needed for my project to compile again (the top 2 are my own). :