繁体   English   中英

如何修复 Unity Applovin 集成场景中有 2 个事件系统的问题

[英]How to fix Unity Applovin Integration There are 2 event systems in the scene problem

通常情况下,我在现场有一个事件系统,但如果我展示广告(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();
    }

}

打开 Assets>MaxSdk>Prefabs 并从每个 prefab 中删除 EventSystem

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM