Speed Up Compile Times in Unity with Assembly Definitions

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ส.ค. 2024
  • The first 1000 people to use the link will get a free trial of Skillshare Premium Membership: skl.sh/gamedev...
    Learn how to get back into the Editor faster after making changes to your code by using Assembly Definition Files in your project!
    Gameplay Logic using Bolt: • Building A Tutorial in...
    Attributes and Reflection: • Using Attributes to Ma...
    Compute Shaders: • Getting Started with C...
    --------------------------------------------------------------------------------
    Want to support the channel?
    ▶️ Help fund new episodes by joining the Patreon - / gamedevguide
    Use these links to grab some cool assets from the asset store:
    Get the Must Have Assets! - assetstore.uni...
    Free Unity Assets! - assetstore.uni...
    New on the Asset Store! - assetstore.uni...
    Top Paid Asset Store Packages - assetstore.uni...
    Asset Store Partners - assetstore.uni...
    --------------------------------------------------------------------------------
    Socials and Other Stuff:
    • Subscribe - www.youtube.co...
    • Join the Discord - / discord
    • Twitter - / gamedevguideyt
    • Facebook - / gamedevguideyt
    • Instagram - / gamedevguideyt

ความคิดเห็น • 132

  • @GameDevGuide
    @GameDevGuide  3 ปีที่แล้ว +13

    The first 1000 people to use the link will get a free trial of Skillshare Premium Membership: skl.sh/gamedevguide05211

    • @GameDevGuide
      @GameDevGuide  3 ปีที่แล้ว +6

      Something I missed out in the video is that's worth noting is that if you've got Editor scripts within your Asset Store files, you will also need to manually sort them between runtime and editor code and split that assembly up into a ThirdParty.Editor assembly to avoid build errors!

  • @smally5739
    @smally5739 3 ปีที่แล้ว +107

    Your use of multi scenes is pretty interesting, would be great to see a tutorial on that.

  • @mrx10001
    @mrx10001 3 ปีที่แล้ว +105

    You should probably mention in the video, that using assembly definitions, will require you to update the definition, if you suddenly add a dependency in the code. Ie. When you add a "using namespace" to the top of the file. That massively caught me off guard when I first used them, since I thought it would simply update them automatically. Or give some kind of warning. But not, it simply gives you a compile error saying that the reference doesn't exist.

    • @mfatihbarut
      @mfatihbarut 3 ปีที่แล้ว +5

      yes definetely and it would be nice to add somepart how to do it.

    • @withoutPurpose
      @withoutPurpose ปีที่แล้ว +2

      so about that....?

  • @Mashyny
    @Mashyny 3 ปีที่แล้ว +91

    Nice. I never bothered to look into Assembly Definitions because I thought they were hard to setup. Thanks for the great explanation.

    • @capsey_
      @capsey_ 3 ปีที่แล้ว +13

      I was shocked when I learned how easy Assembly Definition creating and organizing in Unity actually is

    • @Dominik-K
      @Dominik-K 3 ปีที่แล้ว +4

      Same for me, this video probably saved me weeks of me life in compile times

  • @queenofpain6483
    @queenofpain6483 3 ปีที่แล้ว +28

    WORKING LIKE A CHARM!!!!!
    I just created an assembly definition for my Script folder and added URP as dependencies. Load time reduced from about 20 seconds to 1 second.

  • @benjamingerd4703
    @benjamingerd4703 3 ปีที่แล้ว +6

    Thank you kindly! This has helped me reduce my game's compile time from "This takes so long, I don't enjoy working on this game anymore" back to "This is so much fun again, just like back in the old days when my project used to be small".

  • @user-ti4fb5sd8w
    @user-ti4fb5sd8w 3 ปีที่แล้ว +20

    This might be the only tutorial for lowering compile time.
    I have been searching for something like this for a long time.
    thank you very much!

  • @marty34534
    @marty34534 2 ปีที่แล้ว +3

    I think I spent the good half of the afternoon trying to understand ASMDEF via Unity's documentation and I wasn't much wiser after. Your video really helped me to understand! Thank-you very much!

  • @richardrothkugel8131
    @richardrothkugel8131 ปีที่แล้ว +2

    I'm working in the Observer Pattern, so none of my classes have dependencies or references. I had been thinking about adding assemblies for a long time, but a close package developer I worked with advised that it wouldn't work with his package (backward compatibility issue). In this case that code just got moved to it's own non-assembly area. I highly recommend learning the observer pattern and using assemblies. Saves a lot of time on developing and testing new features.

  • @epiphanyatnight8732
    @epiphanyatnight8732 3 ปีที่แล้ว +1

    This channel is one of the very few for which I enables push notifications. Truly great work Matt, thank you very much for the content you create!

  • @saadbintarique1894
    @saadbintarique1894 3 ปีที่แล้ว +1

    Thanks for putting this up. I've been trying to set up assemblies in a project properly. It's really difficult when you are working in a team and not everyone understands how assembly works and what architecture to follow. Hoping that this video gets us up to speed a little.

  • @Denzill7
    @Denzill7 ปีที่แล้ว

    Happy I found this video, it's surprisingly hard to find a video that breaks this down in an organizational way, I really appreciate it!

  • @DisturbedNeo
    @DisturbedNeo 2 ปีที่แล้ว +2

    In essence, an “Assembly Definition” is the equivalent of a “Project” in Visual Studio.
    I follow the ardalis model for clean architecture, so I put the bulk of my logic in the *Core* Assembly, some data access stuff will be in an *Infrastructure* Assembly, and UI Code is also worth putting in its own assembly.
    UI depends on Core (and maybe Infrastructure).
    Core depends on Infrastructure.
    Infrastructure has no dependencies.

  • @Bloodthirst
    @Bloodthirst 2 ปีที่แล้ว +1

    Another good thing about splitting code into assembly definitions is actually being able to hide system specific stuff with the "internal" keyword , and cleanly separate between the internal classes/methods and the exposed part that other systems/assemblies can use (pretty much an API) , that also ensures that you can take any assembly with it dependencies and drag and drop it into any project with no worries since all of the it's dependencies are there.

  • @HordorDev-ms7sj
    @HordorDev-ms7sj 7 หลายเดือนก่อน

    The best Tutorial about WHY DO I NEED THIS PUZZELS ;D

  • @TheOriginalFish
    @TheOriginalFish 3 ปีที่แล้ว +1

    Thanks matt, Great explanation of something I've been so lazy to learn for the past 5 years,
    Keep up the awesome content, cheers!

  • @mica8076
    @mica8076 10 หลายเดือนก่อน

    I've watched a few of your videos, but this one got you a new Subscriber. Thanks so much and keep up the great work!

  • @nand3kudasai
    @nand3kudasai 2 ปีที่แล้ว

    I really liked how you've made this video. Super clear and easy to understand. So quite calm.

  • @DavidBarile
    @DavidBarile 11 หลายเดือนก่อน

    "Excellent segue... nailed it!" 🤣That was hilarious! The actual content is very useful too. Thanks! Nailed it!

  • @nix3l_
    @nix3l_ 3 ปีที่แล้ว +1

    Ive stopped using unity but ill keep watching your great videos :)

  • @NelsonBilling
    @NelsonBilling 6 หลายเดือนก่อน

    Great advice, and thanks for explaining and showing how to do it so succinctly!

  • @dailydoseofhalal6767
    @dailydoseofhalal6767 3 ปีที่แล้ว +14

    I was literally just searching for this 3 hours ago lol

    • @F3L0
      @F3L0 3 ปีที่แล้ว

      SAME

  • @Guitoon
    @Guitoon 2 ปีที่แล้ว

    This is the kind of vidéo that I would like to like twice or even more.
    Thanks a lot for this tip !

  • @kay-dp8qw
    @kay-dp8qw ปีที่แล้ว

    Thank you so much, I've learned a lot in this video! Definitely will try it out in my next project. Big thanks!

  • @BasonIndieDev
    @BasonIndieDev ปีที่แล้ว +1

    Thanks a lot. Now the project compiles not 20 seconds, but 2-5!!!!!

  • @lgtwzrd
    @lgtwzrd 3 ปีที่แล้ว

    Thanks man. That saved me tons of time and less distractions for sure!

  • @alpercizmeci4039
    @alpercizmeci4039 ปีที่แล้ว

    OMG the first 25 seconds of this video was describing exact same situation I found myself in lol.

  • @ChiliDev
    @ChiliDev 3 ปีที่แล้ว

    Awesome! I shall keep this in mind when I start another project. Thanks dude

  • @Entereri
    @Entereri 3 ปีที่แล้ว

    Great tutorial. I wasn't even aware of this feature in Unity

  • @blackwarrior823
    @blackwarrior823 3 ปีที่แล้ว

    I like your tutorials, they are very much neet and clean, quite easy to understand and very useful :)

  • @lonelycrescendo
    @lonelycrescendo 2 ปีที่แล้ว +1

    I've cried, almost given up, and quit for a full week on my game just because of this. I just couldn't take it anymore. I wanted to die. It was excruciating.

  • @bradleysmith9924
    @bradleysmith9924 ปีที่แล้ว

    Thank you very much for this one Matt! :)

  • @KonaiNobi
    @KonaiNobi ปีที่แล้ว

    Super great information 😁 thanks for this!

  • @untilisee
    @untilisee ปีที่แล้ว

    Thanks a lot! Your video saved me)

  • @phoder1
    @phoder1 3 ปีที่แล้ว +8

    I used assemblies to make my own packages (which I really recommend doing), but I never thought of using it inside my main project or over downloaded assets, great tutorial!
    I watched a video by Infallible Code saying namespaces does the same effect, did you use namespaces in your project (not just a root one), before moving to assemblies?

    • @GameDevGuide
      @GameDevGuide  3 ปีที่แล้ว +3

      Yep, I use namespaces too!

    • @phoder1
      @phoder1 3 ปีที่แล้ว +2

      @@GameDevGuide and you say there's a farther improvement by moving to assemblies? Do you have a source/test for that, or is it significant enough you can feel it instantly?

  • @davitsedrakyan
    @davitsedrakyan 2 ปีที่แล้ว

    Great Tutorial to Assembly Definitions!

  • @martinl.2033
    @martinl.2033 ปีที่แล้ว

    thank you so much!

  • @aoikishu
    @aoikishu 2 ปีที่แล้ว

    Wonderful tutorial, thank you!

  • @DanPos
    @DanPos 3 ปีที่แล้ว

    Excellent video as always :)

  • @mr3shba
    @mr3shba 5 หลายเดือนก่อน

    I love unity and other commercial game engines for this reason, when i make games in my own game engine making stuff in different assembly definitions (aka Namespaces) it takes ages in unity its just a few buttons and vwallah magic just happens.

  • @PENSIONEROVify
    @PENSIONEROVify 3 ปีที่แล้ว

    Thank you for this video!

  • @ROCKSMASHER
    @ROCKSMASHER 2 หลายเดือนก่อน

    Bro you just predicted me in start 😂😂

  • @TroyMakesGames
    @TroyMakesGames 3 ปีที่แล้ว

    Amazing video! Thanks GDG

  • @NickPavlov00
    @NickPavlov00 2 ปีที่แล้ว

    Very useful tip thank you!

  • @RayHorn5128088056
    @RayHorn5128088056 ปีที่แล้ว

    Run Unity from SSD. Get a Threadripper. This works for me.

  • @brianjensen2532
    @brianjensen2532 3 ปีที่แล้ว +6

    Simply adding assembly definitions for External assets will not work very well. For instance I get 800 errors about UnityEditor missing reference when trying to do a build, but the error never appears unless I try to build. And that is just the external packages. Not sure what you did to allow your assembly definitions to access UnityEditor and UnityEngine but those assemblies are not available in the drop down in Unity 2020.3+. I've deemed Assembly Definitions to be a project breaking worthless feature that really needs a complete rework. I wont use them as they break projects.

    • @spikebor
      @spikebor ปีที่แล้ว +3

      because when in build, normally Unity will make anything in an Editor folder an automated assembly for it.
      But when you group all asset store assets under one folder and using one assembly, no automate Editor assembly for you.
      You will build failed with tons of errors, this is the misleading part of this video.
      You have to go to each asset's Editor folder, make an assembly there, and this Editor assembly will reference it's main assembly.
      Example : Fimpossible, Fimpossible.Editor, the .Editor will reference the non-Editor (runtime assembly).
      The Editor assembly will have to do another step: make target platform to none other than Editor.
      If you use a looot of asset store assets, then this introduces a big workload, also is a pain when you update said asset, and some asset will require you to delete and reimport again (because they move/remove scripts), then you have to remake the asmdef for them again.
      A lot of works will have to be done, unless you tell your team to not update assets frequently.

  • @KentHambrock
    @KentHambrock 3 ปีที่แล้ว

    This is genious. Thank you!

  • @LoOnarForge
    @LoOnarForge 2 ปีที่แล้ว +2

    Thanks for the great video. Is it just me or things are getting slower and slower. I got an empty project made on the mobile template, URP with "Hello World" script and reloading scripts takes around 17 seconds, and starting an empty scene takes around 12 seconds. Is this mental or this is a new reality?
    I got a few packages, nothing from the Asset Store yet. Is there anything I can do to change it? I tried to move packages to an assembly but I can't do that .
    Thanks if someone can clarify it for me.

  • @neintonine
    @neintonine 2 ปีที่แล้ว

    this shit is crazy :D I have it setup on my Package-Test project and dang... Its awesome. I save the file, looked into unity and the box doesn't show up. But everything was compiled :D That is cool. Thank you soo much.

  • @HackHeyner
    @HackHeyner ปีที่แล้ว

    M-A-G-I-C-AL!!!

  • @mohammadsadeghlavaie5560
    @mohammadsadeghlavaie5560 3 ปีที่แล้ว

    Thank you!

  • @sps014
    @sps014 3 ปีที่แล้ว

    That's awesome, dotnet 6 has also managed to reduce compile time.
    Hopefully in six months we get to see initial .net support.

  • @TheDaanDude
    @TheDaanDude 3 ปีที่แล้ว +1

    I probably did something wrong. On my end it took twice as long when I did this to my assetstore packages xD
    Thank god for version control

  • @runrajrun
    @runrajrun ปีที่แล้ว

    Thanks a ton! :D

  • @asli9152
    @asli9152 ปีที่แล้ว

    Its crazy boost!

  • @omerfarukbykl6097
    @omerfarukbykl6097 3 ปีที่แล้ว

    Thanks this is helpful

  • @trashcaster
    @trashcaster 2 ปีที่แล้ว +1

    I wish Unity had an automated way of doing this (even if it was in a project settings Assembly Definitions dropdown for "Manual" and "Automatic")

  • @_g_r_m_
    @_g_r_m_ 3 ปีที่แล้ว

    I've never ever had this problem but watching anyways

  • @justinwhite2725
    @justinwhite2725 3 ปีที่แล้ว +3

    4:54 this is a good tip, but it's not that simple. If you do this then editor folders will be Includd in that assembly and it's a huge mess. I forgot how I worked around that in my last project.

  • @PreslavKolev
    @PreslavKolev 3 ปีที่แล้ว

    OMG. I cant belive you iploaded a video

  • @MohammadFaizanKhanJ
    @MohammadFaizanKhanJ 3 ปีที่แล้ว

    Have seen different videos on the this. I thiny I should try it for my scripting oriented projects

  • @DerperDoing
    @DerperDoing 3 ปีที่แล้ว +1

    Thanks for making a video on this topic. Didn't know about Assembly Definitions before this. I'll research more about it for sure.
    I have a query although not related to this topic but something I noticed in your project. You have a Scriptable Object folder and Assembly Definitions work well with less dependency, perhaps, are you using Scriptable Object Events Architecture? If yes, what's your experience with using that architecture for object pooling, spawning and unspawning them?
    For example, object pooling coins and Spawner spawning & unspawning them. A script on the coins raises a void event after 4 seconds of being spawned that it needs to be disabled now. Spawner subscribed to this void event puts it back in the pool. How does it figure out which of the active coins raised that event?
    Or may be can you create a video on your workflow of how do you use Scriptable Object Architecture for different operations in your projects to reduce coupling?

  • @whosnooby
    @whosnooby 3 ปีที่แล้ว

    I don't have this problem but I'm always down to learn :)

  • @charuzu1397
    @charuzu1397 3 ปีที่แล้ว +1

    Do unity events in a class in a different assembly still work?

  • @AggyLovesGames
    @AggyLovesGames 2 ปีที่แล้ว

    Holy fuck man, the most basic of moving asset-store away from my own code increased compile time by at least 50 fold. From 30 seconds to less than a second. Maybe this is a lesson on me checking out too many things in the asset store...

  • @nocultist7050
    @nocultist7050 3 ปีที่แล้ว +2

    Well... I was trying (and failing) to compile ArmorPaint but close enough. XD

  • @pandaengine
    @pandaengine 3 ปีที่แล้ว

    Great video as always, and eerily on time yet again 😆
    I tried to split my project into Assembly Definitions the other day, it was a jumbled mess. I have assets like Google Play Games that restrict their existence into a folder directly inside Assets. How do you suggest organizing these?

  • @TechDunk
    @TechDunk ปีที่แล้ว

    I want to use assembly definitions from the start in my latest project, to make sure the project stays reasonably snappy.
    I got it working up until I utilized my custom attributes. Here everything works in the inspector, since the attributes reference editor code I have to make another asm def for them only included in the editor.
    This works great in editor, but when I start building my project I get errors that the custom attribute namespaces cannot be found. When I enable the asm def for all platforms I get errors that the custom attributes reference editor code, not allowing me to build.

  • @ErrorUncertainty
    @ErrorUncertainty ปีที่แล้ว

    Can anyone recommend a video or a guide for how to start out structuring code well & using assembly definitions as a novice Unity user? I want to avoid getting to the point where it's taking minutes to recompile, but this video is a bit above my level.

  • @rwells242
    @rwells242 ปีที่แล้ว

    One issue i found moving asset from the asset srtore is that they loose their Editor Abilities asthey seem to hard code its location in script

  • @DarthBiomech
    @DarthBiomech ปีที่แล้ว

    4:45
    Well, sure, except when I try to add the missing reference it asks for - it just isn't there. What do I do in this case?

  • @notanacorn703
    @notanacorn703 2 ปีที่แล้ว +1

    POV: you create a assembly definition for every script you make, reload time go BRRRR

  • @stefan429
    @stefan429 ปีที่แล้ว +1

    how does this compare to just putting all classes in namespaces?

    • @kay-dp8qw
      @kay-dp8qw ปีที่แล้ว

      would be interested in that as well

  • @SoaringSimulator
    @SoaringSimulator 3 ปีที่แล้ว

    Awesome! and about loading resources at runtime as Asset Bundle external collection of assets to reduce Project size?

  • @barbarusonline
    @barbarusonline 2 หลายเดือนก่อน

    Why exactly didn't you include TextMeshPro in the External directory/asmdef?

  • @DoorBuster21st
    @DoorBuster21st 3 ปีที่แล้ว

    Great video super helpful. How about unity load times is their anything for that?

  • @CHEEZEyCHEEZE
    @CHEEZEyCHEEZE 2 ปีที่แล้ว

    How does this Effect ECS DOTS?

  • @samwayms4291
    @samwayms4291 2 ปีที่แล้ว

    After that i can't build my project, how use assembies and can build?

  • @wassilzine4473
    @wassilzine4473 ปีที่แล้ว

    How did you move them

  • @twibby6625
    @twibby6625 2 ปีที่แล้ว

    Did you had to specifically create the "Project" folder ? Is it a special name (like Resources) or you could have kept your "Asset store packages" folder and create an Assembly Definition inside of this folder ?

  • @override9872
    @override9872 ปีที่แล้ว

    Hello, very informative video. Which VSCode add-on you use to view the assemblies? Thank you

  • @Tymon0000
    @Tymon0000 3 ปีที่แล้ว

    You don't need to move every piece of your editor code to a folder with an editor assembly definition. You can use Assemble Definition References.

    • @pythonxz
      @pythonxz ปีที่แล้ว

      Doesn't editor code automatically get put into it's own assembly?

    • @Tymon0000
      @Tymon0000 ปีที่แล้ว

      @@pythonxz Yes, I think it does. You can however override this behavior with assembly definitions and their references.

  • @domasgarsvas5651
    @domasgarsvas5651 3 ปีที่แล้ว

    Could you maybe do a tutorial on unity's GraphView? I tried my hand at it but it sorely lacks tutorials and forum posts about it, though it looks like a good way to create custom editor tools for content creation like scripted event chains, dialogs or quests.

  • @soolydooly1234
    @soolydooly1234 10 หลายเดือนก่อน

    Wow! this is good! But, I nearly put my player scripts in an assembly which is referenced by almost every script in the game...

  • @cat-boy1357
    @cat-boy1357 2 ปีที่แล้ว

    General question, would this be worth doing preemptively, instead of reactively when it starts to slow down.
    Like at the start of the project. Grouping content such as; asset store, editor, runtime, platform, etc, beforehand.

  • @makadi86
    @makadi86 ปีที่แล้ว

    does ssd hard drives will make any difference?

  • @vaporbabe3779
    @vaporbabe3779 ปีที่แล้ว

    Question: I have Unity 2021.3.9f1, and the compile times are insane, I literally have a new project without external assets, I just added 2 scripts and the compile time goes up to 1 min. In this case this video does not solve my problem, any help?

  • @cinnamonrollstudios3228
    @cinnamonrollstudios3228 2 ปีที่แล้ว

    Would throwing third party assets into the plugins folder have the same effect (both wont recompile unless directly edited)

  • @keenanrvndr
    @keenanrvndr 3 ปีที่แล้ว

    Hi Matt!

  • @TheOriginalDarkGlitch
    @TheOriginalDarkGlitch 3 ปีที่แล้ว

    So we should separate asset store code, but what about Editor code? That has to have its own AD as well? So just a folder named "Editor" with all the other scrips dumped into it? I'm having trouble building a project thanks to some asset store editor code that is causing issues.

  • @TanukiDigital
    @TanukiDigital 3 ปีที่แล้ว

    I am definitely going to have to implement this soon. (like tomorrow!) Does this speed of shade compile as well? My script code recompile chugs enough so I can go check my email, but my shader code recompile chugs so much I could go and make lunch.

  • @ytubeanon
    @ytubeanon 2 ปีที่แล้ว

    6:46 what setting do you use to reveal Assembly type files in the Project treeview? they don't appear in mine

  • @georgebush3327
    @georgebush3327 ปีที่แล้ว

    Oh this is the video i need
    Unity: Hold On. Waiting for 30:03
    Ok I think I have time

  • @castlecodersltd
    @castlecodersltd ปีที่แล้ว

    Great tutorial. ☺ When I add an assembly I can no longer add a Monobehaviour derived script, that is now in the assembly, as a Component in GameObjects - any idea why that would be please? It all compiles fine and runs without issues, it just won't let me add them from the assembly

    • @castlecodersltd
      @castlecodersltd ปีที่แล้ว

      Turns out that some of the files needed editing to force a recompile. Once I did that it worked. 🤦‍♀

  • @mateusz.habdank.wojewodzki
    @mateusz.habdank.wojewodzki 3 ปีที่แล้ว

    Is the Unity Event System a good method to replace references?

  • @restushlogic5794
    @restushlogic5794 3 ปีที่แล้ว

    Hey, does it works with Plugins asset like Odin Inspector move to external folder?

  • @mohokhachai
    @mohokhachai ปีที่แล้ว

    👍 👌

  • @kainaris
    @kainaris 8 หลายเดือนก่อน

    Bro I literally created an empty URP project and added 1 SINGLE SCRIPT WITH JUST A FEW LINES OF CODE and it take MORE THAN 1 MINUTE TO COMPILE FOR EVERY LITTLE CHANGE it just demotivates me so much I don't wanna make games anymore. I get this video more or less but I have no idea how to apply it here. I have no external assets or anything. I hate this.

  • @behnamrasooli8801
    @behnamrasooli8801 3 ปีที่แล้ว

    Don't forget to also untick the #Auto_Referenced in the assembly definition asset.

    • @castlecodersltd
      @castlecodersltd ปีที่แล้ว

      Why?

    • @behnamrasooli8801
      @behnamrasooli8801 ปีที่แล้ว +1

      @@castlecodersltd More references means more compile time. Unless you have some code in the default assemblies that references code in your custom assembly, you shouldn't tick that option.

  • @nobytes2
    @nobytes2 11 หลายเดือนก่อน +1

    Bro I'm just switching to godot, unity has become a huge pain, all this bs with assemblies is extra work that wasn't needed before wtf