Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
19
Question by FrHaYwOrKs · Apr 12, 2011 at 10:48 AM · assetprojectdependenciesunused

Find Unused Assets In Project

I read in another QA that unused assets are not included in the final build, so they don't put down the game performances.



If Unity is able to exclude those assets on build phase, is it also able to tell me which assets are unused then, so I can clean them up from my disk? How do I do it?



I've seen the "Select Dependancies" action under the "Assets" menu, but it only shows my items relative to the one I selected.

Comment
Add comment · Show 1
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 Fattie · Sep 26, 2018 at 11:14 PM 0
Share

Note

Regarding this very old question, fortunately it is now easy to do:

https://stackoverflow.com/a/49481451/294884

It's that easy nowadays.

5 Replies

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

Answer by Bunny83 · Apr 12, 2011 at 11:47 AM

Unity don't include unused assets in your build. Only assets that are referenced by a scene (that is included in the build) and all assets from the resources folder are included in the build. As far as i know there's no way to "clean up" your project automatically. "Clean up" would mean to completely delete assets and such a task should not be automated ;)

If you want to know what assets are included in your build and how much memory they need, just open the console right after you've created a build and press "Open Editor Log" button.
Notepad will open up (on windows). Just search (CTRL+F) for "***" and you will find this line

***Player size statistics***

after that line you will find very detailed statistics about your build. - Included scenes and size of each - A list of all included assets - And much more...

The clean-up-problem is still there. We have almost the same problem in our project. I think an editor script could do that but you have to do the "used"-check yourself.

Finally here's a Unity-Forum-thread


edit

I've just wrote a little script that extracts the used assets from the editor log file.
It doesn't have much error checking and just search straight into the log. I guess if you create more than one build it will grab the first. You have to restart unity and create a new build to "update" the editor log content.

This script is written for Windows machines. It's just a little helper function. Now you can create a complete file list (via System.IO) and remove the used files.

But be careful: There are even files that should not be deleted!! (the Editor and plugin folder and propably some more)

Use this at your own risk

using UnityEngine; using UnityEditor; using System; using System.IO; using System.Collections; using System.Collections.Generic;

public class UsedAssets {

 public static List<string> GetList()
 {
     List<string> result = new List<string>();
     string LocalAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
     string UnityEditorLogfile = LocalAppData + "\\Unity\\Editor\\Editor.log";
     try
     {
         // Have to use FileStream to get around sharing violations!
         FileStream FS = new FileStream(UnityEditorLogfile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
         StreamReader SR = new StreamReader(FS);

         string line;
         while (!SR.EndOfStream && !(line = SR.ReadLine()).Contains("***Player size statistics***"));
         while (!SR.EndOfStream && !(line = SR.ReadLine()).Contains("Used Assets,"));
         while (!SR.EndOfStream && (line = SR.ReadLine()) != "")
         {
             line = line.Substring(line.IndexOf("% ") + 2);
             result.Add(line);
         }
     }
     catch (Exception E)
     {
         Debug.LogError("Error: " + E);
     }
     return result;
 }

}

Comment
Add comment · Show 6 · 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 FrHaYwOrKs · Apr 12, 2011 at 12:30 PM 0
Share

Thanks a lot for your answer! :D Unfortunately that doesn't solve the clean-up problem in a confortable manner, but at least now I know that it must be done manually, so let's embrace our patience and work it out! :)

avatar image Bunny83 · Apr 12, 2011 at 03:12 PM 0
Share

I've added a simple function to extract the used file list from the editor.log file. $$anonymous$$aybe you can use it to sort out the unused files.

avatar image FrHaYwOrKs · Apr 12, 2011 at 03:42 PM 0
Share

You really are great! :D

avatar image Bill 2 · Nov 06, 2011 at 11:09 PM 0
Share

is it possible to make this output a list of unused items? Searching for 15000 asset names to see if they have been used would be painful to say the least.

Thanks

avatar image Bunny83 · Nov 07, 2011 at 02:52 AM 0
Share

The only way would be to create the used-asset list and then use `System.IO` to get all files in your asset folder and subtract the used assets from all assets. But again be careful when deleting stuff! There might be some assets (like editor script and some other stuff) that aren't included in your build but are used else where. When creating your file-list you should exclude all "editor" folders.

