通常情况下,我在现场有一个事件系统,但如果我展示广告(applovin),那么就会添加一个更多的事件系统。此问题导致“场景中有 2 个事件系统”。问题。我怎样才能解决这个问题?
[我的场景][1][1]:https://i.stack.imgur.com/EY5e9.jpg
我的 applovin 广告代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Gecis : MonoBehaviour
{
private const string MaxSdkKey = "--";
private const string InterstitialAdUnitId = "--";
// Start is called before the first frame update
void Start()
{
MaxSdkCallbacks.OnSdkInitializedEvent += (MaxSdkBase.SdkConfiguration sdkConfiguration) => {
// AppLovin SDK is initialized, start loading ads
InitializeInterstitialAds();
};
MaxSdk.SetSdkKey(MaxSdkKey);
MaxSdk.InitializeSdk();
}
private void InitializeInterstitialAds()
{
// Attach callbacks
MaxSdkCallbacks.Interstitial.OnAdDisplayFailedEvent += InterstitialFailedToDisplayEvent;
MaxSdkCallbacks.Interstitial.OnAdHiddenEvent += OnInterstitialDismissedEvent;
// Load the first interstitial
LoadInterstitial();
}
void LoadInterstitial()
{
MaxSdk.LoadInterstitial(InterstitialAdUnitId);
}
public void ShowInterstitial()
{
if (MaxSdk.IsInterstitialReady(InterstitialAdUnitId))
{
MaxSdk.ShowInterstitial(InterstitialAdUnitId);
}
else
{
}
}
private void InterstitialFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo, MaxSdkBase.AdInfo adInfo)
{
// Interstitial ad failed to display. We recommend loading the next ad
LoadInterstitial();
}
private void OnInterstitialDismissedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
// Interstitial ad is hidden. Pre-load the next ad
LoadInterstitial();
}
}