简体   繁体   中英

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

Normally, i have one event system on the scene, but if i display ads (applovin) then one more event system is added. This issue causes "There are 2 event systems in the scene." problem. How can i fix this?

[My scene][1] [1]: https://i.stack.imgur.com/EY5e9.jpg

My applovin ads code:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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