Question by
CyberModeSoftware · Jun 06, 2021 at 09:38 PM ·
adsunityads
Why my ads is not visible on final build just in editor?
I have some ads on my game like reward video and interstitial video Reward video needs to play when i pres the +20k money button and interstitial when you select a car. In editor everything works perfect but in build nothing work I tried all methods that i find on the internet but is the same problem.
interstitial ad :
public string mySurfacingId = "Interstitial";
string gameId = "4****9";
bool testMode = false;
void Start()
{
// Initialize the Ads service:
Advertisement.Initialize(gameId);
}
public void ShowInterstitialAd()
{
// Check if UnityAds ready before calling Show method:
if (Advertisement.IsReady())
{
Advertisement.Show(mySurfacingId);
// Replace mySurfacingId with the ID of the placements you wish to display as shown in your Unity Dashboard.
}
else
{
Debug.Log("Interstitial ad not ready at the moment! Please try again later!");
}
}
video reward :
private string gameId = "4****9";
Button myButton;
public string mySurfacingId = "rewardedVideo";
public MoneyMNG Money;
public bool testMode;
void Start()
{
myButton = GetComponent<Button>();
Advertisement.Initialize(gameId,testMode);
// Set interactivity to be dependent on the Ad Unit or legacy Placement’s status:
myButton.interactable = Advertisement.IsReady(mySurfacingId);
// Map the ShowRewardedVideo function to the button’s click listener:
if (myButton) myButton.onClick.AddListener(ShowRewardedVideo);
// Initialize the Ads listener and service:
Advertisement.AddListener(this);
}
// Implement a function for showing a rewarded video ad:
public void ShowRewardedVideo()
{
// Check if UnityAds ready before calling Show method:
if (Advertisement.IsReady(mySurfacingId))
{
Advertisement.Show(mySurfacingId);
}
}
// Implement IUnityAdsListener interface methods:
public void OnUnityAdsReady(string surfacingId)
{
// If the ready Ad Unit or legacy Placement is rewarded, activate the button:
if (surfacingId == mySurfacingId)
{
myButton.interactable = true;
}
}
public void OnUnityAdsDidFinish(string surfacingId, ShowResult showResult)
{
// Define conditional logic for each ad completion status:
if (showResult == ShowResult.Finished)
{
// Reward the user for watching the ad to completion.
PlayerPrefs.SetInt("Money", PlayerPrefs.GetInt("Money") + 20000);
Money.Update2();
Debug.Log("Rewarded");
}
else if (showResult == ShowResult.Skipped)
{
// Do not reward the user for skipping the ad.
}
else if (showResult == ShowResult.Failed)
{
}
}
public void OnUnityAdsDidError(string message)
{
// Log the error.
}
public void OnUnityAdsDidStart(string surfacingId)
{
// Optional actions to take when the end-users triggers an ad.
}
Comment