Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
13
Question by Tobias · Mar 15, 2010 at 10:44 AM · rename

How to rename a script file?

How I can change the Name of a Javascript file? ("NewBehavoiurScript")?

I cant find any rename button (enter or F2 also doesnt work).

Im using a mac. Thanks

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

8 Replies

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

Answer by Lipis · Mar 15, 2010 at 10:47 AM

Select the JavaScript file or any other object in Unity and press:

  • return key if you are on MacOS
  • F2 if you are on Windows.
Comment
Add comment · Show 4 · 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 Tobias · Mar 15, 2010 at 11:01 AM 0
Share

Thank you, the Problem was my external usb keyboard :D

avatar image Lipis · Mar 15, 2010 at 11:08 AM 0
Share

You're welcome... If you haven't read that already you should take a look if you are new around here or stackoverflow.com: http://answers.unity3d.com/faq regards

avatar image flberger · May 22, 2013 at 08:07 AM 0
Share

That is a lifesaver. Also works on material assets etc. This is so counterintuitive that it should be fixed in Unity.

avatar image rohitvishwakarma1819 · Aug 13, 2018 at 12:59 AM 0
Share

Can't we change the button function from F2 to Enter in windows only for unity.

avatar image
4
Best Answer

Answer by Eric5h5 · Mar 15, 2010 at 02:16 PM

Aside from the return key, you can click on a file, wait for a bit, then click again (don't click again too fast). This is also the same way to rename files in the OS.

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 KokodokoGames · Sep 01, 2015 at 09:28 AM 0
Share

This works, but then the game object starts complaining that it can't find the file. Strangely it does use the new renamed name, but still can't find it.

avatar image
26

Answer by davemeta · Dec 18, 2012 at 09:32 PM

The only way to fully and gracefully rename a monobehaviour script that I have found:

  1. Inside of Unity, rename the file that contains the script to the desired name. (Select the script, wait 2 seconds, click again, then type the new name)

  2. Inside of MonoDevelop, open the script, right click on the class name, choose "refactor" > "rename". Uncheck the "rename file" box.

  3. Make the new class name the same as the new file name you used in Unity.

  4. Save all open MonoDevelop files.

  5. Close Unity (don't save the scene)

  6. Open Unity

Now your monobehaviour class is fully renamed / refactored.

Comment
Add comment · Show 6 · 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 KokodokoGames · Sep 01, 2015 at 09:29 AM 0
Share

That's a nightmare! It's faster to create a whole new script and paste all code in there :-(

avatar image Estecka KokodokoGames · Apr 01, 2017 at 04:25 PM 0
Share

Not always. If your script is used on multiple objects, they would still use the old script. With the method above, the components on your objects and préfabs will automatically be updated to use the newly named script ins$$anonymous$$d.

avatar image singh31383 · Jun 18, 2016 at 02:01 AM 1
Share

This is very helpful. I had a prefab that the script was attached to. This saved time.

avatar image michaelstv · Jul 12, 2018 at 12:24 PM 1
Share

Works perfect! Even with Visual Studio. Thanks - That should be the accepted answer

avatar image mrCrush · Feb 03, 2019 at 11:18 AM 0
Share

The best way! Thank you man!

avatar image ed_unity380 · Jun 23, 2020 at 12:56 PM 0
Share

It doesn't work for me in the combo:

Unity 5 Windows Raider

avatar image
0

Answer by renderhjs · Jun 17, 2010 at 03:54 AM

Hitting F2 in Windows with folders doesn't work sometimes - it just goes back to the former folder (just like a Assets folder keep re- appearing within the Assets folder after deleting it). Clicking twice on the folder name and then giving it a new name works however, so it seems to be broken on windows at times.

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 AngryOldMan · Apr 08, 2011 at 11:54 AM 0
Share

I've found it's the other way round, double clicking no matter what speed you do doesn't work sometimes. F2 seems to work fine for me and remains working fine even when double clicking doesn't work.

avatar image
0

Answer by Ben Wilkinson · Dec 15, 2010 at 11:27 AM

I have also found that if you create a new folder in project view (called "new folder" by default) then edit the name, then press enter, it just pops back to "new folder". Its very frustrating. I think this could be a bug. Im using windows vista and unity 3 pro and ran it a admin but still no luck.

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 drkalmenius · May 31, 2016 at 12:01 PM 0
Share

I know it's old but if you are still having the problem then it's because you are not hitting Enter/Return after you have finished editing the name

  • 1
  • 2
  • ›

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

12 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Setting Scroll View Width GUILayout 1 Answer

Material doesn't have a color property '_Color' 4 Answers

How to import the object from server to unity 2 Answers


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