Upgraded to the latest version of VS for Mac (2019, v 8.3.1, build 18) and the prompt asking if you want the file name to be changed when renaming a class is gone. Huge pain having to rename the class manually (especially when doing multiples). Am I missing something or is this feature just plain gone?
I’m really glad they removed this feature because it was horribly broken. This simple renaming the filename automatically feature is by far the most-common way to get broken Unity script references.
If you doubt me, try it yourself; it takes less than 60 seconds:
-
make a Monobehavior class
-
attach an instance of it to a blank GameObject
-
go into VS / Mono and rename the class along with the file
RESULT: 100 out of 100 times you will now have a Missing Script reference on that GameOBject.
The reason is simple: Unity doesn’t know about you changing the filename in VS / MonoBehavior, so from Unity’s perspective, it sees the old class removed, and a new class appearing, WITHOUT a metafile.
Unity removes the old metafile dutifully and produces a warning, then produces a fresh metafile with a different Unity GUID inside it, and now that does not match the reference you set earlier.
In the past eight years of using Unity I have seen this waste dozens of hours of valuable developer time and I am positive there are games out there right now with broken and buggy features because of this broken rename feature. Good riddance to have it gone.
Perhaps when Unity gets some kind of “back hook” that can recognize the rename properly it might be okay, but I can imagine about 57 different ways that could fail, such as “What if Unity isn’t running or is stopped by the debugger?”
Bad feature, good riddance.
Edit: what VS needs is a plugin that is actually metafile aware and renames BOTH the .cs file and the .cs.meta file at the same instant. That’s really the only software solution. Anything else is inviting disaster and really hard-to-find bugs. Keep in mind these bugs do NOT cause compiler errors.
I can certainly see how it would break things in the scenario you describe. However, nearly all of my GameObject instances are created at runtime so I don’t ever encounter the “missing script ref” problem.
The prior VisualStudio implementation presented a dialog that included a “Rename associated file” checkbox which was unchecked by default (do not rename file). That would (did) take care of both scenarios.
Good to know… all they needed was to take it that extra mile and rename the @#@%#$%# meta file too!! Well, perhaps in the future…
Sorry that this change impacts your workflow… I too do 99% of my script adding at runtime, but at my day job we have big teams with artists, technical artists, designers, and more, all creating prefabs and scenes, so it was extremely costly to have even a single missing reference failure, which made the convenience of renaming not at all worth it.
And it still bites us from time to time.