Introduction -: We will learn some basic programming concept. “Scripting ” in unity is the programming side of game development .Unity primarily uses the c# language. Java script is also available but is less common. C# is very similar to java or another programming language. For using the scripting in unity it is necessary to know that how to create a scripting.
Script are real;y just custom components.When we create a script then we are creating our very own components. In this we give the components behavior,properties,fields and values. we can add scripts to game object just like any other components.
There are may way for creating a script file using unity.
- In the Menu navigate to click assets | create | choose c# script.
- In the project tab navigate to create button and choose the c# script
- In the project tab right click from the pop up menu navigate to create button and choose c# script
Create a c# Script file -: In our unity project progresses we will have several folder to organize and store all of our c# file. For creating a c# script in unity follow these process..
- Right click in assets folder or we can use assets menu
- In the menu select the “create” menu. A new list has been open here we select c# script and click it.
Open the unity scripting file -: After adding the scripting file the next process for opening the scripting file. This will open in different way as like
- If you are using window operating system then you can open in visual studio.
- If you are using on Mac it will open in Mono Develop.
- Both of these are fine they are just IDE,s.
Here we will first notice a few things as like here
Introducing the MonoDevelop code editor -: Unity uses an external editor to edit c# script. even through unity can create a basic starter c# script for us. We still have to edit the script using the MonoDevelop code editor that’s included with unity.
Syncing c# files between MonoDevelop and unity -: These are separate application. Unity will keep MonoDevelop and unity synchronized with each other. This means that is you add, delete or changes a script file in on application the other application will see the change automatically.
Opening learning script in MonoDevelop-: Unity will synchronize with MonoDevelop the first time you tell unity to open a file for editing. the simplest way to do this is just double click on learning script in the scripts folders.In unity project tab double click on learning script
Unity scripting Mono Behavior-: in the mono scripting there are some rules are define as like here
- It start Start() and update () are just methods
- Start ( ) -: It runs once when the game begins.
- Update -: It runs every frame. A game is divided into frames. for example think of old school flipbook each page is a “frame” This method will be called at least 90 times every second
- Others methods -: awake() run before start.OnEnable run when the script is enabled. fixedupdate ()-: Framerate independent update for physics.
Debugging in unity scripting -: To print debug message in unity use Debug.Log(string message). Debug message will appear in the unity console
Here we can solve the debugging unity scripting.