Search Unity

Add Admob In may Game Plz help "in Bold texte" i want show banner and inter...

Discussion in 'Unity Ads & User Acquisition' started by inderlands, Mar 12, 2018.

?

Add Admob In may Game Plz help "in Green texte" i want show banner and inter...

  1. ads

    2 vote(s)
    100.0%
  2. admob

    2 vote(s)
    100.0%
Multiple votes are allowed.
  1. inderlands

    inderlands

    Joined:
    Mar 8, 2018
    Posts:
    1
    ------------------------------------------------------------------------------------------
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.Events;

    public class AdvertController : MonoBehaviour {


    public bool disableAdverts;

    public bool showAdsOnMainMenu;
    public int adsOnMainMenuInterval;
    private int adsOnMainMenuIntervalCounter;

    public bool showAdsOnGameOver;
    public int adsOnGameOverInterval;
    private int adsOnGameOverIntervalCounter;

    public GameObject advertGuiContainer;
    public bool useAdvertGuiContainer;

    public UnityEvent onAdvertRequested;
    public UnityEvent onAdvertShowed;

    // Use this for initialization
    void Awake ()
    {
    if (advertGuiContainer != null)
    {
    advertGuiContainer.SetActive(false);
    }

    adsOnMainMenuIntervalCounter = 1;
    adsOnGameOverIntervalCounter = 1;
    }



    public void requestAdvert()
    {

    if (disableAdverts == true) return;

    if (onAdvertRequested != null)
    {
    onAdvertRequested.Invoke();
    }
    //////////////////////////////////////////
    // CALL YOUR ADVERT REQUEST METHOD HERE
    // .......
    //////////////////////////////////////////


    }


    public void showAdvertOnMainMenu()
    {
    if (disableAdverts == true) return;

    if (showAdsOnMainMenu == true && adsOnMainMenuIntervalCounter == adsOnMainMenuInterval)
    {
    adsOnMainMenuIntervalCounter = 0;
    Debug.Log("ADVERT SHOWING ON MAIN MENU");

    if (useAdvertGuiContainer == true)
    {
    advertGuiContainer.SetActive(true);
    }

    if (onAdvertShowed != null)
    {
    onAdvertShowed.Invoke();
    }
    //////////////////////////////////////////
    // CALL YOUR ADVERT SHOW METHOD HERE
    // .......
    //////////////////////////////////////////

    }

    adsOnMainMenuIntervalCounter++;


    }

    public void showAdvertOnGameOver()
    {

    if (disableAdverts == true) return;

    if (showAdsOnGameOver == true && adsOnGameOverIntervalCounter == adsOnGameOverInterval)
    {

    adsOnGameOverIntervalCounter = 0;
    Debug.Log("ADVERT SHOWING ON GAME OVER");

    if (useAdvertGuiContainer == true)
    {
    advertGuiContainer.SetActive(true);
    }

    if (onAdvertShowed != null)
    {
    onAdvertShowed.Invoke();
    }

    //////////////////////////////////////////
    // CALL YOUR ADVERT SHOW METHOD HERE
    // .......
    //////////////////////////////////////////

    }

    adsOnGameOverIntervalCounter++;


    }

    }

    -----------------------------------------------------------------------------------------------
     
  2. ESSADIK

    ESSADIK

    Joined:
    May 6, 2018
    Posts:
    1
    hi bro ... i have the same admob code
    I am still trying to solve the essue
    ihope you reply me if you have the solution
    thank adv
    -(3te9na a khoya rah wahel )
     
  3. RozekEnhance

    RozekEnhance

    Joined:
    Feb 2, 2017
    Posts:
    15
    Hi.
    If you are looking to ad admob to unity, check out Enhance.
    You can ad both admob and unity to your project in just minutes. There are a bunch of networks and services supported on top of that.
    For more info, just follow the link : https://goo.gl/VLvSoQ