C# 无法从';GoogleMobileAds.Api.interstitalad';至';字符串';
我遇到了以下错误: Assets\Find The Pairs\Scripts\AdsManager.cs(54,43):错误CS1503:参数1:无法从“GoogleMobileAds.Api.Interstitalad”转换为“string” 使用以下代码:C# 无法从';GoogleMobileAds.Api.interstitalad';至';字符串';,c#,unity3d,C#,Unity3d,我遇到了以下错误: Assets\Find The Pairs\Scripts\AdsManager.cs(54,43):错误CS1503:参数1:无法从“GoogleMobileAds.Api.Interstitalad”转换为“string” 使用以下代码: using System.Collections; using System.Collections.Generic; using UnityEngine; using GoogleMobileAds.Api; public clas
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
public class AdsManager : MonoBehaviour
{
public static AdsManager instance;
private string appID = "ca-app-pub-3940256099942544~3347511713";
private BannerView bannerView;
private string bannerID = "ca-app-pub-3940256099942544/6300978111";
private InterstitialAd fullScreenAd;
private string fullScreenAdID = "ca-app-pub-3940256099942544/1033173712";
private void Awake()
{
if (instance == null)
{
instance = this;
}
else
{
Destroy(this);
}
}
private void Start()
{
RequestFullScreenAd();
}
public void RequestBanner()
{
bannerView = new BannerView(bannerID, AdSize.Banner, AdPosition.Bottom);
AdRequest request = new AdRequest.Builder().Build();
bannerView.LoadAd(request);
bannerView.Show();
}
public void HideBanner()
{
bannerView.Hide();
}
public void RequestFullScreenAd()
{
fullScreenAd = new InterstitialAd(fullScreenAd);
AdRequest request = new AdRequest.Builder().Build();
fullScreenAd.LoadAd(request);
}
public void ShowFullScreenAd()
{
if (fullScreenAd.IsLoaded())
{
fullScreenAd.Show();
}
else
{
Debug.Log("Full Screen Ad Not Loaded");
}
}
}
我得到这个错误:
Assets\Find The Pairs\Scripts\AdsManager.cs(54,43):错误CS1503:参数1:无法从“GoogleMobileAds.Api.Interstitalad”转换为“string”
我需要帮助
public void RequestFullScreenAd()
{
fullScreenAd = new InterstitialAd(fullScreenAd);
AdRequest request = new AdRequest.Builder().Build();
fullScreenAd.LoadAd(request);
}
创建新的Interstitalad对象时,您试图将Interstitalad对象作为字符串参数传递。它需要一个声明为fullScreenAdID的id(字符串)。所以
public void RequestFullScreenAd()
{
fullScreenAd = new InterstitialAd(fullScreenAdID);
AdRequest request = new AdRequest.Builder().Build();
fullScreenAd.LoadAd(request);
}
应该有用