Create Script In Unity:
Create First Script :
Right-click in project panel -create -C# Script. It will create a script with the name NewBehaviourScript. we need to change its name immediately after create it by pressing backspace or simply type the name “Player”.
If we click elsewhere before changing its name then it will be given the name as NewBehaviourScript.
Do as following images, To avoid it.
Change the name of script :
Even if we couldn’t do it, we can still change the script name as we desire But it needs to change the name at 2 separate locations. only rename script will not work out. we need to change its class name also.
We need the script name and class name to be the same to be able to work. so after renaming the script name check the class name of that script by opening it and make it is same as the script name.
This is all we have to see carefully before changing the name of the script.
Also some short info:
While changing any variable name or class name in VS-code which holds reference in the project(used in code or other scripts).
- Select the name you want to change right-click and select the “Rename symbol” option or press f2.
- Then type the name want to change to.
- Press enter.
This will replace the name of that variable in all places where it is getting used.
Hope you will find this useful.