为什么按钮添加动效后就触发不起了

通过场景触发一个Fui Button通过动效显示出来,可是点击Button没反应,初学者求指导下
捕获.PNG 捕获2.PNG
已邀请:

木木蒹葭

赞同来自:

public class ButtonBoss : MonoBehaviour
{
    private GComponent mainUI;
    private GComponent bossCom;
    PlayCompleteCallback call;
    // Start is called before the first frame update
    void Start()
    {
        mainUI = transform.GetComponent<UIPanel>().ui;
        bossCom = UIPackage.CreateObject("Package2","Boss").asCom;
        call = callback;
        mainUI.GetChild("n1").onClick.Add(()=>{ Click(bossCom); });
    }

    void Click(GComponent targetCom)
    {
        mainUI.GetChild("n1").visible = false;
        mainUI.GetChild("n2").visible = false;
        GRoot.inst.AddChild(targetCom);
        Transition t = targetCom.GetTransition("t0");
        t.Play(call);
    }
    void callback()
    {
        mainUI.GetChild("n1").visible = true;
        mainUI.GetChild("n2").visible = true;
        GRoot.inst.RemoveChild(bossCom);
    }
}
看CallBack方法   再动画播放完字后记得移除你要播放的组件 移除之后点击才有效  就是这句GRoot.inst.RemoveChild(bossCom);

要回复问题请先登录注册