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

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.

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.

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.

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.

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.

Working on Linux:

Eric5h5 : Double click at average Speed

Me : Use the Inspector

Not working on Linux:

Lipis : F2

Lipis : Return

By the way, Unity answers’ text thing is really annoying, but I found out you can use

without the spaces to break a line (HTML)

You can solve your problem very easily. When you want to renameame a Javascript file (“NewBehavoiurScript”) I sugest to always use BatchRenameFiles Tool. You can found hier

Your entire project will be messed up !
Every object will loose his connexion to the script, and you will have to fix them one by one !
“Frustrating” is the good word yes, Jeez…