Unity – Class renaming solution

This is just a quick note-to-self, though hopefully it might help someone out with some headaches in the future.

I’ve had a number of issues with renaming scripts/classes between MonoDevelop/Xamarin and the Unity engine itself. Refactor -> Rename of the class itself in the IDE will very likely cause a number of scripts to become unlinked within the script component attached to a GameObject. This will happen whether the GameObject is in the scene hierarchy or in the project, forcing you to re-link the script to the GameObject.

Turns out the way to do this without breaking links is:
1. Rename the script file in the engine to the desired name.
2. Refactor -> Rename the class name in MonoDevelop/Xamarin.

Then everyone is happy!

Leave a Reply

Your email address will not be published. Required fields are marked *