using UnityEngine;
using System.Collections;
public class MenuSelect : MonoBehaviour {
private UIPopupList list;
// Use this for initialization
void Start () {
list = GetComponent<UIPopupList> ();
EventDelegate.Add (list.onChange, OnChange);
}
// Update is called once per frame
void Update () {
}
void OnChange()
{
switch(UIPopupList.current.value)
{
case "列车定位":
Debug.Log ("列车定位.");
break;
}
}
}
以上是操作代码。
popup list 的options为以下选项
列车定位
移动授权执行临时限速
列车完整性检查
但是,因为unity对中文支持不好,当我是将它们整体复制到options栏中时,
运行,选择列车定位,虽然UIPopupList.current.value输出为列车定位,但并不进case,让人费解。
解决方法:
将选项逐条粘贴到options中。