Project
Beginner Gameplay Scripting
Enumerations
Tutorial
Beginner
5 Mins
Unity Technologies
Overview
You have completed 0% of this Tutorial.
1.
Enumerations
Summary
Enumerations allow you to create a collection of related constants. In this video you will learn how to declare and use enumerations in your code.
Language
English
Recommended Unity Versions
4
1.
Enumerations

EnumScript

using UnityEngine; using System.Collections; public class EnumScript : MonoBehaviour { enum Direction {North, East, South, West}; void Start () { Direction myDirection; myDirection = Direction.North; } Direction ReverseDirection (Direction dir) { if(dir == Direction.North) dir = Direction.South; else if(dir == Direction.South) dir = Direction.North; else if(dir == Direction.East) dir = Direction.West; else if(dir == Direction.West) dir = Direction.East; return dir; } }

Woohoo! You nailed this tutorial.
Continue rocking your Beginner Gameplay Scripting project.
Next Step:
Switch Statements
Tutorial
Beginner
5 Mins
Unity Technologies