// ========================================================
// 描述:
// 作者:
// 创建时间:2021-01-10 11:49:37
// 版 本:1.0
// ========================================================
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class UIController : MonoBehaviour
{
public enum LargeStep
{
xx,
yy,
zz
}
public enum SmallStep
{
呼和浩特市,//1
赤峰市, //2
齐齐哈尔市,//3
长春市, //4
沈阳市, //5
}
public Dropdown LargeStepDropdown;
public Dropdown SmallStepDropdown;
void Start()
{
List<string> LargeStepOptions = new List<string>();
Type _LargeStep = typeof(LargeStep);
foreach (string s in Enum.GetNames(_LargeStep))
LargeStepOptions.Add(s);
LargeStepDropdown.AddOptions(LargeStepOptions);
LargeStepDropdown.onValueChanged.AddListener(LargeStepValueCange);
List<string> SmallStepOptions = new List<string>();
Type _SmallStep= typeof(SmallStep);
foreach (string s in Enum.GetNames(_SmallStep))
SmallStepOptions.Add(s);
SmallStepDropdown.AddOptions(SmallStepOptions);
SmallStepDropdown.onValueChanged.AddListener(SmallStepValueCange);
}
void LargeStepValueCange(int _value) {
Debug.Log(_value);
}
void SmallStepValueCange(int _value)
{
Debug.Log(_value);
}
}
c#遍历枚举类型
最新推荐文章于 2024-03-28 09:58:43 发布