Beginner Scripting: DataTypes


 In this weeks Coding Task it looked at DateTypes. This weeks task is a little hard to explain. When working with code you will have to work with variables. All variables have a DataType. The two primary DataTypes being Value and Reference. This week was explaining how you change values which is like the original but can also change a reference which will not effect the original value



The code is as follows

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); } }

Comments

Popular Posts