Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

[Released] Auto-ASMDEF (Single-Click, project wide assembly definition creator)

Discussion in 'Assets and Asset Store' started by Pecek, Oct 30, 2019.

  1. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    156
    I have my project organized so that all 3rd party assets are in the Plugins folder and all of the game's code is under Scripts. I followed the manual and the video to do the setup, and everything worked correctly. However, compilation time doubled from 20 to 40 seconds. If I'm already organizing using the special folders, is there no point in using the ASMDEF files, or is something else going on here?
     
  2. Pecek

    Pecek

    Joined:
    May 27, 2013
    Posts:
    187
    @GoldFireStudios Unity introduced assembly definitions because people didn't follow conventions with the folder names and put pretty much everything under the root instead of one of the special folders, they aren't any faster than that system was, it's just easier to manage as the files can stay where they are. So yes, if you already have every third party code in Plugins/StandardAssets/StandardAssetsPro folders, and only the code you change frequently is outside of it then your project was already optimized, you only ever have to recompile the contents of Plugins if you change anything in it - this is what the asset is trying to achieve without the folder structure requirement.
    However 20 seconds sounds like a lot, how big is your project, and what's your CPU?

    With ASMDEF files only the compilation order changes, there is some overhead since Unity has to scan the project for *.asmdef and *.asmref files, but this should be small unless you have an extreme amount of them(in my projects there are 4-5 thousands of them, not a hitch yet), and this should only happen the first time(as the rest won't be recompiled unless you change something in them).
     
  3. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    156
    I thought 20 seconds was rather slow as well. The project isn't exactly massive. A few dozen game scripts in Assets/Scripts and around 25 assets/tools in Assets/Plugins. I've got an 8-core i9, so it should be plenty fast to handle compilation, which is why I've thought something must be setup wrong. The reason I thought I'd try this tool is that if I put the custom game code in a separate project without most of the plugins, it compiles in just a few seconds, so I assumed all of the plugins were still being compiled each time.
     
  4. Pecek

    Pecek

    Joined:
    May 27, 2013
    Posts:
    187
    @GoldFireStudios Yeah, any modern 8 core should be plenty. Just to be sure, am I correct assuming you are not talking about build times but just iteration in the editor? Sometimes there is some confusion when it comes to this, when you build your project you have to recompile everything no matter what, the only way to speed that process up is by manually compiling code into DLLs(in that case Unity will just make a copy of those).

    Also can you confirm if your code is compiled into Assembly-CSharp.dll, and the 3rd party stuff is in Assembly-Csharp-firstpass.dll? You can check this by just selecting the .cs file in the project view, it'll be listed on the inspector.
     
  5. Pecek

    Pecek

    Joined:
    May 27, 2013
    Posts:
    187
    1.3 is available now, yay! It brings fixes, much better editor performance(especially when selecting\deselecting recursively), more safety checks, and some quality of life improvements.
    • Added QOL improvements, such as color-coded folders in the Hierarchy tab, it lets you know if a subfolder has enabled folders with a script in it(no more stealthy scripts!), or if a script is disabled via RegEX
    • Reworked parts of the UI to make it easier to understand
    • Fixed RegEX not saving with the database
    • Changed the way the database stores data
    • Better editor performance
    • Updated the written and recorded documentation
    • Removed some unnecessary UI elements
    The database's code changed quite significantly, when you open up the window from an earlier version it's going to automatically revert the changes(otherwise you might end up in a compilation loop - this was fun to fix btw, barely took me a week since every single time Unity took my project hostage for almost three hours when I did manually delete the library folder, longer when I didn't). So it's a mild inconvenience for sure, but it saves at least half a day's worth of waiting.
     
    firstuser likes this.
  6. MoonMoritz

    MoonMoritz

    Joined:
    Jan 30, 2022
    Posts:
    18
    UI is very broken in Unity 2022.1.9f1
    upload_2022-8-22_21-52-54.png

    Repro 100%: Literally from the start, the window looks like this.
    upload_2022-8-22_21-53-56.png
    It tried to run one time without the errors or infinitely growing scrollbars, but stopped greyed out "waiting for input" with the Compile Yellow Warning triangle showing. The compile was done, and had failed.
     

    Attached Files:

  7. MoonMoritz

    MoonMoritz

    Joined:
    Jan 30, 2022
    Posts:
    18
    Here's the use case I would like to see supported (assuming you will fix the UI soon)

    Large project, team working in many directories. Lots of cross referencing between assemblies, but each team only works on one; so would benefit from them being in Asmdefs.

    However, we use SO MUCH CODE, first party, second party, 3rd party... it's so much that setting up each assembly definition by hand is a nightmare.

    Would love a button that would check "so this directory references all these things? lets auto-add the asmdefs", because assembly definition names often are very different from the class or package being referenced, so searching is a nightmare.

    The actual "game code" or whatever most people have in "Scripts" rarely changes. It's the "3rd Party" stuff that changes a lot for us, but for each team or developer usually only one of these at a time.

    So instead of pooling everything into 1 big asmdef, it would be super useful to just comfortably refactor one individual folder at a time, and say "turn this folder into its own assembly, referencing all the S*** you have, and then filtering down with some sort of bisect trial-and-error what is valid".

    Even a simple template asmdef generator that just references everything I have would be a huge boon.

    CreateAssetMenu->"New Global Asmdef with everything in it" or something. Get the idea? :D
     
    Meatloaf4 likes this.
  8. Pecek

    Pecek

    Joined:
    May 27, 2013
    Posts:
    187
    @MoonMoonMoritz Thanks for bringing this up, I'll look into Unity 2022 ASAP - issues like this are usually due to changes how Unity handles UI, it's probably just something simple during initialization or something similar. I'll let you know as soon as I can.

    About "global" ASMDEF - it's basically what it does right now, the idea is to move everything that's somewhat static into an assembly so you don't have to recompile it over and over if the rest of the codebase changes. The tool creates 1-4 asmdef files so your references won't get messed up(as it basically emulates how Unity compiles its stuff by default using folders like Editor, Plugins, and Editor inside Plugins - so outside of some very specific edge cases everything should just work the way it used to). However you can do whatever you like with the created asmdef/asmref files. :)
     
  9. Pecek

    Pecek

    Joined:
    May 27, 2013
    Posts:
    187
    @MoonMoonMoritz Finally had the time to check out what's going on - yep, background UI changes made everything off and introduced a couple of errors. I'm going to submit an update over the weekend, it should be live a day or two after that - feel free to contact me via email if you want to try it before it goes live. Ironic though, I rewrote the entire UI this year to make it future-proof UI-wise using UIToolkit lol.
     
  10. Pecek

    Pecek

    Joined:
    May 27, 2013
    Posts:
    187
    @MoonMoonMoritz
    Unity 2022 is officially supported in 1.4b. :) Uploading it now, it should be live within 2 business days.
    Edit: it's available now.

     
    Last edited: Aug 29, 2022