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中。
本文介绍了一个Unity中关于UIPopupList组件使用中文时遇到的问题及解决方案。当将包含中文的选项整体复制到options栏时,虽然能正常显示并选择,但事件响应不正确。通过将每个选项单独粘贴的方法解决了该问题。
166

被折叠的 条评论
为什么被折叠?



