Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
5
Question by diggerjohn · May 27, 2015 at 03:33 PM · cleanup

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?

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 dreg_master · Dec 30, 2017 at 12:16 AM 0
Share

I too would like to know if a solution exist for this. I made a mess of my scripts folder structures and got scripts everywhere.

2 Replies

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

Answer by DiegoSLTS · May 27, 2015 at 03:49 PM

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.

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 jwulf · Dec 30, 2016 at 06:44 PM 0
Share

Does this include Scripts which aren't directly assigned to any Prefab, but only via Script, e.g. with the AddComponent()-$$anonymous$$ethod or any Static Classes?

If not, going this way to detect unused scripts might be problematic.

avatar image Xarbrough · Feb 14, 2017 at 11:27 PM 1
Share

This doesn't work for scripts. Unity can gather dependencies to assets like textures and prefabs and will correctly exclude unused ones, but it can't possibly know if you need a certain script. How would it? If a script is not referenced by any scene, it could still be referenced somewhere in code. Now Unity could parse all script files and do individual compilation passes to find all references and also check for platform dependent compilation and so on, but there are probably a dozen other things, which could go wrong, like when you use reflection. Sadly, there is no magic automated way of knowing which scripts are being used. If you know your project, you can probably write a tool based on assumptions like, you're not using reflection or only using $$anonymous$$onoBehaviour etc, but it will still be tricky.

avatar image
1

Answer by Gotlight · Aug 07, 2020 at 11:46 AM

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 :-)

https://assetstore.unity.com/packages/tools/utilities/asset-cleaner-pro-clean-find-references-167990

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:

  • gamedevtools.assetstore@gmail.com or via Telegram chat:

  • https://t.me/joinchat/BdWObBk5PxjNALiRSXp7Vw

    Thanks and looking forward to seeing you among our happy users:)
    Denis from Gamedevtools team

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

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

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

Related Questions

Organize Inspector Better? 1 Answer

Any way to stop texture lookup wiping material from prefab? 0 Answers

What does "Clean All" do? 1 Answer

baked animation cleanup 0 Answers

Tips on Cleaning up my player controller 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