Unity resetting prefab name when saved
Whenever I rename some of my prefabs (the actual prefabs, not the instances in the scene), their names do not update in the project file window, and when I save the scene, their names are reset to whatever they were previously. It's really annoying having to distinguish 5 different prefabs all using the same name, and I'm guessing would throw a wrench into a bunch of code which involves object names (Although I'm lucky to say that that hasn't happened yet...)
Some help would really be appreciated. Thanks. :)
Were you in Play mode in the Unity Editor when you did this?
No, I was not in play mode when this occured
Answer by Adam-Mechtley · Nov 03, 2016 at 01:13 PM
Can you please clarify how you are renaming them and what you are expecting to happen? It sounds like you are selecting the prefab in project view, editing its name from the inspector, and expecting its name in the project view (i.e. on disk) to also be updated to this value. Is that correct? If so, does editing the prefab's name on disk (i.e. renaming the asset in the project view rather than at the top of its inspector) make a difference for you?
Yes, that's what I was doing, and expecting to happen. After trying to change the prefab name in the inspector, the name in the project view (Or any reference to it in other prefab's inspectors) would not update, but when looked at in the inspector it would retain its new name up until the second you hit save, at which point it would immediately return to the original name.
I found a workaround by adding an instance of the objects to the scene, deleting the prefabs, changing the name of the instances (which DID save), then re-making the objects into a prefab.
This is obviously not ideal because it severs all connections to other objects/prefabs, but considering the objects this occurred with are all simply added to an array of another prefab, I was able to do it without too much fuss.
Also, I had not thought about rena$$anonymous$$g it in the project view; I'm so used to using the inspector... And seeing as I seem to have gotten the desired effect with the affected prefabs using my work-around, I'll have to wait and see if the problem crops up again to try it. Hopefully not...