Sample.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// 列挙型とは?
// * コードを読みやすくするためのもの(可読性をあげる)
// * 制限の中から選択可能にするもの
public class Sample : MonoBehaviour
{
enum DIRECTION {
UP,
DOWN,
RIGHT,
LEFT,
}
DIRECTION direction = DIRECTION.DOWN;
int directionInt = 0; // 0:上
void Start()
{
if (directionInt == 0)
{
Debug.Log("下");
}
else if(directionInt == 1)
{
Debug.Log("上");
}
switch (direction)
{
case DIRECTION.DOWN:
Debug.Log("下");
break;
case DIRECTION.UP:
Debug.Log("下");
break;
case DIRECTION.RIGHT:
Debug.Log("下");
break;
case DIRECTION.LEFT:
Debug.Log("下");
break;
}
/*
if (direction == DIRECTION.Down)
{
Debug.Log("下");
}
else if (direction == DIRECTION.Up)
{
Debug.Log("上");
}
else if (direction == DIRECTION.RIGHT)
{
Debug.Log("右");
}
else if (direction == DIRECTION.LEFT)
{
Debug.Log("左");
}
*/
}
}