TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Unity Data Types

Unity Data Types with Introduction, Installing, GameObject, First Unity Project, Unity 2D, Sprite Unity, Loops, If Statement, Data Types, Swith Statements, Unity UI, Unity Asset Store etc.

<< Back to UNITY

Data Types

A data type classifies various types of data, for example, string, integer, boolean, float, and the types of accepted values for that data type, operations that can be performed on the data type, the meaning of the data of that type can be stored.

int: This data type is used to store 32 bits integer numbers. This data type stores positive or negative whole numbers.

float: The float data type is used to store floating point numbers. The float data type is the default type of number in Unity.

For Example:

float points = 72.24;

double: Double data type also stores floating point numbers, but it can hold larger size numbers than float. And it is not the default number type in Unity.

For Example:

double amount = 134434.23;

bool: The bool data type is the short form of Boolean. This data type store true or false values.

For example:

bool chance = false;

char: This data type stores a single character such as a number, letter, space, or special character. A char value should be written in single quotes.

For example:

char press = 'a';

string: This data type is used to store letters, numbers, and other special characters in the form of words or sentences. A string value should be written inside double quotes.

For example:

string CharacterName = "Ken Fighter";

Example

Let's see one simple example:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DataType: MonoBehaviour
{
    int playerHealth = 100;
    float playerVelocity = 14.74f;
    string msg = "Welcome to the Game";
    bool isGameOver = false;
    void Start()
    {
        Debug.Log("Initial Health : " + playerHealth);
        Debug.Log("Player's Volecity : " + playerVelocity + " km/h");
        Debug.Log(msg);
        Debug.Log("Game Over: " + isGameOver);
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

Output:

Data Types
Next TopicClasses




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf