🥞Batch Serve Ad
Quickly serve or disable ads across all scenes using ReneVerse’s Batch Serve Ad system.
Last updated
using ReneVerse;
using UnityEngine;
public class InSceneScript : MonoBehaviour
{
private void Awake()
{
ReneAPIManager.BatchServeAd();
}
}using System.Collections;
using System.Collections.Generic;
using UnityEngine; using UnityEngine.SceneManagement;
using ReneVerse;
public class LoadingManagerExample : MonoBehaviour {
public string nextSceneWithAdSurfaces;
public GameObject loadingScreen;
private void Start()
{
StartCoroutine(LoadSceneAndBatchServeAdCoroutine());
}
private IEnumerator LoadSceneAndBatchServeAdCoroutine()
{
// Display the loading screen
loadingScreen.SetActive(true);
// Load the next scene asynchronously
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(nextSceneWithAdSurfaces);
// Wait until the asynchronous scene fully loads
while (!asyncLoad.isDone)
{
yield return null;
}
// Ensure all ad surfaces are registered
// Call the batch serve ad function asynchronously
yield return BatchServeAdWrapper();
// Hide the loading screen
loadingScreen.SetActive(false);
}
private IEnumerator BatchServeAdWrapper()
{
var task = ReneAPIManager.BatchServeAd();
while (!task.IsCompleted)
{
yield return null;
}
if (task.Exception != null)
{
Debug.LogError($"BatchServeAd failed: {task.Exception}");
}
}
}ReneAPIManager.BatchDisableAds();