我有一个在 NGUI 中制作简单菜单动画的功能。它似乎工作得很好,但是当我进入游戏然后返回菜单时,该功能无法正常工作。
IEnumerator MenuTransition (GameObject panelOut, GameObject panelIn) {
foreach (Transform child in panelOut.transform)
{
if(child.gameObject.collider != null)
{
child.gameObject.collider.enabled = false;
UIButton [] buttons = child.GetComponents<UIButton>();
foreach(UIButton b in buttons) b.UpdateColor(true, true);
}
child.gameObject.animation.Play("MenuTransitionOff");
}
Debug.Log("time: "+animTime);
//yield return new WaitForSeconds(animTime);
Debug.Log("ini");
foreach (Transform child in panelIn.transform)
{
UIButton [] buttons = child.GetComponents<UIButton>();
foreach(UIButton b in buttons) b.UpdateColor(true, true);
child.gameObject.animation.Play("MenuTransitionOn");
}
//yield return new WaitForSeconds(animTime);
foreach (Transform child in panelIn.transform)
{
if(child.gameObject.collider != null)
{
child.gameObject.collider.enabled = true;
}
}
Debug.Log("3");
yield return null;
Debug.Log("4");
}
并且此函数从另一个分配给按钮 onclick 事件(使用 NGUI)的函数中分离出来。
void OnMainMatch () {
StartCoroutine(MenuTransition(mainPanel, matchPanel));
}
由于未注释产量,应用程序似乎在第一个时崩溃,之后不再出现日志,但即使我评论了两个产量并在最后添加了一个,我也没有动画并且按钮变得无响应。在最后一种情况下,打印 4。这只发生在进入游戏并返回菜单后,而不是第一次执行菜单时。我也调试过动画时间,不到一秒,所以是正确的。我真的不知道在哪里寻找错误。关于在哪里寻找的任何想法?