Cleaning Project of unused scripts

I am cleaning my project and want to get rid of scripts that are not used.
Is there a way to identify what scripts are used and which are not?

If you’re using Unity 5 or have a pro license in older Unity versions you can select all your scenes in the project window and select to export them as a package. Unity will show you a list of all assets that are referenced in those scenes (and by prefabs used in the scenes), so you can check there if a script from your project is being used.

Another option could be to right click in an asset and select “Find references in scene” but it’s slower and you have to check on each scene, one by one.

Hi @diggerjohn @dreg_master @jwulf @Xarbrough ! There’s a tool made especially for getting rid of unused assets and scenes in a project. I guarantee it’s the easiest way possible without losing context :slight_smile:

Asset Cleaner PRO - Clean | Find References | Utilities Tools | Unity Asset Store

It allows you to:

  • Hunt down the unused Assets and Scenes (not only scripts) without any need to generate build
  • The unused assets are shown directly in your Project view (regarding the scripts, see below)
  • Check the dependencies/references for those which are used somewhere (supports Nested Prefabs and all asset types).

One note regarding the Scripts themselves - those aren’t shown red in the Editor as it’s not possible to know whether the script isn’t used outside of Unity. However there’s a way we’re hunting the unused scripts down ourselves.

There are 3 types of scripts important for this topic:

  1. Non-related to Unity serialization

  2. Derived from MonoBehavior

  3. Derived from ScriptableObject

Because of #1, we need to be careful with stating whether a certain script could or could not be removed.

We ourselves are using the Asset Cleaner for the purpose of cleaning scripts the following way (step by step):

  1. In Asset Cleaner, we’re selecting the given script and checking its usages.
  2. If there are some (see example on screenshot below), we remove the linkages manually
    alt text
  3. If there are none, we remove it.

Asset Cleaner is capable of showing the usages within Unity:

  • For MonoBehavior-derived classes: Usages in prefabs and scenes (after unfolding one, see screenshot above) are shown
  • For ScriptableObject-derived classes: All script instances will be shown

In a nutshell:
alt text

alt text

Any question you have, you’ll get a quick answer:-)
You can ask here, via email:

Thanks and looking forward to seeing you among our happy users:)

Denis from Gamedevtools team