为什么我得到“没有超载方法.createBanner需要' 3'参数呢?

时间:2014-07-07 14:18:41

标签: c# unity3d admob

当我尝试使用Google Admob致电No Overload Method .createBanner takes '3' arguments时,为什么会收到错误CreateBanner

using UnityEngine;
using System.Collections;

public class AdMob : MonoBehaviour {

private const string AD_UNIT_ID = " ";
private AdMobPlugin admob;

public bool hidden = true;

// Use this for initialization
void Start () {

    admob = GetComponent<AdMobPlugin> ();
    admob.CreateBanner (AD_UNIT_ID, AdMobPlugin.AdSize.SMART_BANNER, false);
    admob.RequestAd ();
}

3 个答案:

答案 0 :(得分:4)

AdMobPlugin.CreateBanner()不只需要三个参数,需要五个参数。您缺少唯一的插页式广告ID,isTestDevice布尔值。

从Unity Admob AdMobPlugin的源代码中,预期的参数是:

public void CreateBanner(string adUnitId, AdSize adSize, bool isTopPosition, string interstitialId, bool isTestDevice)

所以你的方法调用应该如下:

admob.CreateBanner(AD_UNIT_ID, AdMobPlugin.AdSize.SMART_BANNER, true, INTERSTITIAL_ID, IS_TEST_DEVICE);

查看Adding Google Admob Plugin to UnityUnity Admob source

答案 1 :(得分:0)

响应cyral:

这是一个巨大的错误构建播放器消息。具体来说:&#39;构建播放器时出错:

CommandInvokationFailure:无法重新打包资源。请参阅控制台了解详细信息 C:\ Users \ Max \ Documents \ adt-bundle-windows-x86_64-20140624 \ sdk \ build-tools \ android-4.4W \ aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S&#34; res&#34; -I&#34; C:/ Users / Max / Documents / adt-bundle-windows-x86_64-20140624 / sdk / platforms / android-20 \ android.jar&#34; -F bin / resources.ap_ --extra-packages com.google.example.games.basegameutils:com.google.android.gms:com.google.example.games.mainlibproj -S&#34; C:\ Users \ Max \ Documents \ Unity Dev \ TWOTWO \ Temp \ StagingArea \ android-libraries \ BaseGameUtils \ res&#34; -S&#34; C:\ Users \ Max \ Documents \ Unity Dev \ TWOTWO \ Temp \ StagingArea \ android-libraries \ google-play-services_lib \ res&#34; &#39;

答案 2 :(得分:-1)

您收到错误,因为AdMobPlugin CreateBanner的实例方法没有3个参数。