Show more comments
avatar image
18

Answer by Dougomite · May 22, 2013 at 05:33 PM

Couldn't you select all the scenes being used in your project. Right click and select export. That should show you a list of all files that have dependencies with those scenes, meaning all the files actually being used. Export that, then import it into a fresh project. You should then have only the files that are being used. At which point I guess you could delete the old project and all those unused assets along with it.

Comment
Add comment · Show 5 · 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 thesfid · Dec 11, 2013 at 04:53 PM 0
Share

This seems like a decent solution, and I'm going to try it in addition to the Clean Up script in the above answer.

One thing to keep in $$anonymous$$d is you have to select your scene(s), right click "select dependencies", scroll down to make sure the scene(s) are still selected (or CTRL+click to add them back to the selection), and then export to a package.

avatar image thesfid · Dec 11, 2013 at 05:07 PM 1
Share

@Dougomite: this answer works for me, mostly.

Not included when exporting the package is anything in the Standard Assets folder, in my case the Popup.cs file I used for my GUI (found on the wiki, linked below for reference/convenience/props to the author).

Luckily it was just the one script in my case, and it was easy enough to copy it over from the original project. Just something to keep in $$anonymous$$d for those who choose to go this route.

http://wiki.unity3d.com/index.php?title=PopupList

avatar image thesfid · Dec 11, 2013 at 05:12 PM 0
Share

Hmmm, this also seems like it grabs a few things that aren't used. Not sure why that's happening, but either way the project folder is $$anonymous$$UCH cleaner.

avatar image Jesdisciple · Apr 21, 2014 at 10:02 PM 0
Share
  • for a creative solution. But watch out, assets retrieved via Resources.Load won't be in there, so that's "Standard Assets" + "Resources" that you need to copy manually so far. Plus anything your $$anonymous$$m wants in the project but hasn't yet used.

avatar image coolamigo · Jun 24, 2020 at 09:35 PM 0
Share

Worked for me. Still puzzled how the exported package was only 7.3 $$anonymous$$Bs while even my assets alone are over 25 $$anonymous$$B.

avatar image
4

Answer by KristianHJ · Feb 15, 2012 at 01:08 PM

Created a tool on the asset store that automates the process. Lists all unused assets by type. Also lists the used files by filesize, making it easy to optimize buildsize.

Link to asset store

Comment
Add comment · Show 3 · 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 Vicas · May 10, 2013 at 07:39 AM 0
Share

Great! This was just what I needed. Consider putting it on the Unity store! :-)

avatar image davidandrade89 · Feb 17, 2021 at 05:55 PM 0
Share

This is not available anymore

avatar image KristianHJ davidandrade89 · Feb 22, 2021 at 08:31 AM 0
Share

Seems the link was outdated. You can still find it here Link to asset store

avatar image
1

Answer by AvPerov · Jul 08, 2021 at 12:26 PM

Dependencies-Hunter can help you with the task of finding unused assets in your project. It's free and open-source.

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
avatar image
0

Answer by achimmihca · Jan 02, 2018 at 07:45 PM

I also wanted to clear unused assets. I created a few scripts to show (un-)used assets based on the works from https://gist.github.com/karl-/4076464 What it does is read the unity build log to find the assets that are really needed and thus also the assets that are unused. The used and unused assets that are displayed can be filtered simply by selecting a folder in the project view. Works for me using Unity 5.5.0f3.


screenshot.jpg (57.2 kB)
buildinfo.zip (4.5 kB)
Comment
Add comment · Show 2 · 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 davidandrade89 · Feb 17, 2021 at 05:48 PM 0
Share

This seems that might do the work for me! Do you have a readme file to use this?

avatar image achimmihca · Feb 17, 2021 at 06:31 PM 0
Share

I created a git repo and added a description. See https://github.com/achimmihca/Unity3DBuildInfoWindowFindUnusedAssets

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

10 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

Related Questions

Unity brings some asset folders back right after I delete them? 1 Answer

Tutorial Program will not Run (First time in Unity) 1 Answer

Can't find Monobehaviours in Asset Folder when using ObjectPicker 0 Answers

Have I lost my project? Or is this fixable. 1 Answer

Loading/mounting alot of assetbundles 1 Answer


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