unity3d中C#枚举

来源:互联网 发布:文学书籍推荐 知乎 编辑:程序博客网 时间:2024/06/05 01:54
using UnityEngine;
using System.Collections;

public class NewBehaviourScript : MonoBehaviour {

    enum COLOR{RED,YELLOW,BLACK,WHITE,GREEN,BLUE};
    COLOR a=COLOR.RED;
    void Start () {
        
    }
    

    void Update () {
        switch(a){

        case COLOR.RED:
            Debug.Log("this is Red");
            break;
        case COLOR.YELLOW:
            Debug.Log ("this is Yellow");
            break;
        case COLOR.GREEN:
            Debug.Log ("this is Green");
            break;
        case COLOR.WHITE:
            
            Debug.Log ("this is White");
            break;
        case COLOR.BLACK:
            
            Debug.Log ("this is Black");
            break;
        }
    }
}
0 0
原创粉丝点击