Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by unityBerserker · Mar 28, 2018 at 02:28 AM · destroyassemblycompilation

Are Assembly definition files are not build system files?

I spend few days to understand how work assembly definition but one thing is not clear.

In documentation I have fragment:


Assembly definition files are not build system files

Note: The assembly definition files are not assembly build files. They do not support conditional build rules typically found in build systems.

This is also the reason why the assembly definition files do not support setting of preprocessor directives (defines), as those are static at all times.


I do tests.

1st - I marked Assembly Definition file platform only for android. alt text And I checked is there assembly in Library-> ScriptAssemlies folder. There is no dll.

2nd - I add in script preprocessor directives. And I opened dll from Library-> ScriptAssemlies folder with IL spy. Preprocessor directives work. alt text

For me assembly definition support conditional build rules.


My question is what mean that part of documentation? My test are wrong? Could somebody suggest some tests how to check and show this.

@lukaszunity

android-platform.png (5.5 kB)
preprocessor.png (15.6 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Bunny83 · Mar 28, 2018 at 03:57 AM

This is also the reason why the assembly definition files do not support setting of preprocessor directives (defines), as those are static at all times.

They just wanted to say that assembly definition files do basically just group scripts inside a folder into a seperate assembly. Of course all preprocessor directives work just the same way as if you didn't have those assembly definition files.


In a true build system usually support much more configuration options for each "thing" you build. Classical makefiles which are often used for C / C++ project allow to specify certain rules when a certain object / library has to be recompiled. This is mainly required for languages like C++ where the code is compiled seperately and linked seperately. If something has changed where others may depend on means they have to be recompiled as well.


Assembly definition files do not support any of those fancy build rules. They basically just run the compiler several times with (almost) the same options and just group the corresponding files into seperate assemblies. The only options that are different are the assembly references between those different assemblies. The main point of assembly definition files is to cut down compilation time by letting you group your files in logical chunks. Since each chunk is compiled seperately Unity doesn't need to recompile all scripts whenever you change one of them. Only the assembly that contains the changed file need to be recompiled.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image unityBerserker · Mar 29, 2018 at 10:09 PM 0
Share

I thought about your answer and I have found this class-: class AssemblyBuilder

Is this class give me posibilities about which you talk? (I think - yes. But I want to be sure)

avatar image Bunny83 unityBerserker · Mar 30, 2018 at 12:02 AM 1
Share

No, not really ^^. The AssemblyBuilder just gives you direct access to Unity's compilation service. It allows you to just compile certain C# files into an assembly. The C# files and the assembly doesn't need to be part of the project. So it's a simple way to compile a class library without using VisualStudio and actually using the same compiler that Unity uses internally.


Build systems are rarely needed for managed / .NET projects. Unlike C / C++ the compilation time of C# is almost zero. The compilation of large C++ projects can take hours while most C# projects build within seconds. In C# a class library / assembly is much more "standalone" as in C++. If you don't do any breaking changes to an assembly (not method signatures are changed) you usually can just recompile that assembly and just use it. If there is a breaking change you would need to refactor all dependent assemblies anyways which can't be automated (unless you refactor in VisualStudio and have all library projects in the same solution).


Since you usually don't need all those build system features in Unity I'm not sure what you actually search for. Do you miss any particular feature?

avatar image unityBerserker Bunny83 · Mar 30, 2018 at 01:03 PM 0
Share

I creating free tutorials so when I try to explain topic I do it as well as possible. I search for every connection in documentation, forums, blogs and yt channels to collect community knowledge. I ask because I curious about that, and because I not very familiar with C++ .

avatar image vitorbarbosa · Jan 08, 2019 at 03:25 PM 0
Share

Does that mean that I cannot create a script that contains some defines (like UNITY_EDITOR, UNITY_ANDROID, etc.) if I create a assembly definition file for that contains this script?

For what I've tested, I can have a assembly definition for a script and this script uses preprocessor directives. I cannot use them when I pack the scripts into a DLL. Is there something I'm missing?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

82 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

What else happens after the compilation cycle? 0 Answers

Moving file failed 2 Answers

FileNotFoundException (System.reflection) when using SmarFox2.dll 1 Answer

using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers

Asmdef and custom conditional compilation symbols 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges