This project is read-only.

Enable and disable ads for unity

Feb 7, 2014 at 3:16 PM
Hi, i'm have finished unity game that i want to add ads by using your adrotator and i want the ads to only show in pause menu, so how to control enable propery in adrotator?

my project using javascript and i don't know how to control your adrotator c# code... i already tried to comunicate but it throwing null reference to me
private var csScript : AdRotatorUnitySDK.Assets.Plugins.AdSettings;

function pause() {
    isPause = true;
    csScript.IsEnabled = true;

function unPause(){
    isPause = false;
    modeConfirm = false;
    csScript.IsEnabled = false;
Feb 8, 2014 at 8:13 AM
Looks like that capability doesn't exist in the Bridge at this time.

We'll have to add that in a future release.

There are a couple potential ways we could add this, either using a standard interop to bridge to the page the control is running on and set the IsEnabled property

Or expose another setter through the management page to update the settings and update the control. Or we could just control it completely from the host projec completely.

Will get back to you on that but as we have full time jobs it may be some time
Feb 8, 2014 at 8:32 AM
well i just want the ads to show when i pause the game and hide it when my game resume... can i do it using this adrotator?
and i also aware that even when i selecting the ads size , sometimes it show much bigger than what i anticipated
Feb 8, 2014 at 9:14 AM
AdRotator can do this yes, just the trick of doing it through the integration.

You can try this for now:
        var manager = GameObject.Find("AdRotatorManagement");
        var AdRotator = manager.GetComponent<AdRotatorUnitySDK.Assets.Plugins.AdRotatorManagement>();
        AdRotator.AdSettings.IsEnabled = false;
Which should achieve what you are trying to do, note it will cause an error in the editor currently because it expects the platform project to be running.

Let me know if this works for you. Worked fine in testing.

As for the AdSizes, this is a common problem with so many ad providers and we are looking at solutions, it comes down to how ad providers react to different ad size settings, some will get the closest match if the pixel rations are not exact, others will just deliver a default ad size. Just experiment with which ever ad size fits you.

In the future we intend to abstract the ad size configuration so you always get the closest match but it's a fair amount of work to implement.
Feb 8, 2014 at 10:59 AM
well i already tried and it not working it throw me nullreference

Additional information: Object reference not set to an instance of an object.

here is how i use it
function pause() {
    isPause = true;
        var manager = GameObject.Find("AdRotatorManagement");
    var AdRotator = manager.GetComponent(AdRotatorUnitySDK.Assets.Plugins.AdRotatorManagement);
    AdRotator.AdSettings.IsEnabled = true;

function unPause(){
    isPause = false;
    var manager = GameObject.Find("AdRotatorManagement");
    var AdRotator = manager.GetComponent(AdRotatorUnitySDK.Assets.Plugins.AdRotatorManagement);
    AdRotator.AdSettings.IsEnabled = false;
Feb 8, 2014 at 11:51 AM
Check your config in the defaultadsettings.xml file and verify you have referenced all the ad providers dlls in your client project.

known issue with pubcenter at the moment where it causes a Unity error if you have it in your config bu not referenced
Feb 8, 2014 at 12:06 PM
i'm not using pubcenter since it's not supported in my country

here is my defaultadsettings.xml
<?xml version="1.0" encoding="utf-8"?>
<AdSettings xmlns:xsi="" xmlns:xsd="">
  <CultureDescriptors CultureName="">
    <AdDuplex AppId="84619" Probability="25"/>
    <Smaato AppId="65824924" SecondaryId="923872042" Probability="25"/>
    <Inmobi AppId="24c6dc74a89d48e8a765bf77720a4ba3" Probability="25"/>
    <InnerActive AppId="LaurensiusGame_Escape_WP"  Probability="25"/>
Feb 9, 2014 at 9:11 AM
Right, so you are targetting Windows phone then, I shall re-target and test with your config
Feb 9, 2014 at 9:46 AM
okay thank you, i'm looking forward for your solution :)
Jun 20, 2014 at 10:21 PM
Edited Jun 20, 2014 at 10:22 PM
I'd like to see this support as well! In my case, the user can pay to remove ads from the game - so I need to stop the ads from showing both at startup and if they choose to purchase removing ads mid-game.