Javatpoint Logo
Javatpoint Logo


Classes are the blueprints for your objects. Basically, in Unity, all of your scripts will begin with a class declaration. Unity automatically puts this in the script for you when you create a new C# script. This class shares the name as the script file that it is in. This is very important because if you change the name of one, you need to change the name of the other. So, try to name your script sensibly when you create it.

The class is a container for variables and functions and provides, among other things. Class is a nice way to group things that work together.

They are an organizational tool, something known as object-oriented programming or OOP for short. One of the principles of object-oriented programming is to split your scripts up into multiple scripts, each one taking a single role or responsibility classes should, therefore, be dedicated ideally to one task.

The main aim of object-oriented programming is to allow the programmer to develop software in modules. This is accomplished through objects. Objects contain data, like integers or lists, and functions, which are usually called methods.





Attach the PlayerDetails.cs script file to the GameOject's component and play the game. It will display the following output:

Next TopicArrays

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA