how to create a script in unity editor
Script is life of a game. Script allow you to control you gameObjects as you want. Unity support C# programming language (called as C-Sharp). From this post we will learn scripting in unity. and first part of learning is creating a script so now start creating script. There are some way of creating script let's take a look.
1. You can create a new script by navigating Assets > Create > C# Script
as you click on C# Script a new script will be created in project panel with a name newMonobehaviorScript to rename you have to give a name to script whatever you want.
2. You can also create a script by clicking on plus(+) icon in top left corner of project panel and
click C# Script to create a new script when you click c# script it will prompt to rename it.
These are some way of creating a script now let take a look what a script contain. By double clicking on the script it will be opened in visual studio code editor or whatever how set in Edit > Preferences > External tools.
Scripts are attached a component to gameObjects so to see working of a script need to attach to a gameObject.
You must take care that script name and class name should exactly match.
Our script already contains to function Start() and Update().
Our script already contains to function Start() and Update().
Start() :- Start function will run only once when a scene is loaded.
Update() :- Update function run at each frame mean it will run several time in a second so to use a oher function in game you have to call it in Update function.