Home ยป Core Concepts»Variables
Index
Navigation
Community Wiki

Variables

A variable is a named container for a value. Action parameters accept variables as well as hard-coded values.

A variable has several advantages over a hard-coded value:

  • It has a name that makes its value more meaningful (e.g., maxNumberOfLives instead of 99).
  • The same variable can be used in multiple places. Hard-coded values have to be changed separately.
  • A variable's value can change over time!

Variable Types

Float Stores floating point numbers

Int

Stores integer/whole numbers

Bool

Stores true/false values
GameObject Stores references to GameObjects
Color Stores Color values
String Stores text values
Vector2 Stores Vector2 values (x,y)
Vector3 Stores Vector3 values (x,y,z)
Rect Stores Rect values (x,y,width,height)
Material Stores references to Materials
Texture Stores references to Textures
Quaternion Stores Quaternion values (used for rotations)
Object Stores references to UnityEngine.Objects
Array Stores a collection of values
Enum Stores an Enum value

 

Tags:

Last modified on 12/29/2015 1:17 AM by User.

  • RSS Feed