Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

468
Vistas
You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. Unity Google AdMob

Assets:

  1. Unity 2018.4.30f1

  2. GoogleMobileAds-v5.4.0.unitypackage plugin

  3. Enable In GoogleMobileAdsSettings - GoogleAdMob and I Added the App Id to Android and IOS

adbanner.cs script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;

public class AdBanner : MonoBehaviour
{

    private BannerView bannerView;
    private string idApp, idBanner;

    public void Start()
    {
        idApp = "ca-app-pub-2584265330622657~8465399911";
        idBanner = "ca-app-pub-2584265330622657/1877307815";

        MobileAds.Initialize(idApp);
        RequestBannerAd();
    }

    public void RequestBannerAd()
    {
        bannerView = new BannerView(idBanner, AdSize.Banner, AdPosition.Bottom);
        AdRequest request = AdRequestBuild();
        bannerView.LoadAd(request);
    }

    AdRequest AdRequestBuild()
    {
        return new AdRequest.Builder().Build();
    }

}


I have this error that does not allow me to build the application further for xcode

The all errors :

You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all UnityEngine.MonoBehaviour:.ctor() ButtonBehaviour:.ctor() GoogleMobileAds.Unity.BannerClient:CreateButtonBehavior() (at Assets/GoogleMobileAds/Platforms/Unity/BannerClient.cs:64) GoogleMobileAds.Unity.BannerClient:ShowBannerView() (at Assets/GoogleMobileAds/Platforms/Unity/BannerClient.cs:143) GoogleMobileAds.Unity.BannerClient:LoadAd(AdRequest) (at Assets/GoogleMobileAds/Platforms/Unity/BannerClient.cs:123) GoogleMobileAds.Api.BannerView:LoadAd(AdRequest) (at Assets/GoogleMobileAds/Api/BannerView.cs:61) AdBanner:RequestBannerAd() (at Assets/Scripts/AdBanner.cs:25) AdBanner:Start() (at Assets/Scripts/AdBanner.cs:18)

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda