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 |
| Stores integer/whole numbers | |
| 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 |

