Search Unity

Assembly Definition Woes

Discussion in 'Editor & General Support' started by Wahooney, Dec 20, 2017.

  1. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    I'm sorry, you feel that way but what you are describing would negate the other settings in an asmdef(per platform, defines constraints, Test & Editor only assemblies). Compiling with asmdefs and without can give different results.

    We understand the issues users are having and are working on improvements. We are adding support for out of branch files, what some have referred to as partial asmdefs. With this, you will be able to continue with the Editor folder approach and simply use an assembly reference(asmref) in each Editor folder which would all compile to a single asmdef(or more).
    You will then be able to continue using assets that have Editor folders and assets that use asmdefs together.

    I should mention I'm not actually part of the scripting team but I will be the one doing the work on this so that it can be done quickly because I know it's bothering you guys.
     
  2. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    >We are adding support for out of branch files, what some have referred to as partial asmdefs.

    Oh man, am I glad to read that. This is the thing that will allow us to trivially use asmdef files without having to modify asset store packages.
     
    Flavelius and karl_jones like this.
  3. JayArgh

    JayArgh

    Joined:
    Jul 23, 2013
    Posts:
    9
    @karl_jones I appreciate your pitching in on this thread. Thanks for the info.

    I'm working on a very large project, a container that includes 20+ licensed games and which recently failed to compile due to, it appears, an undocumented code limit for Assembly-CSharp.dll. I'm working on updating the project from 5.6.5f1 to 2018 now, using asmdefs to split up the code and avoid bumping against the limit, but I'm finding that adding separate asmdef files to every Editor folder for every game is a painful process - besides being tedious (one game alone has 38 Editor folders), there are interdependencies between some of those editor scripts that mean I'm having to track down, say, Assembly-{gamename}_Editor-34 and make sure it's listed as a reference for Assembly-{gamename}-Editor-20, etc. The alternative - moving all Editor scripts into a single folder for each game - is a possibility but will make it harder to maintain such scripts if their corresponding plugins are updated or removed.

    Will the "out of branch files" feature easily let me compile all these files into a shared assembly, the way Editor folders would if I wasn't using asmdefs at all? If so, that's a helpful step. For my own use-case, it might be easier if there was just an override option to exclude subfolders named Editor from their parent asmdefs, letting those scripts instead get automatically compiled into Assembly-CSharp-Editor.dll with an automatic dependency on everything previously compiled, as Assembly-CSharp does for any files unassociated with an asmdef file.

    - JR

    PS: FWIW, I found this thread by googling "unity 2018 partial assembly definition", so "partial asmdefs" did seem an intuitive term to me; I'm not sure what's meant by "out of branch files".
     
    stonstad and SugoiDev like this.
  4. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    Yeah, we've been calling it partial asmdef ever since custom assemblies were out. I don't even remember who started calling it that, but it is the most intuitive name we've got.

    Maybe "out of branch files" will make sense once it's out, but right now it's not intuitive at all.
     
  5. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    The Assembly Definition Reference (asmref) requires there to be a matching asmdef. They have no settings inside of them, just a reference to the asmdef.
    The reason we decided not to support actual partial asmdefs, i.e having multiple asmdefs with the same name is that they could have conflicting settings which would make things confusing, especially since the settings would need to be applied to all the source files, not just the ones in that particular partial asmdef.
    So you would need a master asmdef but it can be anywhere, it does not even need to have any source files with it.
    So if you had lots of editor folders then you could place these asmrefs in all the folders and tell them to reference a master asmdef which could be somewhere else. So you do still need an asmdef, they do not work without.
    We dont support excluding files, maybe we could allow an asmref to reference Assembly-CSharp as an alternative to this?

    We are also considering per platform settings for asmrefs. E.G only include these source files if compiling for Android. You could do all sorts of things with partial classes or class variants then. Thats still just an idea though, not planned just yet.
     
  6. yatagarasu

    yatagarasu

    Joined:
    Apr 24, 2013
    Posts:
    28
    That would be good. Now having 15 asmdefs in the project, and Visual Studio sucks on every project reload, open file from editor or connecting a debugger. Thinking about moving back to precompiled assemblies, because all the system makes no sence when it slows down the development process.

    Another useful feature would be ability to add preprocessor defines for asmdefs.
     
  7. ifisch

    ifisch

    Joined:
    Jul 15, 2012
    Posts:
    35
    That's the exact same suggestion you made before and it still involves us putting dozens of asmdefs in each of our editor folders. That's no good.

    I don't understand how compiling without asmdefs, only at build time, would "give you different results" that could cause any sort of negative issue. Wouldn't it simply package everything into the main c# assembly (like it would if you had never setup the asmdefs)? Why would that be a problem?
     
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    As I said, they could have conflicting settings which would make things confusing, especially since the settings would need to be applied to all the source files, not just the ones in that particular partial asmdef.

    Assembly Definition settings such as platform, define constraints, test assemblies would all be ignored and they would just be combined into a single assembly. Creating a very different build.

     
  9. JayArgh

    JayArgh

    Joined:
    Jul 23, 2013
    Posts:
    9
    FWIW, the solution we've ended up going with is this:
    Create a top-level Editor folder per game (I actually called it "_Editor" to distinguish).
    Create folders within _Editor to duplicate the paths to any Editor folders. So, for instance, a folder called Assets/{GAME}/Editor would move to Assets/{GAME}/_Editor/Editor. A folder called Assets/{GAME}/Scripts/LeanTween/Editor would move to Assets/{GAME}/_Editor/Scripts/LeanTween/Editor.
    Create a single asmdef in the {GAME} folder.
    Create a single Editor asmdef in the {GAME}/_Editor folder. Set the other asmdef as a reference/dependency.

    It's an annoying process, but significantly less time-consuming than creating separate asmdefs and managing the references between them, and the tree structure is generally preserved so that we're still able to see where things came from, just with one more step each time. Suboptimal, yes, but thus far it seems the most workable solution.
     
  10. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    That sounds an awful lot like my suggestion
    :p
    Sounds like a good approach.
     
  11. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    That's what we've been doing ever since custom assemblies landed.

    The biggest issue we have is having the repeat your directory structure in two places. It creates a lot of redundancy when you have lots os directories and is especially bad with asset store stuff, since you will have to keep track of your changes and propagate them every time the developer changes the structure.

    Another annoying issue is not having the related files close together in the IDE. You have to navigate a lot more to find your files.



    Related files are far away. It's easy to rename the folder to something else and forget that its counter even exists.
    This is the current solution.

    Code (CSharp):
    1. Assets/Game/Editor/Characters/NPCs/Ghosts/CommonGhost/Eyes/EyeEditor.cs
    2. Assets/Game/Characters/NPCs/Ghosts/CommonGhost/Eyes/Eye.cs

    Files are very close. It's much rarer to rename something and forget to propagate the change. Easy to navigate in the IDE, and also easy to see that the Eye component actually has an editor.
    This would only work with partial asmdef files.

    Code (CSharp):
    1.  
    2. Assets/Game/Characters/NPCs/Ghosts/CommonGhost/Eyes/
    3. ---------------------------------------------------Eye.cs
    4. ---------------------------------------------------Editor/EyeEditor.cs
     
    Hunter_Bobeck likes this.
  12. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    We are working on a solution so you can keep them all together in the future but still have them into one assembly. See the asmref stuff I mentioned earlier in the thread.
     
    Hunter_Bobeck likes this.
  13. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    That's gonna be awesome!
     
  14. JayArgh

    JayArgh

    Joined:
    Jul 23, 2013
    Posts:
    9
    It IS an awful lot like your suggestion! We added the twist of duplicating the path to each Editor folder so we can still see where they came from. Perhaps your proposed automatic utility would do the same? :)

    But as I said, and for the reasons mentioned by others: it's not preferable. Automating that process would save a few minutes per project (once I had a rhythm going), but I would have preferred for all Editor folders under a common asmdef to automatically combine into an Editor-only assembly that depends on that parent asmdef, thereby gaining the benefits of splitting up assemblies without losing the convenience of the Editor folder naming convention.
     
  15. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    That was how it was going to work. I then changed it so it would automatically place an asmdef in every folder but it's tricky getting all the references correct and often ends up with cyclic references so the asmref is needed really.
    Once thats in ill change the tool so it places an asmref in every Editor folder.
    Doing the automated Editor folder thing for an asmdef would create similar problems with the references, it's hard to get them right automatically and referencing everything often causes the cyclic issues. The asmref solution will allow you to configure an Editor asmdef with the correct references and then just add additional source code directories via the asmrefs.
     
    Hunter_Bobeck and SugoiDev like this.
  16. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    333
    I wanted assembly definition files for all third-party assets, with separate files for each Editor folder underneath.

    So I took @LVermeulen's very cool script and adapted it a bit.

    This version doesn't delete assembly definition files - it just creates them. But it won't overwrite a file that already exists. That means you can run it each time you add a third-party asset, and it should just create new files for the asset but leave the rest alone.

    I found I needed to tweak some of the dependencies a bit and, after that, it worked for me.

    There's a list of directories you don't want to generate for - basically your project directory and Resources go in here. And I wanted a separate assembly definition for each directory in Plugins.

    Hoping this might be useful to someone else...

    Code (CSharp):
    1.  
    2. using System.Collections.Generic;
    3. using System.IO;
    4. using System.Linq;
    5. using UnityEditor;
    6. using UnityEngine;
    7.  
    8.  
    9. #pragma warning disable 649 // CS0649 - always have its default value
    10. // ReSharper disable once ClassNeverInstantiated.Global
    11. internal class AssemblyDefinitionType
    12. {
    13.     public string name;
    14.     public List<string> references;
    15.     public List<string> includePlatforms;
    16.     public List<string> excludePlatforms;
    17. }
    18. #pragma warning restore 649 // CS0649 - always have its default value
    19.  
    20. // Based on https://forum.unity.com/threads/assembly-definition-woes.509541/#post-3451964
    21. public static class AssemblyDefinitionGenerator
    22. {
    23.     // ignore everything in these directories altogether - include anything here you want to setup manually
    24.     private static readonly string[] IgnoreDirectories = new string[]
    25.     {
    26.         "_Project",
    27.         "Resources"
    28.     };
    29.     // don't create parent assemblies for these directories - create them one level lower
    30.     private static readonly string[] NoAssemblyDirectories = new string[]
    31.     {
    32.         "Plugins"
    33.     };
    34.    
    35.     [MenuItem("Tools/Create Assembly Definition Files")]
    36.     public static void TurnOnAssembly()
    37.     {
    38.         CreateAssemblyDefinitions(new DirectoryInfo(Application.dataPath), null, false, "");
    39.         AssetDatabase.Refresh();
    40.     }
    41.  
    42.     private static List<string> _editorAssemblySiblings;
    43.     private static int _duplicateNumber = 0;
    44.  
    45.     private static void CreateAssemblyDefinitions(DirectoryInfo directory, FileInfo parentAssembly,
    46.         bool requireAssembly, string assemblyPrefix)
    47.     {
    48.         if (IgnoreDirectories.Contains(directory.Name) || !ContainsSources(directory)) return;
    49.  
    50.         var files = directory.GetFiles("*.asmdef");
    51.         foreach (var file in files)
    52.         {
    53.             parentAssembly = file;
    54.             _editorAssemblySiblings = new List<string>();
    55.             _duplicateNumber = 1;
    56.         }
    57.         // if there is no parent assembly file, it's not the root, and it contains source code, create an assembly
    58.         if (requireAssembly && parentAssembly == null &&
    59.             !NoAssemblyDirectories.Contains(directory.Name))
    60.         {
    61.             var assembly = new AssemblyDefinitionType {name = assemblyPrefix + directory.Name};
    62.             var filename = assembly.name + ".asmdef";
    63.             var pathname = Path.Combine(directory.FullName, filename);
    64.             UnityEngine.Debug.Log("Writing parent " + pathname);
    65.             File.WriteAllText(pathname, JsonUtility.ToJson(assembly));
    66.             parentAssembly = directory.GetFiles(filename)[0];
    67.             _editorAssemblySiblings = new List<string>();
    68.             _duplicateNumber = 1;
    69.         }
    70.                    
    71.         var directories = directory.GetDirectories();
    72.         foreach (var subdirectory in directories)
    73.         {
    74.             if (subdirectory.Name != "Editor")
    75.             {
    76.                 // add a prefix to plugins
    77.                 var prefix = NoAssemblyDirectories.Contains(directory.Name) ? directory.Name + "-" : "";
    78.                 CreateAssemblyDefinitions(subdirectory, parentAssembly, true, prefix);
    79.                 continue;
    80.             }
    81.  
    82.             if (!ContainsSources(subdirectory)) continue;
    83.  
    84.             // create a assembly file based on the Parent one, only with includePlatforms changed to Editor
    85.             // assembly name is the parent assembly name + directory that contains the editor folder + "Editor"
    86.             var editorAssembly = JsonUtility.FromJson<AssemblyDefinitionType>(File.ReadAllText(parentAssembly.FullName));                    
    87.             editorAssembly.references.Add(editorAssembly.name); // add parent assembly as a reference
    88.  
    89.             // make the name unique
    90.             var editorAssemblyName = editorAssembly.name;
    91.             if (!editorAssemblyName.EndsWith(directory.Name)) editorAssemblyName += directory.Name;
    92.             editorAssemblyName += "Editor";                
    93.             if (_editorAssemblySiblings.Contains(editorAssemblyName))
    94.             {
    95.                 editorAssemblyName += _duplicateNumber;
    96.                 _duplicateNumber += 1;
    97.             }
    98.             _editorAssemblySiblings.Add(editorAssemblyName);
    99.            
    100.             // only create an assembly if we don't have one already
    101.             var pathname = Path.Combine(subdirectory.FullName, editorAssemblyName + ".asmdef");
    102.             var file = new FileInfo(pathname);
    103.             if (file.Exists) continue;
    104.  
    105.             editorAssembly.name = editorAssemblyName;
    106.             editorAssembly.references.AddRange(_editorAssemblySiblings); // for subeditor folders to reference the above editor assemblies
    107.             editorAssembly.includePlatforms = new List<string> {"Editor"};
    108.             UnityEngine.Debug.Log("Writing " + pathname);
    109.             File.WriteAllText(pathname, JsonUtility.ToJson(editorAssembly));
    110.         }
    111.     }
    112.  
    113.     private static bool ContainsSources(DirectoryInfo directory)
    114.     {
    115.         var sourceFiles = directory.GetFiles("*.cs", SearchOption.AllDirectories);
    116.         return sourceFiles.Length > 0;
    117.     }
    118. }
    119.  
    Original script is here: https://forum.unity.com/threads/assembly-definition-woes.509541/#post-3451964
     
  17. Wriggler

    Wriggler

    Joined:
    Jun 7, 2013
    Posts:
    133
    Just ran into this issue with Assembly Definitions too. Everything looked good in the Editor, but when I went to build our bundles on our build server I discovered that the Editor special folder naming convention is ignored. Yikes.

    My two choices right now are to either:
    1) Spend a while manually setting up asmdef files in all the third party assets we use (yuck), manually managing their dependencies (double yuck), as well as inheriting the responsibility for merging all future third party updates, potentially forcing me to rework their codebases for future versions.
    2) Don't use Assembly Definitions.

    It's not even a choice - I just deleted all the asmdef files and am going old school. Option 1 adds way too much overhead to our team; I don't want the responsibility of managing all the Asset Store code in our project... that's why we purchased the assets in the first place. Any large scale project will run into this issue.

    @karl_jones: I do understand the stance you're taking in this thread, but it's rather idealistic. Right now using asmdefs adds so much overhead for any non-trivial project that it might as well not exist as an option. Perhaps we'll review this again when every asset in the Asset Store is using the package manager (in a million years, probably), but until then this feature isn't realistically usable, in my opinion.

    Ben
     
    Hunter_Bobeck and Harinezumi like this.
  18. Deleted User

    Deleted User

    Guest

    @Wriggler I agree with your statement, but as it is with all new inventions, it takes time to adapt. Most cars still run on gas even though we have battery powered ones for at least a decade now.
    In my opinion:
    - Don't convert a project you started just yet. It's simply too early due to all the assets in the asset store not matching the criteria. And reworking your carefully created folder structures and namespaces is just a pain in the butt.
    - Consider it when starting a new project, including contacting to asset vendors providing ASMDEF ready solutions. I tried that once and they were pretty fast in providing a package making use of them
     
  19. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    945
    Meanwhile, are there any news regarding this issue?
     
  20. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    Which issue are you referring to? There's quite a few in this thread.
     
  21. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    945
    Having multiple Editor folders and being able to merge them into one Editor-assembly
     
    Harinezumi and fherbst like this.
  22. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    945
    Or did i miss that some change already went live?
     
  23. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    945
    Are there any plans?
     
  24. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    309
    After reading the manual on assembly definitions I misunderstood the part about plugins being able to be referenced by defined assemblies as being able to reference code in the folder Plugins. After many hours trying to get assembly definitions to work I realize that this is wrong, only plugins, i.e. pre built dll:s work this way.

    But that got me thinking, if user defined assemblies could reference Assembly-CSharp-firstpass (or its editor counterpart for editor only scripts) wouldn't that solve all the problems with e.g. Editor folders in asset store packages? You could just copy all asset store stuff into Plugins folder, making it compile into firstpass and then reference it from your own assemblies.
     
    Maeslezo likes this.
  25. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    2019: After adding asmrefs to a couple of projects, and to a couple of assets ... I discovered the major design mistakes in the original implementation, and found this thread while trying to figure out what I'm missing - why is this shiping when it doesn't seem to fully work? Reading the thread I came to the obvious conclusion: give up. These cannot be sensibly supported in plugins, it's obvious why asset-store authors aren't using them, and there's no point in developers using them either. The main use-cases are projects so obscenely large they have huge compile-times - but that's better solved already by using external compilation! (which still works, and works better than this new asmrefs stuff).

    Like others said back in 2017 (!), @karl_jones idealistic view of "Everyone will change all 3rd party code and give it to you for free" doesn't reflect reality, and the alternative of "Ruin your project structure and create dependency-hell because all the Editor scripts lose their folder-based namespacing that's core to C#" strikes me as an even worse idea for code-quality/project-cleanliness.

    Disappointed that asmrefs are still a "nice prototype" that Unity apparently hasn't got around to finishing a v1.0 implemention of yet :(.
     
    stonstad likes this.
  26. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    @a436t4ataf Asset Store authors are more likely "not using them" because migration is still in progress. I know a few asset authors who actually do so, and do so well: e.g. UniRx, Zenject.

    Also what do you mean it cannot be "sensibly" supported? We used it in different ranges with projects from 20 asmdefs up to 120 asmdefs and it is pretty easy to recreate what the the original 4 assemblies did.

    Also "core to C#" is a bit strict. It is a guideline and I've seen and used folders to be excluded as namespace providers for different reasons.

    However, I can only repeat myself - there are major drawbacks and problems and I am not happy with the system as it is, but it is by far not as "unuseable" as you describe it is far from reality.
     
    a436t4ataf likes this.
  27. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    Mostly: Asmdefs are *nearly* a good solution to a set of important problems, but feel like they were rushed through without seriously considering the consequences (especially: ignoring the vast amount of legacy code that becomes incorrect through no fault of its own).
     
    MNNoxMortem likes this.
  28. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    309
    If I could set up the references to firstpass, editor-firstpass etc in assemblies then I think they would work perfectly. I would not have to go through all the editor folders of assets from store as they would already be in the editor-firstpass and I could set up references as I saw fit.

    @karl_jones is this something that is doable? I am probably missing a lot of technical hurdles I don't even know about :)
     
  29. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    This may be possible with the new Assembly Definition Reference Files. Ill take a look tomorrow.

    Edit:

    It's not possible with the current implementation(which has almost landed in 2019.2) however we will look at adding support in the future after we land the asmref support.
     
    Last edited: Feb 4, 2019
    MNNoxMortem and Mikael-H like this.
  30. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    309
    If something like this became possible it would make me so happy! :) That would mean you could actually use assembly definitions even in legacy projects. It would bring much needed order to some stuff at work.

    Thanks for taking the time to read my humble suggestion, I really appreciate it!
     
    karl_jones likes this.
  31. mobilfactory

    mobilfactory

    Joined:
    Nov 11, 2014
    Posts:
    2
    error CS1069: The type name 'Registry' could not be found in the namespace 'Microsoft.Win32'. This type has been forwarded to assembly 'Microsoft.Win32.Registry, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.

    how can I add that library to 'Assembly Definition References'?
    I can't find it
     
  32. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
  33. DrunkenMastah

    DrunkenMastah

    Joined:
    Sep 26, 2017
    Posts:
    51
    Hope someone will create an Asset Store package and call it "Simple / Automatic ASMDEF Creator".
     
  34. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    2019.2 beta is now out and includes the new assembly definition reference(asmref) files feature. This will let you add out of branch files to an existing asmdef. So if you have your Editor folders included with all your scripts you can now pop an asmref file into each of the Editor folders, with a reference to a master asmdef and they will now all be compiled into the chosen asmdef. give it a try :)
     
    Last edited: May 10, 2019
  35. Wriggler

    Wriggler

    Joined:
    Jun 7, 2013
    Posts:
    133
    Hey Karl, this sounds like a great step in the right direction. Thanks for sharing!

    Ben
     
    karl_jones likes this.
  36. Ash-Blue

    Ash-Blue

    Joined:
    Aug 18, 2013
    Posts:
    102
    I wrote a script that will inject a reference into an `Editor` folder. This was really useful for my project as it has over 100 nested editor folders due to TDD. Hopefully this saves somebody else some time. PS Make sure to backup for using something like this.


    Code (CSharp):
    1. using System.IO;
    2. using UnityEditor;
    3. using UnityEngine;
    4.  
    5. namespace CleverCrow.DungeonsAndHumans.Utilities.Editors {
    6.     public static class AsmdefGenerator {
    7.         [MenuItem("Tools/Create Assembly Definition Files")]
    8.         public static void CreateAssemblyReferences () {
    9.             var generator = new AsmDefReferenceGenerator(
    10.                 $"{Application.dataPath}/DungeonsAndHumans",
    11.                 new [] {
    12.                     new AsmdefReference {
    13.                         assemblyDefinitionPath = "Assets/DungeonsAndHumans/Scripts/Editor/DungeonsAndHumans.Editors",
    14.                         folderName = "Editor",
    15.                         referenceName = "DungeonsAndHumans.Editors",
    16.                     },
    17.                 }
    18.             );
    19.  
    20.             generator.CreateReferences();
    21.         }
    22.     }
    23.  
    24.     public class AsmdefReference {
    25.         public string assemblyDefinitionPath;
    26.         public string folderName;
    27.         public string referenceName;
    28.     }
    29.  
    30.     public class AsmDefReferenceGenerator {
    31.         private readonly string _root;
    32.         private readonly AsmdefReference[] _referenceFolders;
    33.  
    34.         public AsmDefReferenceGenerator (string root, AsmdefReference[] referenceFolders) {
    35.             _root = root;
    36.             _referenceFolders = referenceFolders;
    37.         }
    38.  
    39.         public void CreateReferences () {
    40.             Debug.ClearDeveloperConsole();
    41.  
    42.             foreach (var referenceFolder in _referenceFolders) {
    43.                 var assemblyDefinitionId =
    44.                     AssetDatabase.AssetPathToGUID($"{referenceFolder.assemblyDefinitionPath}.asmdef");
    45.                 Debug.Log($"assemblyDefinitionId: {assemblyDefinitionId}");
    46.  
    47.                 var folders = GetFolders(referenceFolder.folderName);
    48.                 Debug.Log(string.Join(" \n", folders));
    49.  
    50.                 foreach (var folder in folders) {
    51.                     var file = File.CreateText($"{folder}/{referenceFolder.referenceName}.asmref");
    52.                     file.Write($"{{\"reference\": \"GUID:{assemblyDefinitionId}\"}}");
    53.                     file.Close();
    54.                 }
    55.  
    56.                 AssetDatabase.Refresh();
    57.             }
    58.         }
    59.  
    60.         private string[] GetFolders (string folder) {
    61.             return Directory.GetDirectories(_root, folder, SearchOption.AllDirectories);
    62.         }
    63.     }
    64. }
    65.  
     
    Mikael-H and Deleted User like this.
  37. mcroswell

    mcroswell

    Joined:
    Jan 6, 2010
    Posts:
    79
     
    Last edited: Mar 10, 2020
  38. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    Im not sure I understand. The link you provided tells you how to do it and when.

    When: Compilation is taking a long time, it will help to reduce this. You separate your code into assemblies that have well-defined dependencies. A lot of the same reasons you would split a large project into multiple dll libraries instead of a single exe.
     
    TeagansDad likes this.
  39. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
    Asmdef Unity docs are overcomplicated and lack practical guide of how to properly use them. They also lack some kind of proper structure. They could be split to: Basics, How to use, Details.

    This image itself is confusing as .cs scripts in Plugins folder are compiled to Assembly-CSharp-firstpass.dll.


    Here's very basic how to:
    (Replace BeatAim with your project name)

    1. Create BeatAim.asmdef in Assets folder.
    2. Create BeatAim.Editor.asmdef in Assets/Editor folder.
    3. Create BeatAim.Plugins.asmdef in Assets/Plugins folder.
    3. Create BeatAim.Plugins.Editor.asmdef in Assets/Plugins/Editor folder.
    4. Create .asmrefs pointing to BeatAim.Editor.asmdef in all Editor folders that are not in Assets/Plugins
    (you can duplicate same .asmref and drag - drop them to all the folders)
    5. Create .asmrefs pointing to BeatAim.Plugins.Editor.asmdef in all Editor folders that are in Assets/Plugins
    6. In BeatAim.asmdef add Assembly Definition Reference to BeatAim.Plugins.asmdef.
    7. Add all needed Assembly Definition References to all .asmdefs (stuff like UnityEngine.UI, Unity.TextMeshPro etc)

    Now you can start splitting your code. For example let's say you have a test scene with few scripts that are not used in the game.

    1. Make a folder
    2. Make .asmdef
    3. Add BeatAim.asmdef as Assembly Definition Reference

    Any changes to scripts in that folder will compile almost instantly.

    Converting whole project to asmdefs is needed otherwise they are almost unusable. I dislike how they are compiled before "Predefinded Assemblies". Asmdefs would be very easy to use if they'd be compiled after them.
     
    Last edited: Mar 10, 2020
    ageana, Jey88 and mcroswell like this.
  40. mcroswell

    mcroswell

    Joined:
    Jan 6, 2010
    Posts:
    79
    I agree. Unity should get you to help them write their docs as you're write-up above is very useful to me. The addition of the testing folder, and why you do that, is great. Thanks.

    Also, your notes additional notes may help me when I get in trouble, where you say:

    Thank you, @Kamyker !

    -Mike
     
  41. mcroswell

    mcroswell

    Joined:
    Jan 6, 2010
    Posts:
    79
    So, you're saying it is really only useful for when compilation is taking a long-time?

    Also, is it implied that if the assemblies don't have well-defined dependencies (like URP and Post-Rendering plugins supplied by Unity and other examples where various version-issues occur) they should not be used?
     
  42. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    I'm not aware of any issues with the dependencies of URP and Post Rendering, what do you mean?

    One of the main reasons to use asmdefs is for faster compilation speeds. If possible, you also want to disable the `auto reference` checkbox, this will stop it being referenced by Assembly-CSharp etc which means it triggers fewer recompilations.


    There are a few other benefits, for example:

    • When you are using packages or third party libraries and they are also using asmdefs(or dlls) then you can take advantage of the version defines feature. This lets you enable defines based on if a library is present and even the version number of the library. For example, you could have some code that is only compiled if the UI package is in the project. For example here is how you would handle TextMeshPro and UI as optional dependencies:
    Screen Shot 2020-03-11 at 20.48.19.png In the asmdef code, you can then do:

    Code (csharp):
    1. #if PACKAGE_UGUI
    2. // some ugui code
    3. #endif

    You can also query the asmdefs and build a dependency graph to better visualize dependencies etc. Heres one I made earlier https://twitter.com/KarlJamesJones/status/1040195116965810177
    The plan is to clean this up and release it in the future.
     
    TeagansDad and Deleted User like this.
  43. mcroswell

    mcroswell

    Joined:
    Jan 6, 2010
    Posts:
    79
    Karl,

    Thanks for the detailed replies. It really helps me understand this stuff a bit more.

    Regarding the URP and Post-processing, it's just I have issues where assemblies don't match up and it's difficult to identify what the issue(s) are. Often these are mismatches between versions even those provided with core assemblies. I'll try to provide an example next time it happens. It might just be my computer is a mess with years of Unity versions and projects laying around - a veritable treasure chest. ;-)

    The "version defines feature" sounds good. So, using your asmdef code snippet, could, or should, a third party provider minimally place a message there (in the conditional) to tell the end-user that the dependent library, um, assembly, is required? In this case, something like "TextMeshPro depends on UGUI - Go get version X.Y of UGUI"? I guess this would apply for one's own code, too?

    Thanks for sharing the video, too! That was built programmatically from the meta-data in the asmdef source code files? Neat!

    -Mike
     
  44. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    You could do this or if you are part of a package then You would put the dependent packages into the package JSON file so that it always ensures they are present. Then you would use this for parts that are optional dependencies. For example we do this in the Localisation package. If a user ha UI or tmp then we enable some additional code, if not then we don't do anything (no errors or warnings).

    If you do encounter any strange version problems then do please file bug reports, we can't fix what we don't know about ;)
     
    mcroswell likes this.
  45. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
    One more reason to convert whole project to asmdefs as in that case "Assembly-CSharp etc" don't exist.
     
    mcroswell and karl_jones like this.
  46. Deleted User

    Deleted User

    Guest

    About that. I also just realized putting ALL code in assemblies gets rid of Assembly-CSharp. Does that mean the auto reference checkbox is obsolete in that case?
    I read here, that the most frequently changed code should not go into an ASMDEF, is that true:
    http://www.screaminggoose.com/blog/2019/2/4/how-i-cut-unity-compile-times-by-75
     
  47. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
    No, very frequently changed code should be in separate asmdef that's not used by any other asmdef. That way if u change only one line of code - that single asmdef will be very quickly recompiled.

    For ex. from that website:


    Any changes to WildDog.Installers will be quickly recompiled. This tree looks overcomplicated anyway, 1-3 asmdefs would be enough in that case.
     
    TeagansDad and karl_jones like this.
  48. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    To be honest, there are still oddities in Unity regarding that.

    One example. Opening/Closing/Opening the same project:

    Code (CSharp):
    1. Compilation Report
    2. 1,48s Unity.Physics.Hybrid.dll <--- Was not changed
    3. 0,68s Frameworks.dll
    4. 0,70s Unity.Physics.Editor.dll <--- Was not changed
    5. 0,36s Main.dll
    6. compilation total: 3,22s
    7. Assembly Reload Time: 7,373836s <---
    And once more
    Code (CSharp):
    1. Compilation Report
    2. 1,28s Unity.Physics.Hybrid.dll <-- Still not changed
    3. 0,75s Unity.Physics.Editor.dll <--Still not changed
    4. 0,86s Frameworks.dll
    5. 0,37s Main.dll
    6. compilation total: 3,27s
    7. Assembly Reload Time: 9,6144489s <--
    Just opening and closing it - without touching anything.

    Code (CSharp):
    1. Compilation Report
    2. compilation total: 0,00s <-- now it figured out nothing has changed
    3. Assembly Reload Time: 8,344936s<--- but we still have to reload the domain?
    And even without a code change it seems to reload all assemblies. Can't it avoid doing the reload if it realizes nothing was changed?

    However, what seems to work well now is figuring out the dependencies. In the beginning of asmdef I regularly saw the compiler beeing triggered for everything. Changing something in Frameworks, which is used by Main seems now to correctly triggering a recompilation of those two. The Assembly Reload time obviously still hurts in this scenario as it takes way longer than the actual compilation.
    Code (CSharp):
    1. Compilation Report
    2. 0,66s Frameworks.dll
    3. 0,33s Main.dll
    4. compilation total: 0,99s
    5. Assembly Reload Time: 8,7681951s
    However, luckily sooner or later we will get the configurable enter play mode
    upload_2020-3-14_16-37-26.png
    Which removes the Assembly Reload Time on enter playmode. You still have to do it on recompilation (code change)
    Code (CSharp):
    1. Compilation Report
    2. 1,00s Frameworks.dll <- code change
    3. 0,33s Main.dll
    4. compilation total: 1,34s
    5. Assembly Reload Time: 8,7175188s
    And entering play mode is now instant
    Code (CSharp):
    1. Entering Playmode with Reload Domain disabled.
    2. If you experience any issues, please disable "Enter Play Mode Options (Experimental)" in Editor Settings
    Compare to "no code change" and enter play mode with domain reload
    Code (CSharp):
    1. Compilation Report
    2. compilation total: 0,00s
    3. Assembly Reload Time: 8,4087819s
    And while this is the wrong forum for the Burst Compiler, there it is much worse. Entering playmode:

    Code (CSharp):
    1. UpdateAssemblyCacheDirtyState:           0,0ms
    2. FetchFromAssemblyCache:                  0,0ms
    3. ILCreateModule:                        632,1ms
    4. ILTransform:                           185,4ms
    5. ILAnalyzer:                              0,0ms
    6. ILHash:                                 36,4ms
    7. IL2Module:                              75,0ms
    8. TargetModule:                            3,2ms
    9. StaticModule:                            0,0ms
    10. OptimizeModule:                         64,9ms
    11. CleanupModule:                           0,3ms
    12. PrintModule:                             0,0ms
    13. PrintModule:                             0,0ms
    14. VerifyModule:                            2,7ms
    15. AsmDump:                                 0,0ms
    16. ILDump:                                  0,0ms
    17. Initialize:                             25,6ms
    18. CompileModule:                         372,9ms
    19. LoadModuleFromCache:                     0,0ms
    20. SaveModuleToCache:                       0,0ms
    21. ExternalFunctions:                       1,1ms
    22. ---------------------- -----------------------
    23. Total:                                1080,5ms
    24.  
    25.  
    26. While compiling job: System.Void Unity.Entities.StructuralChange::SetChunkComponentExecute(Unity.Entities.EntityComponentStore*,Unity.Entities.ArchetypeChunk*,System.Int32,System.Void*,System.Int32)
    27. at <empty>:line 0
    28. Burst timings (total:                 6385,0ms)
    29.  
    30. UpdateAssemblyCacheDirtyState:           0,0ms
    31. FetchFromAssemblyCache:                  0,0ms
    32. ILCreateModule:                       1871,0ms
    33. ILTransform:                           117,6ms
    34. ILAnalyzer:                              0,0ms
    35. ILHash:                                384,2ms
    36. IL2Module:                             343,4ms
    37. TargetModule:                            2,9ms
    38. StaticModule:                            0,0ms
    39. OptimizeModule:                       2720,9ms
    40. CleanupModule:                           0,0ms
    41. PrintModule:                             0,0ms
    42. PrintModule:                             0,0ms
    43. VerifyModule:                            6,1ms
    44. AsmDump:                                 0,0ms
    45. ILDump:                                  0,0ms
    46. Initialize:                             25,6ms
    47. CompileModule:                        4093,7ms
    48. LoadModuleFromCache:                     0,0ms
    49. SaveModuleToCache:                       0,0ms
    50. ExternalFunctions:                       0,0ms
    51. ---------------------- -----------------------
    52. Total:                                6385,0ms
    53.  
    54.  
    55. While compiling job: System.Void Unity.Entities.StructuralChange::MoveEntityArchetypeExecute(Unity.Entities.EntityComponentStore*,Unity.Entities.Entity*,System.Void*)
    56. at <empty>:line 0
    57. Burst timings (total:                 7103,5ms)
    58.  
    59. UpdateAssemblyCacheDirtyState:           0,0ms
    60. FetchFromAssemblyCache:                  0,0ms
    61. ILCreateModule:                       1865,8ms
    62. ILTransform:                           115,1ms
    63. ILAnalyzer:                              0,0ms
    64. ILHash:                                395,4ms
    65. IL2Module:                             324,6ms
    66. TargetModule:                            2,9ms
    67. StaticModule:                            0,0ms
    68. OptimizeModule:                       3140,0ms
    69. CleanupModule:                           0,0ms
    70. PrintModule:                             0,0ms
    71. PrintModule:                             0,0ms
    72. VerifyModule:                            6,5ms
    73. AsmDump:                                 0,0ms
    74. ILDump:                                  0,0ms
    75. Initialize:                             25,6ms
    76. CompileModule:                        4806,4ms
    77. LoadModuleFromCache:                     0,0ms
    78. SaveModuleToCache:                       0,0ms
    79. ExternalFunctions:                       0,0ms
    80. ---------------------- -----------------------
    81. Total:                                7103,5ms
    82.  
    83.  
    84. While compiling job: System.Void Unity.Entities.StructuralChange::RemoveComponentEntitiesBatchExecute(Unity.Entities.EntityComponentStore*,Unity.Collections.LowLevel.Unsafe.UnsafeList*,System.Int32)
    85. at <empty>:line 0
    86. Burst timings (total:                 7181,3ms)
    87.  
    88. UpdateAssemblyCacheDirtyState:           0,0ms
    89. FetchFromAssemblyCache:                  0,0ms
    90. ILCreateModule:                       1903,3ms
    91. ILTransform:                           104,4ms
    92. ILAnalyzer:                              0,0ms
    93. ILHash:                                393,6ms
    94. IL2Module:                             320,4ms
    95. TargetModule:                            2,9ms
    96. StaticModule:                            0,0ms
    97. OptimizeModule:                       3198,5ms
    98. CleanupModule:                           0,0ms
    99. PrintModule:                             0,0ms
    100. PrintModule:                             0,0ms
    101. VerifyModule:                            6,4ms
    102. AsmDump:                                 0,0ms
    103. ILDump:                                  0,0ms
    104. Initialize:                             25,6ms
    105. CompileModule:                        4848,9ms
    106. LoadModuleFromCache:                     0,0ms
    107. SaveModuleToCache:                       0,0ms
    108. ExternalFunctions:                       0,0ms
    109. ---------------------- -----------------------
    110. Total:                                7181,3ms
    111.  
    112.  
    113. While compiling job: System.Void Unity.Entities.StructuralChange::AddComponentEntitiesBatchExecute(Unity.Entities.EntityComponentStore*,Unity.Collections.LowLevel.Unsafe.UnsafeList*,System.Int32)
    114. at <empty>:line 0
    115. Burst timings (total:                   72,9ms)
    116.  
    117. UpdateAssemblyCacheDirtyState:           0,0ms
    118. FetchFromAssemblyCache:                  0,0ms
    119. ILCreateModule:                          9,0ms
    120. ILTransform:                             8,0ms
    121. ILAnalyzer:                              0,0ms
    122. ILHash:                                  2,7ms
    123. IL2Module:                               5,1ms
    124. TargetModule:                            0,1ms
    125. StaticModule:                            0,0ms
    126. OptimizeModule:                         32,3ms
    127. CleanupModule:                           0,0ms
    128. PrintModule:                             0,0ms
    129. PrintModule:                             0,0ms
    130. VerifyModule:                            0,8ms
    131. AsmDump:                                 0,0ms
    132. ILDump:                                  0,0ms
    133. Initialize:                              0,3ms
    134. CompileModule:                          60,7ms
    135. LoadModuleFromCache:                     0,0ms
    136. SaveModuleToCache:                       0,0ms
    137. ExternalFunctions:                       0,0ms
    138. ---------------------- -----------------------
    139. Total:                                  72,9ms
    140.  
    141.  
    142. While compiling job: System.Int32 Unity.Entities.ChunkIterationUtility::CalculateEntityCountExecute(Unity.Entities.UnsafeMatchingArchetypePtrList&,Unity.Entities.EntityQueryFilter&)
    143. at <empty>:line 0
    144. Burst timings (total:                   43,0ms)
    145.  
    146. UpdateAssemblyCacheDirtyState:           0,0ms
    147. FetchFromAssemblyCache:                  0,0ms
    148. ILCreateModule:                          8,2ms
    149. ILTransform:                             5,7ms
    150. ILAnalyzer:                              0,0ms
    151. ILHash:                                  1,4ms
    152. IL2Module:                               2,2ms
    153. TargetModule:                            0,1ms
    154. StaticModule:                            0,0ms
    155. OptimizeModule:                         16,5ms
    156. CleanupModule:                           0,0ms
    157. PrintModule:                             0,0ms
    158. PrintModule:                             0,0ms
    159. VerifyModule:                            0,7ms
    160. AsmDump:                                 0,0ms
    161. ILDump:                                  0,0ms
    162. Initialize:                              0,3ms
    163. CompileModule:                          33,0ms
    164. LoadModuleFromCache:                     0,0ms
    165. SaveModuleToCache:                       0,0ms
    166. ExternalFunctions:                       0,0ms
    167. ---------------------- -----------------------
    168. Total:                                  43,0ms
    169.  
    170.  
    171. While compiling job: System.Void Unity.Jobs.IJobExtensions/JobStruct`1<Unity.Entities.GatherChunksAndOffsetsJob>::Execute(T&,System.IntPtr,System.IntPtr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,System.Int32)
    172. at <empty>:line 0
    173. Burst timings (total:                   62,9ms)
    174.  
    175. UpdateAssemblyCacheDirtyState:           0,0ms
    176. FetchFromAssemblyCache:                  0,0ms
    177. ILCreateModule:                          7,0ms
    178. ILTransform:                             6,4ms
    179. ILAnalyzer:                              0,0ms
    180. ILHash:                                  2,1ms
    181. IL2Module:                               5,2ms
    182. TargetModule:                            0,1ms
    183. StaticModule:                            0,0ms
    184. OptimizeModule:                         27,8ms
    185. CleanupModule:                           0,0ms
    186. PrintModule:                             0,0ms
    187. PrintModule:                             0,0ms
    188. VerifyModule:                            0,7ms
    189. AsmDump:                                 0,0ms
    190. ILDump:                                  0,0ms
    191. Initialize:                              0,2ms
    192. CompileModule:                          53,5ms
    193. LoadModuleFromCache:                     0,0ms
    194. SaveModuleToCache:                       0,0ms
    195. ExternalFunctions:                       0,0ms
    196. ---------------------- -----------------------
    197. Total:                                  62,9ms
    198.  
    199.  
    200. While compiling job: System.Int32 Unity.Entities.ChunkIterationUtility::CalculateChunkCountExecute(Unity.Entities.UnsafeMatchingArchetypePtrList&,Unity.Entities.EntityQueryFilter&)
    201. at <empty>:line 0
    202. Burst timings (total:                  135,9ms)
    203.  
    204. UpdateAssemblyCacheDirtyState:           0,0ms
    205. FetchFromAssemblyCache:                  0,0ms
    206. ILCreateModule:                         22,3ms
    207. ILTransform:                            17,4ms
    208. ILAnalyzer:                              0,0ms
    209. ILHash:                                  5,3ms
    210. IL2Module:                              12,2ms
    211. TargetModule:                            0,1ms
    212. StaticModule:                            0,0ms
    213. OptimizeModule:                         60,8ms
    214. CleanupModule:                           0,0ms
    215. PrintModule:                             0,0ms
    216. PrintModule:                             0,0ms
    217. VerifyModule:                            1,0ms
    218. AsmDump:                                 0,0ms
    219. ILDump:                                  0,0ms
    220. Initialize:                              0,2ms
    221. CompileModule:                         107,8ms
    222. LoadModuleFromCache:                     0,0ms
    223. SaveModuleToCache:                       0,0ms
    224. ExternalFunctions:                       0,0ms
    225. ---------------------- -----------------------
    226. Total:                                 135,9ms
    227.  
    228.  
    229. While compiling job: System.Void Unity.Entities.JobChunkExtensions/JobChunk_Process`1<Unity.Entities.GatherComponentDataJob`1<Unity.Entities.SceneReference>>::Execute(Unity.Entities.JobChunkExtensions/JobChunkData`1<T>&,System.IntPtr,System.IntPtr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,System.Int32)
    230. at <empty>:line 0
    231. Burst timings (total:                  130,6ms)
    232.  
    233. UpdateAssemblyCacheDirtyState:           0,0ms
    234. FetchFromAssemblyCache:                  0,0ms
    235. ILCreateModule:                         25,0ms
    236. ILTransform:                            10,0ms
    237. ILAnalyzer:                              0,0ms
    238. ILHash:                                  4,9ms
    239. IL2Module:                              11,6ms
    240. TargetModule:                            0,2ms
    241. StaticModule:                            0,0ms
    242. OptimizeModule:                         61,0ms
    243. CleanupModule:                           0,0ms
    244. PrintModule:                             0,0ms
    245. PrintModule:                             0,0ms
    246. VerifyModule:                            1,0ms
    247. AsmDump:                                 0,0ms
    248. ILDump:                                  0,0ms
    249. Initialize:                              0,3ms
    250. CompileModule:                         100,3ms
    251. LoadModuleFromCache:                     0,0ms
    252. SaveModuleToCache:                       0,0ms
    253. ExternalFunctions:                       0,0ms
    254. ---------------------- -----------------------
    255. Total:                                 130,6ms
    256.  
    257.  
    258. While compiling job: System.Void Unity.Entities.JobChunkExtensions/JobChunk_Process`1<Unity.Entities.GatherComponentDataJob`1<Unity.Scenes.LiveLinkPatcher/LiveLinkedSceneState>>::Execute(Unity.Entities.JobChunkExtensions/JobChunkData`1<T>&,System.IntPtr,System.IntPtr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,System.Int32)
    259. at <empty>:line 0
    260. Burst timings (total:                  193,5ms)
    261.  
    262. UpdateAssemblyCacheDirtyState:           0,0ms
    263. FetchFromAssemblyCache:                  0,0ms
    264. ILCreateModule:                         29,5ms
    265. ILTransform:                            15,6ms
    266. ILAnalyzer:                              0,0ms
    267. ILHash:                                  7,8ms
    268. IL2Module:                              16,2ms
    269. TargetModule:                            0,2ms
    270. StaticModule:                            0,0ms
    271. OptimizeModule:                         98,0ms
    272. CleanupModule:                           0,0ms
    273. PrintModule:                             0,0ms
    274. PrintModule:                             0,0ms
    275. VerifyModule:                            1,0ms
    276. AsmDump:                                 0,0ms
    277. ILDump:                                  0,0ms
    278. Initialize:                              0,3ms
    279. CompileModule:                         155,6ms
    280. LoadModuleFromCache:                     0,0ms
    281. SaveModuleToCache:                       0,0ms
    282. ExternalFunctions:                       0,0ms
    283. ---------------------- -----------------------
    284. Total:                                 193,5ms
    285.  
    286.  
    287. While compiling job: System.Void Unity.Entities.JobForEachExtensions/JobStruct_Process_ECC`3<Unity.Rendering.CopySkinnedEntityDataToRenderEntity/IterateSkinnedEntityRefJob,Unity.Rendering.SkinnedEntityReference,Unity.Rendering.BoneIndexOffsetMaterialProperty>::Execute(Unity.Entities.JobForEachExtensions/JobStruct_Process_ECC`3<T,T0,T1>&,System.IntPtr,System.IntPtr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,System.Int32)
    288. at <empty>:line 0
    289. Burst timings (total:                  147,4ms)
    290.  
    291. UpdateAssemblyCacheDirtyState:           0,0ms
    292. FetchFromAssemblyCache:                  0,0ms
    293. ILCreateModule:                         19,9ms
    294. ILTransform:                             9,7ms
    295. ILAnalyzer:                              0,0ms
    296. ILHash:                                  3,8ms
    297. IL2Module:                              11,6ms
    298. TargetModule:                            0,1ms
    299. StaticModule:                            0,0ms
    300. OptimizeModule:                         81,2ms
    301. CleanupModule:                           0,0ms
    302. PrintModule:                             0,0ms
    303. PrintModule:                             0,0ms
    304. VerifyModule:                            1,0ms
    305. AsmDump:                                 0,0ms
    306. ILDump:                                  0,0ms
    307. Initialize:                              0,2ms
    308. CompileModule:                         123,4ms
    309. LoadModuleFromCache:                     0,0ms
    310. SaveModuleToCache:                       0,0ms
    311. ExternalFunctions:                       0,0ms
    312. ---------------------- -----------------------
    313. Total:                                 147,4ms
    314.  
    315.  
    316. While compiling job: System.Void Unity.Jobs.IJobParallelForExtensions/ParallelForJobStruct`1<Unity.Entities.GatherChunksWithFiltering>::Execute(T&,System.IntPtr,System.IntPtr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,System.Int32)
    317. at <empty>:line 0
    318. Burst timings (total:                  101,9ms)
    319.  
    320. UpdateAssemblyCacheDirtyState:           0,0ms
    321. FetchFromAssemblyCache:                  0,0ms
    322. ILCreateModule:                         16,2ms
    323. ILTransform:                             9,1ms
    324. ILAnalyzer:                              0,0ms
    325. ILHash:                                  3,1ms
    326. IL2Module:                               8,4ms
    327. TargetModule:                            0,1ms
    328. StaticModule:                            0,0ms
    329. OptimizeModule:                         51,0ms
    330. CleanupModule:                           0,0ms
    331. PrintModule:                             0,0ms
    332. PrintModule:                             0,0ms
    333. VerifyModule:                            0,9ms
    334. AsmDump:                                 0,0ms
    335. ILDump:                                  0,0ms
    336. Initialize:                              0,2ms
    337. CompileModule:                          82,2ms
    338. LoadModuleFromCache:                     0,0ms
    339. SaveModuleToCache:                       0,0ms
    340. ExternalFunctions:                       0,0ms
    341. ---------------------- -----------------------
    342. Total:                                 101,9ms
    343.  
    344.  
    345. While compiling job: System.Void Unity.Jobs.IJobParallelForExtensions/ParallelForJobStruct`1<Unity.Rendering.GatherChunkRenderers>::Execute(T&,System.IntPtr,System.IntPtr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,System.Int32)
    346. at <empty>:line 0
    347. Burst timings (total:                  555,3ms)
    348.  
    349. UpdateAssemblyCacheDirtyState:           0,0ms
    350. FetchFromAssemblyCache:                  0,0ms
    351. ILCreateModule:                         72,3ms
    352. ILTransform:                            31,5ms
    353. ILAnalyzer:                              0,0ms
    354. ILHash:                                 15,7ms
    355. IL2Module:                              57,6ms
    356. TargetModule:                            0,2ms
    357. StaticModule:                            0,0ms
    358. OptimizeModule:                        316,2ms
    359. CleanupModule:                           0,0ms
    360. PrintModule:                             0,0ms
    361. PrintModule:                             0,0ms
    362. VerifyModule:                            1,5ms
    363. AsmDump:                                 0,0ms
    364. ILDump:                                  0,0ms
    365. Initialize:                              0,3ms
    366. CompileModule:                         466,7ms
    367. LoadModuleFromCache:                     0,0ms
    368. SaveModuleToCache:                       0,0ms
    369. ExternalFunctions:                       0,0ms
    370. ---------------------- -----------------------
    371. Total:                                 555,3ms
    372.  
    373.  
    374. While compiling job: System.Void Unity.Entities.JobChunkExtensions/JobChunk_Process`1<Unity.Physics.Systems.ExportPhysicsWorld/ExportDynamicBodiesJob>::Execute(Unity.Entities.JobChunkExtensions/JobChunkData`1<T>&,System.IntPtr,System.IntPtr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,System.Int32)
    375. at <empty>:line 0
    376. Burst timings (total:                   84,9ms)
    377.  
    378. UpdateAssemblyCacheDirtyState:           0,0ms
    379. FetchFromAssemblyCache:                  0,0ms
    380. ILCreateModule:                         11,7ms
    381. ILTransform:                             8,0ms
    382. ILAnalyzer:                              0,0ms
    383. ILHash:                                  2,1ms
    384. IL2Module:                               6,1ms
    385. TargetModule:                            0,1ms
    386. StaticModule:                            0,0ms
    387. OptimizeModule:                         42,8ms
    388. CleanupModule:                           0,0ms
    389. PrintModule:                             0,0ms
    390. PrintModule:                             0,0ms
    391. VerifyModule:                            0,7ms
    392. AsmDump:                                 0,0ms
    393. ILDump:                                  0,0ms
    394. Initialize:                              0,2ms
    395. CompileModule:                          70,7ms
    396. LoadModuleFromCache:                     0,0ms
    397. SaveModuleToCache:                       0,0ms
    398. ExternalFunctions:                       0,1ms
    399. ---------------------- -----------------------
    400. Total:                                  84,9ms
    401.  
    402.  
    403. While compiling job: System.Void Unity.Jobs.IJobParallelForExtensions/ParallelForJobStruct`1<Unity.Entities.GatherChunks>::Execute(T&,System.IntPtr,System.IntPtr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,System.Int32)
    404. at <empty>:line 0
    405. Burst timings (total:                 8265,5ms)
    406.  
    407. UpdateAssemblyCacheDirtyState:           0,0ms
    408. FetchFromAssemblyCache:                  0,0ms
    409. ILCreateModule:                       1820,8ms
    410. ILTransform:                           148,2ms
    411. ILAnalyzer:                              0,0ms
    412. ILHash:                                371,5ms
    413. IL2Module:                             347,7ms
    414. TargetModule:                            3,0ms
    415. StaticModule:                            0,0ms
    416. OptimizeModule:                       4597,6ms
    417. CleanupModule:                           0,0ms
    418. PrintModule:                             0,0ms
    419. PrintModule:                             0,0ms
    420. VerifyModule:                            6,1ms
    421. AsmDump:                                 0,0ms
    422. ILDump:                                  0,0ms
    423. Initialize:                             25,6ms
    424. CompileModule:                        6036,9ms
    425. LoadModuleFromCache:                     0,0ms
    426. SaveModuleToCache:                       0,0ms
    427. ExternalFunctions:                       0,0ms
    428. ---------------------- -----------------------
    429. Total:                                8265,5ms
    430.  
    431.  
    432. While compiling job: System.Void Unity.Entities.StructuralChange::RemoveComponentChunksExecute(Unity.Entities.EntityComponentStore*,Unity.Entities.ArchetypeChunk*,System.Int32,System.Int32)
    433. at <empty>:line 0
    434. Burst timings (total:                 8267,7ms)
    435.  
    436. UpdateAssemblyCacheDirtyState:           0,0ms
    437. FetchFromAssemblyCache:                  0,0ms
    438. ILCreateModule:                       1890,7ms
    439. ILTransform:                           105,0ms
    440. ILAnalyzer:                              0,0ms
    441. ILHash:                                403,9ms
    442. IL2Module:                             325,0ms
    443. TargetModule:                            2,9ms
    444. StaticModule:                            0,0ms
    445. OptimizeModule:                       4538,2ms
    446. CleanupModule:                           0,0ms
    447. PrintModule:                             0,0ms
    448. PrintModule:                             0,0ms
    449. VerifyModule:                            6,2ms
    450. AsmDump:                                 0,0ms
    451. ILDump:                                  0,0ms
    452. Initialize:                             25,6ms
    453. CompileModule:                        5937,6ms
    454. LoadModuleFromCache:                     0,0ms
    455. SaveModuleToCache:                       0,0ms
    456. ExternalFunctions:                       0,0ms
    457. ---------------------- -----------------------
    458. Total:                                8267,7ms
    459.  
    460.  
    461. While compiling job: System.Void Unity.Entities.StructuralChange::AddComponentChunksExecute(Unity.Entities.EntityComponentStore*,Unity.Entities.ArchetypeChunk*,System.Int32,System.Int32)
    462. at <empty>:line 0
    463. Burst timings (total:                 8294,7ms)
    464.  
    465. UpdateAssemblyCacheDirtyState:           0,0ms
    466. FetchFromAssemblyCache:                  0,0ms
    467. ILCreateModule:                       1925,6ms
    468. ILTransform:                           101,9ms
    469. ILAnalyzer:                              0,0ms
    470. ILHash:                                380,4ms
    471. IL2Module:                             317,4ms
    472. TargetModule:                            2,9ms
    473. StaticModule:                            0,0ms
    474. OptimizeModule:                       4582,0ms
    475. CleanupModule:                           0,0ms
    476. PrintModule:                             0,0ms
    477. PrintModule:                             0,0ms
    478. VerifyModule:                            7,5ms
    479. AsmDump:                                 0,0ms
    480. ILDump:                                  0,0ms
    481. Initialize:                             25,6ms
    482. CompileModule:                        5953,2ms
    483. LoadModuleFromCache:                     0,0ms
    484. SaveModuleToCache:                       0,0ms
    485. ExternalFunctions:                       0,0ms
    486. ---------------------- -----------------------
    487. Total:                                8294,7ms
    488.  
    489.  
    490. While compiling job: System.Void Unity.Entities.StructuralChange::AddSharedComponentChunksExecute(Unity.Entities.EntityComponentStore*,Unity.Entities.ArchetypeChunk*,System.Int32,System.Int32,System.Int32)
    491. at <empty>:line 0
    492. Burst timings (total:                 8495,1ms)
    493.  
    494. UpdateAssemblyCacheDirtyState:           0,0ms
    495. FetchFromAssemblyCache:                  0,0ms
    496. ILCreateModule:                       1899,7ms
    497. ILTransform:                           105,1ms
    498. ILAnalyzer:                              0,0ms
    499. ILHash:                                389,3ms
    500. IL2Module:                             316,7ms
    501. TargetModule:                            2,9ms
    502. StaticModule:                            0,0ms
    503. OptimizeModule:                       4728,2ms
    504. CleanupModule:                           0,0ms
    505. PrintModule:                             0,0ms
    506. PrintModule:                             0,0ms
    507. VerifyModule:                            4,7ms
    508. AsmDump:                                 0,0ms
    509. ILDump:                                  0,0ms
    510. Initialize:                             25,6ms
    511. CompileModule:                        6170,3ms
    512. LoadModuleFromCache:                     0,0ms
    513. SaveModuleToCache:                       0,0ms
    514. ExternalFunctions:                       0,0ms
    515. ---------------------- -----------------------
    516. Total:                                8495,1ms
    517.  
    518.  
    519. While compiling job: System.Boolean Unity.Entities.StructuralChange::RemoveComponentEntityExecute(Unity.Entities.EntityComponentStore*,Unity.Entities.Entity*,System.Int32)
    520. at <empty>:line 0
    521. Burst timings (total:                 7298,3ms)
    522.  
    523. UpdateAssemblyCacheDirtyState:           0,0ms
    524. FetchFromAssemblyCache:                  0,0ms
    525. ILCreateModule:                       1136,1ms
    526. ILTransform:                           256,8ms
    527. ILAnalyzer:                              0,0ms
    528. ILHash:                                114,3ms
    529. IL2Module:                             158,8ms
    530. TargetModule:                            0,2ms
    531. StaticModule:                            0,0ms
    532. OptimizeModule:                       4632,8ms
    533. CleanupModule:                           0,0ms
    534. PrintModule:                             0,0ms
    535. PrintModule:                             0,0ms
    536. VerifyModule:                            5,7ms
    537. AsmDump:                                 0,0ms
    538. ILDump:                                  0,0ms
    539. Initialize:                              0,7ms
    540. CompileModule:                        6046,6ms
    541. LoadModuleFromCache:                     0,0ms
    542. SaveModuleToCache:                       0,0ms
    543. ExternalFunctions:                       0,0ms
    544. ---------------------- -----------------------
    545. Total:                                7298,3ms
    546.  
    547.  
    548. While compiling job: System.Void Unity.Entities.StructuralChange::CreateEntityExecute(Unity.Entities.EntityComponentStore*,System.Void*,Unity.Entities.Entity*,System.Int32)
    549. at <empty>:line 0
    550. Burst timings (total:                 8589,7ms)
    551.  
    552. UpdateAssemblyCacheDirtyState:           0,0ms
    553. FetchFromAssemblyCache:                  0,0ms
    554. ILCreateModule:                       1908,4ms
    555. ILTransform:                           103,2ms
    556. ILAnalyzer:                              0,0ms
    557. ILHash:                                379,6ms
    558. IL2Module:                             328,6ms
    559. TargetModule:                            2,9ms
    560. StaticModule:                            0,0ms
    561. OptimizeModule:                       4788,2ms
    562. CleanupModule:                           0,0ms
    563. PrintModule:                             0,0ms
    564. PrintModule:                             0,0ms
    565. VerifyModule:                            5,0ms
    566. AsmDump:                                 0,0ms
    567. ILDump:                                  0,0ms
    568. Initialize:                             25,6ms
    569. CompileModule:                        6265,9ms
    570. LoadModuleFromCache:                     0,0ms
    571. SaveModuleToCache:                       0,0ms
    572. ExternalFunctions:                       0,0ms
    573. ---------------------- -----------------------
    574. Total:                                8589,7ms
    575.  
    576.  
    577. While compiling job: System.Boolean Unity.Entities.StructuralChange::AddComponentEntityExecute(Unity.Entities.EntityComponentStore*,Unity.Entities.Entity*,System.Int32)
    578. at <empty>:line 0
    579. Burst timings (total:                 5420,0ms)
    580.  
    581. UpdateAssemblyCacheDirtyState:           0,0ms
    582. FetchFromAssemblyCache:                  0,0ms
    583. ILCreateModule:                        555,5ms
    584. ILTransform:                            97,9ms
    585. ILAnalyzer:                              0,0ms
    586. ILHash:                                 83,0ms
    587. IL2Module:                             183,5ms
    588. TargetModule:                            0,2ms
    589. StaticModule:                            0,0ms
    590. OptimizeModule:                       3617,9ms
    591. CleanupModule:                           0,0ms
    592. PrintModule:                             0,0ms
    593. PrintModule:                             0,0ms
    594. VerifyModule:                            7,2ms
    595. AsmDump:                                 0,0ms
    596. ILDump:                                  0,0ms
    597. Initialize:                              0,2ms
    598. CompileModule:                        4781,0ms
    599. LoadModuleFromCache:                     0,0ms
    600. SaveModuleToCache:                       0,0ms
    601. ExternalFunctions:                       0,0ms
    602. ---------------------- -----------------------
    603. Total:                                5420,0ms
    604.  
    605.  
    606. While compiling job: System.Void Unity.Entities.StructuralChange::InstantiateEntitiesExecute(Unity.Entities.EntityComponentStore*,Unity.Entities.Entity*,Unity.Entities.Entity*,System.Int32)
    607. at <empty>:line 0
    21 "totals" summing up to 77909,6 ms => 77,9s
     
  49. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
    For me entering playmode is slow only once after opening project with burst. Opening/closing time is a lot less important than recompilation time.
     
    mcroswell and MNNoxMortem like this.
  50. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    I did not want to argue against that, which is why I in particular listed the domain reload option. The dev cycle of most people (assumption !sic) more likely consists of opening once (or rarely... except when unity crashes regularly :p) and frequent change->enter playmode cycles.
     
    TeagansDad and mcroswell like this.