所以我正在尝试将我的项目从 unity 4.6 移动到 unity 5.3
我收到此错误(在 4 行中由//ERROR 标记),脚本中的某些变量在当前上下文中不存在。
#if ENABLE_4_6_FEATURES
using UnityEngine.EventSystems;
#endif
public class MobilePaint : MonoBehaviour {
...
#if ENABLE_4_6_FEATURES
public GameObject userInterface;
public bool hideUIWhilePainting=true;
private bool isUIVisible=true;
#endif
...
public void HideUI()
{
if (!useNewUI) return;
isUIVisible=false;//ERROR
userInterface.SetActive(isUIVisible);//ERROR
}
public void ShowUI()
{
if (!useNewUI) return;
isUIVisible=true;//ERROR
userInterface.SetActive(isUIVisible);//ERROR
}
该错误针对"isUIVisible"和"userInterface"。
有没有人在 unity5 中遇到过这个问题,可以告诉我如何解决这个问题?
#if ENABLE_4_6_FEATURES,
使用的预处理器指令在这里可能是假的,因此不会定义这些变量。尝试注释掉预处理器。
//#if ENABLE_4_6_FEATURES
public GameObject userInterface;
public bool hideUIWhilePainting=true;
private bool isUIVisible=true;
//#endif