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

more ▼

asked Mar 15 '10 at 10:44 AM

Tobias gravatar image

438 51 55 66

(comments are locked)
10|3000 characters needed characters left

5 answers: sort voted first

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.
more ▼

answered Mar 15 '10 at 10:47 AM

Lipis gravatar image

2.5k 10 24 48

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

Mar 15 '10 at 11:01 AM Tobias

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

Mar 15 '10 at 11:08 AM Lipis

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

May 22 '13 at 08:07 AM flberger
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Mar 15 '10 at 02:16 PM

Eric5h5 gravatar image

102k 49 165 620

(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Jun 17 '10 at 03:54 AM

renderhjs gravatar image

14 1 1 5

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.

Apr 08 '11 at 11:54 AM AngryOldMan
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Dec 15 '10 at 11:27 AM

Ben Wilkinson gravatar image

Ben Wilkinson
1 2

(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Dec 18 '12 at 09:32 PM

davem123us gravatar image


(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Mar 15 '10 at 10:44 AM

Seen: 10851 times

Last Updated: May 22 '13 at 08:07 AM