removing unused materials and textures

Hi there,
is there any method to get rid of unused materials from an unity project? I’m just wondering if anyone could help me with this problem because I have a huge quantity of materials that are not assigned to specific meshes.
Furthermore I’d like to know if I have to delete the unused textures manually or the process above replaces them automatically.

In the meanwhile I thank you!

Yes u can remove all unused assets from project. What u have to do Just right click on Scene file in project folder and click on select dependencies, show its show u how much assets u used in a scene.

2 Likes

Delete the files in the Project view in Unity. That also deletes them in your computer file structure.

Do not delete the files in Finder, Windows Explorer or any other way outside Unity as that corrupts the metadata of the project.

1 Like

Hi UnityCoder, thanks for your reply. Your suggestion is very useful.
Now I visualize all the assets used. In the same way, I’d like to know if it is possible to visualize all the unused assets. Is there a way to invert the selection?

Ha… Ha… No i dont know how to do that and i m sure its not possible. But Just do onething with all selected dependencies just right click and export package and save that package, then after create new project and import that package into that brand new project. Thats it.

You could make a script which took all of your scenes one by one, and made a complete list of all dependencies of these scenes. You could then loop through all assets in the assetDatabase, and see if they were present in this list. If not, delete them.
There is a but: Scriptet classes or dll’s which are just referenced through scripts used in the scene (either by being statically issused from within a class, or from being imported by “Using” directives) won’t be noticed by the build-in select dependencies command. Also shader fall backs and cg includes won’t be discovered as well. So as long as you only delete materials, geometry, prefabs and such, it would work fine.

Wrote an editorwindow tool that will help. It lists all unused objects by type, and have an easy interface to delete them. Added the tool to the unity asset store: Unity Asset Store - The Best Assets for Game Making

NB: It also lists filesize of files included in build. That should help to reduce buildsize.