redbluegames / unity-mulligan-renamer

Mulligan Renamer tool for the Unity Editor allows for quick and safe renaming of many assets and gameobjects at once
MIT License
546 stars 57 forks source link

Request: Add Option to rename gameobjects after Prefab name change #295

Open justinwasilenko opened 2 years ago

justinwasilenko commented 2 years ago

Would be nice to see after changing the name of a Prefab in the project view, to then change the names of all gameobjects using that prefab in the scene.

Something like this: https://pastebin.com/DaiACbJU

edwardrowe commented 2 years ago

Thanks for the suggestion - This is a nice script!

So the workflow you are needing to do right now is:

  1. Rename a prefab
  2. Select the objects in the scene with the old name and
  3. Revert them with menu item: Prefab/RevertName

I like the idea, but there are a few potential problems. Not sure if they are dealbreakers or not.

  1. Within Unity I don't believe it's possible to distinguish whether or not an instantiated prefab in the scene had its named changed from the prefab. So if someone deliberately changed the name, we can't tell. We also can't know if the user wants these renamed or not.
  2. Even if we could tell, maybe they've enumerated multiple instances with a suffix, such as Char_Hero (1). Should it change the common substring?
  3. These prefabs could be used in any scene. So just looking at the open scene isn't enough.

In these cases, I think I'd expect a user to fix them with the bulk renamer themselves. Simply because we can't know what the "right" way is to fix up the users assets. Here's an example: if you want to change Char_Hero to Batman in the project and the scene, I'd probably search my scene for "Char_Hero", and my project for "t:prefab Char_Hero", and just drag everything in and Replace "Char_Hero" with "Batman".

That said, I this gave me an idea for a feature that might allow this.

Custom script nodes - users could create functions that adhere to some signature and do anything, and you could put them in the rename pipeline on the left. In this case you don't need all that, you'd just need a callback when it's done. Which might be the way to go.

So I think I'd like to keep this Issue open until I have a chance to write up a design for Custom Script operations. But ultimately I'd probably close it in favor of custom scripts - and maybe ship with a few operations, including this one.

What do you think?