Batch GameObject renaming tool for Unity




Silly that Unity doesn't support this. Uses the name of the first GO selected (the one in the inspector) to rename the rest of them. This is actually a great template for all sorts of batch editor commands in Unity.

Here it is in pastebin

.

 

@MenuItem ("Maquette/Batch Rename")
static function BatchRename() 
	{ // Renames all selected items in the Hierarchy to the first item selected, with numbers.
	var iname : String;
	ispacer = "0"; 
    icount = 0; 
	iname = Selection.activeGameObject.name;   // The item in the inspector
	
	istuff = Selection.gameObjects.length;  // if I wanted this to support renaming of > 99 objects correctly, I'd use this. 
	
	for (igo in Selection.gameObjects)
		{
		icount ++; 
		if (icount > 9) ispacer = ""; 
		igo.name =iname + "-" + ispacer + icount; 
		}
	}





Feedback - 2 responses

Displayed newest to oldest. Leave a comment.
Alex Schwartz wrote:   
This is good stuff, Hanford.

I got sick of the lack of little niceties in Unity and built MultiPanel for myself, then decided to sell it on the Unity Asset Store. It handles things just like this (batch rename with numerical suffix, batch on/off for renderers, batch adding/removing components, that kind of stuff).

Marty, you're right. You don't realize how much you need something until you hear a solution, then you're using it every day :P
Marty Plumbo wrote:   
I've never needed to do this. But now that I can, I know I'll want to every day.
 

This site is mostly about

Video Game Design

User Interface Design

Creative & fun stuff

 

Your Host

I'm Hanford Lemoore. My parking skills are unparalleled.

I make things. From consumer electronics, to video games, to theme park attractions. Perhaps I can make things for you! Check out my portfolio.

When I'm not making things for other people, I'm usually experimenting.

 

Contact

Follow me on Twitter.

Message me on Facebook.

Email me using my contact form.

 

RSS 2.0

 

maquettegame.com

tikiroom.com

junkyardclubhouse.com

monolux.com

 

   


Copyright 2012 Hanford Lemoore | Blog | About | Portfolio | Contact
Powered by Olark