DataTypes

Tutorial

Beginner

+10XP

5 mins

74

Unity Technologies

DataTypes

Learn the important differences between Value and Reference data types, in order to better understand how variables work.

1. Data Types

DatatypeScript

using UnityEngine;
using System.Collections;

public class DatatypeScript : MonoBehaviour 
{
    void Start () 
    {
        //Value type variable
        Vector3 pos = transform.position;
        pos = new Vector3(0, 2, 0);
        
        //Reference type variable
        Transform tran = transform;
        tran.position = new Vector3(0, 2, 0);
    }
}

Complete this Tutorial