Search Unity

Does Unity 2017 still need GameId in My C# Code?

Discussion in 'Unity Ads & User Acquisition' started by devinccc, Feb 9, 2018.

  1. devinccc

    devinccc

    Joined:
    Mar 24, 2017
    Posts:
    5
    As Title,I Get a Unity Ads Demo, But I can't find GameId in the code,So it means GameId is not nessary in Unity 2017 ? Because It successful show the AD.Thank you!!!

    using UnityEngine;
    using System.Collections;
    using UnityEngine.Advertisements;
    using UnityEngine.UI;
    public class show_ad : MonoBehaviour
    {

    public void ShowRewardedAd()
    {

    if (Advertisement.IsReady ("rewardedVideo"))
    {
    var options = new ShowOptions { resultCallback = HandleShowResult };
    Advertisement.Show ("rewardedVideo", options);
    print ("ad is ready");
    }
    else
    {
    ResultAction();
    print ("ad is fail");
    }
    }
    private void HandleShowResult(ShowResult result)
    {
    switch (result)
    {
    case ShowResult.Finished:
    print("The ad was successfully shown.");
    ResultAction();
    break;
    case ShowResult.Skipped:
    print("The ad was skipped before reaching the end.");
    ResultAction();
    break;
    case ShowResult.Failed:
    print("The ad failed to be shown.");
    ResultAction();
    break;
    }
    }
    private void ResultAction()
    {
    GameObject.Find ("GameManager").GetComponent<GameManager> ().gamestart ();
    GameObject.Find("ParentPlayer").GetComponent<Bounce>().alive();
    print ("AD_looking finish");
    }
    }
     
  2. Callie-Zhu

    Callie-Zhu

    Unity Technologies

    Joined:
    Mar 2, 2016
    Posts:
    42
    Hi,

    Thanks for writing.

    There's no necessary to specify Game ID if you have enabled Unity Ads in the Services Window. Unity Editor will auto initialize Ads on the beginning of the game session. This applies to Unity 5.5 and above.