Rename
Rename a method or variable from its name at the top of the right rail, then Compile.
On this page
Names drift. A method called HandleThing was clear when the class did one thing and becomes vague once it does five. You rename it where its name is shown, at the top of the right rail, and nothing in the script changes until you press Compile.
What it does
Section titled “What it does”The method’s name at the top of the right rail is also its rename box. Press F2 there, type, then press Enter: the canvas shows the new name straight away as a draft, and the script keeps the old one until you Compile. The name is checked as you type, so a name that cannot be used tells you why before you commit it. Undo takes the rename back until you Compile.
When to use it
Section titled “When to use it”Rename a method when its name no longer says what it does: HandleThing that now refreshes the coin display becomes RefreshCoinDisplay. Rename a variable when its meaning changes, such as speed becoming walkSpeed once the player can also run.
A method you add with the + on Methods is named when it is made. Its row opens as a name box holding NewMethod (then NewMethod1, NewMethod2), all of it selected. Enter keeps what you typed, Escape keeps the default, and an empty name, a reserved word, the class’s own name, or a name the class already has shows its reason as you type. Every later rename goes through the name at the top of the right rail.
Lifecycle methods such as Start and Update cannot be renamed: Unity finds them by name, so a new name would stop them running.
What it looks like
Section titled “What it looks like”
How to use it
Section titled “How to use it”Rename UnlockGoal to OpenGoalWhenEarned
Select the method
Click the method’s row under Methods in the left rail.
Press F2 on the name
Click the name at the top of the right rail, or move keyboard focus to it, and press F2.
Type the new name
Type the new name, such as OpenGoalWhenEarned.
Commit the rename
Press Enter, or click away.
Rename a variable the same way
To rename a variable, select its row in the Variables list and click its name in the right rail.
Compile
Press Compile in the toolbar.
What it writes
Section titled “What it writes”If you also work in C#, this is what is written into the script. This helper uses variables of PlayerController from the Platformer sample, renamed to RefreshCoinDisplay:
Only the name in the script changes. Node positions and zoom are saved separately, and so are wire bends; none of them is affected.
When it goes wrong
Section titled “When it goes wrong”When it goes wrong
| Symptom | Check | Fix |
|---|---|---|
| A message appears under the name box | Read it: a character that is not allowed, a reserved word, or a name already taken. | Change the name in the box, or press Escape. |
| F2 shows a lock message instead of a box | Read the message: a lifecycle method, a member from a base class, or a member declared in another file. | Keep the name, or rename it in the class or file that declares it. |






