How to ad picture ads??

hi
I use some codes like this

if(Advertisement.isReady()){ Advertisement.Show(); }

or this one

using System; using UnityEngine; using UnityEngine.Advertisements; public class AdvertisementTest : MonoBehaviour { void Awake() { if (Advertisement.isSupported) { Advertisement.allowPrecache = true; Advertisement.Initialize (); } else { Debug.Log(“Platform not supported”); } } void OnGUI() { if(GUI.Button(new Rect(10, 10, 150, 50), Advertisement.isReady() ? “Show Ad” : “Waiting…”)) { // Show with default zone, pause engine and print result to debug log Advertisement.Show(null, new ShowOptions { pause = true, resultCallback = result => { Debug.Log(result.ToString()); } }); } } }

but nothing will make picture ads ???!!

Keep in mind, picture ads are still in beta. Which means there is limited fill for English speaking countries, and in most cases no fill for non-English speaking countries.

You can still test picture ad functionality regardless of fill by enabling test mode:

public string gameID;
public bool disableTestMode;

void Awake ()
{
    bool enableTestMode = Debug.isDebugBuild && !disableTestMode;
    Debug.Log(string.Format("Initializing Unity Ads for game ID {0} with test mode {1}...",
                            gameID, enableTestMode ? "enabled" : "disabled"));
    Advertisement.Initialize(gameID,enableTestMode);
}

Having gameID and disableTestMode as public variables makes it easy to set them from the inspector. During development, you always want to be initializing Unity Ads with test mode enabled. With the above code, test mode will be enabled if Development Build is enabled in Build Settings. However, you can force production ads to be shown instead of test ads by checking disableTestMode.

When you’re ready to publish your game, simply disable Development Build and test mode will be disabled. This way you don’t accidentally ship your game with test mode enabled, which would only show test ads and not generate any revenue.

To show picture ads, Unity Ads needs to be both initialized and ready to show ads:

if (Advertisement.isInitialized &&
    Advertisement.isReady("pictureZone"))
{
    Advertisement.Show("pictureZone");
}

Something like this will allow you to show an ad shortly after the scene loads:

public string zoneID = "pictureZone";
public float timeout = 15f;

private float _startTime = 0f;
private float _yieldTime = 1f;

// A return type of IEnumerator allows for the use of yield statements.
//  For more info, see: http://docs.unity3d.com/ScriptReference/YieldInstruction.html
IEnumerator Start ()
{
    // Set zoneID to null if string is empty.
    //  When zoneID value is null, the default zone is used.
    if (string.IsNullOrEmpty(zoneID)) zoneID = null;

    // Check to see if Unity Ads is initialized.
    //  If not, wait a second before trying again.
    do yield return new WaitForSeconds(_yieldTime);
    while (!Advertisement.isInitialized);

    Debug.Log("Unity Ads has finished initializing. Waiting for ads to be ready...");

    // Set a start time for the timeout.
    _startTime = Time.timeSinceLevelLoad;

    // Check to see if Unity Ads are available and ready to be shown.
    //  If not, wait a second before trying again.
    while (!Advertisement.isReady(zoneID))
    {
        if (Time.timeSinceLevelLoad - _startTime > timeout)
        {
            Debug.LogWarning("The process for showing ads on load has timed out. " +
                             "Ad not shown.");

            // Break out of both this loop and the Start method; Unity Ads will not
            //  be shown on load since the wait time exceeded the time limit.
            yield break;
        }

        yield return new WaitForSeconds(_yieldTime);
    }

    Debug.Log("Ads are available and ready. Showing ad now...");

    // Show ad after Unity Ads finishes initializing and ads are ready to show.
    Advertisement.Show(zoneID);
}

Additional code examples and demo scene are available here.

1 Like

thx you :slight_smile:

hmm funny i use this one

  • if (Advertisement.isInitialized &&
  • Advertisement.isReady(“pictureZone”))
  • {
  • Advertisement.Show(“pictureZone”);
  • }

And in unity3d this works good.
But when i used it on my android phone this dont want to show me a picture ad why???

And how to go out of the test mode??
and i think the picture ad is by me buggy ??!!

Keep in mind, picture ads are still in beta. Which means there is limited fill for English speaking countries, and in most cases no fill for non-English speaking countries.

The example I provided earlier in this thread allows you to have test mode enabled while Development Build is enabled in Unity’s Build Settings. You can override this behavior by selecting disableTestMode in the inspector for the script.

To enable and disable test mode for Unity Ads, pass a boolean value when calling Initialize():

ads show during 1st run but not after that why? and again run after clearing app cache.

Same happens to me after the 1.2.1 update.

How can I create Picture-ad placement in UnityAds Admin ?
I have only the “Video” and “Rewarded video” types…

Thank’s

Picture Ads have been removed.

(they need to update their docs, it’s been months since since was announced)

1 Like