团结中的屈服问题

本文关键字:屈服 问题 | 更新日期: 2023-09-27 17:58:04

我有一个在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。这只发生在获取ingame并返回菜单之后,而不是第一次执行菜单时。我还调试了动画时间,它不到一秒钟,所以它是正确的。我真的不知道该在哪里查找错误。知道在哪里找吗?

团结中的屈服问题

我在NGUI的OnClick和协程中遇到了同样的问题,这是因为在调用StartCoroutine后,OnClick按钮被设置为非活动状态。这导致协同程序的迭代被消除,因为它是管理协同程序的OnClick对象。但不确定这是否是同一个问题。