Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 15th, 2011  |  syntax: None  |  size: 0.56 KB  |  views: 379  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. @MenuItem ("Maquette/Batch Rename")
  2. static function BatchRename()
  3.         { // Renames all selected items in the Hierarchy to the first item selected, with numbers.
  4.         var iname : String;
  5.         ispacer = "0";
  6.     icount = 0;
  7.         iname = Selection.activeGameObject.name;   // The item in the inspector
  8.        
  9.         istuff = Selection.gameObjects.length;  // if I wanted this to support renaming of > 99 objects correctly, I'd use this.
  10.        
  11.         for (igo in Selection.gameObjects)
  12.                 {
  13.                 icount ++;
  14.                 if (icount > 9) ispacer = "";
  15.                 igo.name =iname + "-" + ispacer + icount;
  16.                 }
  17.         }
clone this paste RAW Paste Data