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