Enum Unity Code Example


Example 1: unity enum


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

Example 2: unity enum


private enum State
{
Idle,
Walk,
Attack,
}

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable