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.

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;
    }
}

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.

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

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

I also wanted to clear unused assets. I created a few scripts to show (un-)used assets based on the works from New interface for removing unused Unity assets · GitHub
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.