Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
5
Question by HypnoticOwl · Jun 22, 2015 at 04:49 PM · c#dll

How can I exclude unnecessary DLLs from my build?

I'm trying to optimize the file size of my game, in particular the android build. I have optimized the assets and set the build stripping level to Use micro mscorlib. However, looking at the Editor.log reveals the DLLs still take up more than 50%:

 Textures      2.7 mb     35.7% 
 Meshes        80.5 kb     1.0% 
 Animations    0.0 kb     0.0% 
 Sounds        0.8 kb     0.0% 
 Shaders       98.2 kb     1.3% 
 Other Assets  177.9 kb     2.3% 
 Levels        110.0 kb     1.4% 
 Scripts       447.4 kb     5.8% 
 Included DLLs 3.9 mb     52.2% 
 File headers  26.2 kb     0.3% 
 Complete size 7.5 mb     100.0% 

3.9mb seemed a bit much, so I looked at which DLLs are actually added. I found this:

 Mono dependencies included in the build
 Dependency assembly - Mono.Security.dll
 Dependency assembly - System.Core.dll
 Dependency assembly - System.dll
 Dependency assembly - mscorlib.dll
 Dependency assembly - UnityEngine.UI.dll
 Dependency assembly - UnityEngine.Networking.dll
 Dependency assembly - UnityEngine.Analytics.dll
 Dependency assembly - Assembly-CSharp.dll
 Dependency assembly - Assembly-UnityScript-firstpass.dll
 Dependency assembly - Assembly-UnityScript.dll

This looks like it can be improved quite a bit. I don't use UnitScript, so Assembly-UnityScript-firstpass.dll and Assembly-UnityScript.dll should be obsolete. Neither do I use Networking or Analytics, so these could be removed as well. Not sure what Mono.Security.dll does or whether UnityEngine.UI.dll is really necessarry.

So, knowing this, how can I get rid of these seemingly unnecessary DLLs?

Comment
Add comment · Show 6
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 HypnoticOwl · Jun 25, 2015 at 09:33 AM 0
Share

I found references to the dlls in the various .csproj files and their locations in the Library folder and deleted them by hand, but Unity overwrites those files. :/

avatar image Bunny83 · Jun 25, 2015 at 10:35 AM 4
Share

If you have UnityScript assemblies that means that you have at least one UnityScript (Javascript) file in your project.

  • Assembly-UnityScript-firstpass.dll contains all UnityScript files inside the Standard Assets / plugins folder.

  • Assembly-UnityScript.dll contains all UnityScript files which are placed outside of the Standard Assets / plugins folder.

In general all your scripts inside your project are always included in a build. That's because Unity can't deter$$anonymous$$e which classes are actually used since AddComponent also works with a string argument.

So just remove unused scripts from your project. Chances are high that you have imported some standard assets which are written in UnityScript.

I haven't done builds recently but i don't think $$anonymous$$ono.Security is included by default. You might use some functions from there ($$anonymous$$D5? SHA?). It's also possible that you have a third party library which relies on those.

System.dll usually shouldn't be included as well. You might use the System.Xml namespace somewhere. If you need Xml you either have to accept that one or search for a lightweight xml framework. At least in the past the System.dll was referenced by the "boo runtime" which is used by the UnityScript runtime. So it might vanish as well if you kick out all UnityScript files.

Not sure about UI / Networking / Analytics

avatar image HypnoticOwl · Jun 25, 2015 at 12:19 PM 1
Share

There were indeed some .js files left. I should have let windows search the folders to find them all. After removing the Assembly-UnityScript dlls were gone (3$$anonymous$$B improvement)!

System.dll is there, because I use IEnumerable for Coroutines (System.Collections), Lists (System.Collections.Generic), BinaryFormatter (System.Runtime.Serialization.Formatters.Binary) and FileStream (System.IO). Not sure if I really want to get rid of all that.

$$anonymous$$aybe that's where $$anonymous$$ono.Security comes from. We don't use any plugins as far as I'm aware.

avatar image Bunny83 · Jun 25, 2015 at 01:01 PM 2
Share

@HypnoticOwl: As far as i know all things you've mentioned are actually defined in the mscorlib. Don't get fooled by the namespace names. Not everything in the System or sub namespace belong to the System.dll.

For example look at the FileStream docs. It's in the System.IO namespace but declared within the mscorlib.

You might want to open the System.dll in ILSpy and see what's actually defined in there which you might be using.

Of course if you use third party stuff it's getting complicated. However with ILSpy you can even figure out which of those assemblies reference which other assemblies.

Hmm it looks like the UnityEngine.dll is by itself referencing System.dll, $$anonymous$$ono.Security.dll and System.Core.dll. Not sure how well byte-code-stripping works on those...

avatar image HypnoticOwl · Jun 26, 2015 at 07:36 AM 0
Share

@Bunny83: Huh, that's weird. That must have changed quite recently. The manual is still clai$$anonymous$$g:

 By default, Unity includes only the following DLLs in the built player:
 
     mscorlib.dll
     Boo.Lang.dll
     UnityScript.Lang.dll
     UnityEngine.dll


http://docs.unity3d.com/$$anonymous$$anual/ReducingFilesize.html

I have played around with the Stripping Level in the Player Settings, but that doesn't seem to make a difference.

Do you think this was intentional? $$anonymous$$aybe I should report it...

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by masterjohn12 · Nov 13, 2017 at 11:49 AM

I asked it in stack overflow: https://stackoverflow.com/a/47254728/7582969

Comment
Add comment · 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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

dll error when build 4 Answers

Bringing in classes from a DLL 1 Answer

Using 2 DLLs with the same name 2 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