Adrotator / AdrotatorV2

A highly customizable ad rotator component for Windows Phone and Windows 8 platforms, supporting the XAML, WinJS, Silverlight, XNA and Monogame frameworks.
24 stars 22 forks source link

Unity plugin Enable/Disable Ads #16

Open jvanrij opened 10 years ago

jvanrij commented 10 years ago

I have been trying to get ads to appear at only certain points in the game on WP8. I have been using the following to enable and disable the ads.

var manager = GameObject.Find("AdRotatorManagement");
var AdRotator = manager.GetComponent<AdRotatorUnitySDK.Assets.Plugins.AdRotatorManagement>(); 
AdRotator.AdSettings.IsEnabled = false;
AdRotator.UpdateAd();

Which was suggested by Simon at https://getadrotator.codeplex.com/discussions/529709

The first scene in the game has the AdRotatorManagement GameObject. When the game starts the ads load and display fine and I get these Log messages.

AdRotator: Trying provider AdDuplex 
  (Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp Line: 55)
AdRotator: Ad created for provider AdDuplex 
  (Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp Line: 55)
AdRotator: Ad created for provider AdDuplex

If I then use the above code to disable and then later re-enable the ads, they don't appear. I get the following Log messages.

Update Ad Rotator Display Settings. 
  (Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp Line: 55)
AdRotator: Trying provider None
  (Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp Line: 55)
AdRotator: No Ads available
  (Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp Line: 55)
AdRotator: Trying provider None

This issue is dependant on the time I wait before disabling the AdRotator. If I wait 30 seconds after the game starts before disabling the AdRotator, the ads do display correctly when re-enabled.

I really appreciate all the work you guys are doing on AdRotator, keep up the good work!

SimonDarksideJ commented 10 years ago

Hmm, that would seem to indicate that your adProvider is getting added to the failed list for some reason when it re-enables. odd. How many providers do you have configured?

jvanrij commented 10 years ago

Only AdDuplex. This is the settings file

<AdSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CultureDescriptors CultureName="">
<AdDuplex AppId="104335" Probability="100"/>
</CultureDescriptors>
</AdSettings>