During the course of completing a project I generally end up with several variables throughout my scripts that are declared but end up not being needed.
Is there anything out there that can run through scripts, find which variables are declared but not used, and then give a list of what and where they are?
I'm about to write my own little .exe or editor script (maybe even an UltraEdit or TextPad macro) that does that but before I spend the time I wasn't sure if something like that already existed. Anyone know of one?
asked May 08 '10 at 02:04 AM
If you use C#, then there are plenty of refactoring tools available. I would strongly recommend ReSharper. It will help you do hundreds of things to improve your code, including deleting unused variables.
Its even smart enough to detect variables that are assigned to, but never read from and other esoteric cases that you may not think of if you roll your own script.
answered May 08 '10 at 02:21 AM
Michael La Voie
You shouldn't need any external tools to do this. Unity should show you any unused variables in the console window as an warning (with a yellow warning icon). In particular it warns you about:
If you double click a warning message in the console, it will open the script editor and take you to the relevant line.