Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by reptilebeats · Jul 31, 2013 at 05:08 PM · textasset

name changer component

hey just a simple question, is there an asset on the store to change the name of all selected objects in the hierarchy. so instead of just changing them all to the same name it will add 1,2,3,4,5 and so on.

if not i''ll make my own,

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by reptilebeats · Aug 09, 2013 at 12:19 AM

hey i added a couple things to it append and prepend, oh and if you type NONE it will only give you the numbers. if i have time i may make a proper little asset as i find this really useful, but maybe its just what im working on. enjoy

 using UnityEngine;
 using UnityEditor;
 
 public class NameChanger : EditorWindow{
 
 string newObjName; // input for the new name of object if required
 bool changeName = false; // change all selected names
 bool resetObjName = true; // reset the input name after use
 bool prependAppend = true; // put the sequence before or after the name  false = prepend true = append
 
 private int counter = 0;
     
     [MenuItem("MMGstudios/Window/NameChanger")]
     
     static void Init()
     {
         EditorWindow.GetWindow(typeof(NameChanger));
     }      
         
     void OnGUI()
     {
         newObjName = EditorGUILayout.TextField("New Name",newObjName);            
         changeName = EditorGUILayout.Toggle("Apply Change",changeName);        
         resetObjName = EditorGUILayout.Toggle("Reset Name",resetObjName);        
         prependAppend = EditorGUILayout.Toggle("Prepend/Append",prependAppend);
 
         if(changeName == true)
         {
             GUIUtility.keyboardControl = 0;
                 changeName = false;
         
             if(Selection.activeGameObject)
             {
                 Undo.RegisterSceneUndo("Undo Name Change");
                 
                 foreach(Transform ObjTransform in Selection.transforms)
                 {
                     counter++;
 
                     if(newObjName == "NONE") // will only put the sequence in and no name must be caps
                         ObjTransform.gameObject.name = "" + counter;
                     
                     else
                     if(newObjName != "" && newObjName != "NONE")
                     {
                         if(prependAppend == true)
                             ObjTransform.gameObject.name = newObjName + counter;
                         else
                             ObjTransform.gameObject.name = counter + newObjName;
                     }                                    
                     else 
                     if(prependAppend == true)
                         ObjTransform.gameObject.name = ObjTransform.gameObject.name + counter;
                     
                     else
                         ObjTransform.gameObject.name = counter + ObjTransform.gameObject.name;    
                 }
                 
                 counter = 0;
                 
                 if(resetObjName == true)
                 {
                     newObjName = "";
                 }
             }
         }
             if(GUI.Button(new Rect(1, 90, 110, 18), "MMGstudios Link"))
                 Application.OpenURL("http://mmgstudios.com");
     }
  
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Jamora · Aug 01, 2013 at 12:26 AM

In case you've not written it by now... I searched the Unify Wiki and the Asset Store. Didn't find anything. You'll probly write it faster than it takes to find one on the internet.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image reptilebeats · Aug 09, 2013 at 12:22 AM 0
Share

dunno it took me a while to scan the reference for it as i haven't looked at csharp much.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can't find a working free speech to text api or asset 0 Answers

Script to load a text file gives error. 1 Answer

Loading TextAsset returns null 1 Answer

Prefabs not visible in webplayer? (read from .txt file) 1 Answer

Null Reference Exception while trying to access Text Files 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges