gpt4 book ai didi

ios - Unity3D中的AppLovin广告:onAppLovinEventReceived未触发

转载 作者:行者123 更新时间:2023-12-01 18:39:02 27 4
gpt4 key购买 nike

我在Unity3D iOS游戏中使用了Applovin全屏广告。

广告运作良好。但是事件监听器没有被触发。我希望跟踪失败事件调用。

public static void StartApplovin () 
{
AppLovin.SetSdkKey("My_SDK_Key");
AppLovin.InitializeSdk();

AppLovin.SetUnityAdListener("ApplovinListener");
}

这是ApplovinListener.cs类
public class ApplovinListener : MonoBehaviour {

void onAppLovinEventReceived(string ev)
{
Debug.Log ("\n\nonAppLovinEventReceived\n\n");

if(ev.Contains("DISPLAYEDINTER")) {
// An ad was shown. Pause the game.
}
else if(ev.Contains("HIDDENINTER")) {
// Ad ad was closed. Resume the game.
// If you're using PreloadInterstitial/HasPreloadedInterstitial, make a preload call here.
AppLovin.PreloadInterstitial();
}
else if(ev.Contains("LOADEDINTER")) {
// An interstitial ad was successfully loaded.
}
else if(string.Equals(ev, "LOADINTERFAILED")) {
// An interstitial ad failed to load.
GameCenter2.ShowAdmobAds ();
Debug.Log ("\n\n Applovin FAILED\n\n");

}
}

}

当我运行时,Xcode提供以下控制台日志。
SendMessage: object ApplovinListener not found!

如何获得onAppLovinEventReceived调用?

更新:我通过创建gameObject解决了此问题。

在Unity Manu中,按GameObject-> Create Empty

将其命名为“ApplovinListener”

现在,将名为ApplovinListener的脚本附加到游戏对象。而已。

最佳答案

必须将ApplovinListener脚本附加到传递到AppLovin.SetUnityAdListener函数中的GameObject的名称上,以便调用onAppLovinEventReceived函数。

你有这个:

AppLovin.SetUnityAdListener("ApplovinListener");

确保有一个实际上名为“ApplovinListener”的GameObject。现在,确保已将 ApplovinListener脚本附加到该脚本。完成此操作后,应调用 onAppLovinEventReceived函数。

为了使您更轻松,建议您改为:
AppLovin.SetUnityAdListener(yourGameObject.name);

然后将 ApplovinListener脚本附加到您上面引用的GameObject上。

关于ios - Unity3D中的AppLovin广告:onAppLovinEventReceived未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46484572/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com