错误:方法destroyAfterCBEvent' takes
0的参数没有重载
上述problem>的解决方案是什么?
Chartboost.CBManager.didFailToLoadInterstitialEvent += destroyAfterCBEvent();
void destroyAfterCBEvent (string location)
{
Debug.LogError ("CB Event failed, noads button destroyed");
Destroy (gameObject);
}
这些是用于生成错误的代码。
发布于 2014-05-21 13:54:42
当您实际想要使用方法组转换来创建一个委托来订阅事件时,您将调用destroyAfterCBEvent
。您需要去掉括号(这就是它是一个方法调用的原因)。您需要:
Chartboost.CBManager.didFailToLoadInterstitialEvent += destroyAfterCBEvent;
这相当于:
Chartboost.CBManager.didFailToLoadInterstitialEvent +=
new Action<string>(destroyAfterCBEvent);
或者根据你的评论:
Chartboost.CBManager.didFailToLoadInterstitialEvent +=
new GUIClickEventReceiver(destroyAfterCBEvent);
(鉴于Chartboost documentation,后者让我大吃一惊。)
顺便说一句,最好更改代码以遵循正常的.NET命名约定-事件和方法都应该是PascalCased。事件通常也应该有一个与EventHandler
兼容的委托。(我对ChartBoost一无所知,所以可能其中一些问题与您无关……但方法名绝对是您可以修复的。)
https://stackoverflow.com/questions/23775037
复制相似问题