Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 当前上下文中不存在Unity3D名称播发_C#_Unity3d_Unity3d Editor_Unityads - Fatal编程技术网

C# 当前上下文中不存在Unity3D名称播发

C# 当前上下文中不存在Unity3D名称播发,c#,unity3d,unity3d-editor,unityads,C#,Unity3d,Unity3d Editor,Unityads,我对Unity测试广告没有任何问题,它们在Android构建中显示良好,没有错误 但当我即将发布时,我关闭了编辑器中的“测试模式”广告,现在代码中对广告的所有引用突然在当前上下文中不存在 错误: Assets\Scripts\AdManager.cs(32,21): error CS0103: The name 'Advertisement' does not exist in the current context 我还没有在网上找到任何关于这个的信息,我真的很困惑。已经尝试过“关闭广告,重

我对Unity测试广告没有任何问题,它们在Android构建中显示良好,没有错误

但当我即将发布时,我关闭了编辑器中的“测试模式”广告,现在代码中对广告的所有引用突然在当前上下文中不存在

错误:

Assets\Scripts\AdManager.cs(32,21): error CS0103: The name 'Advertisement' does not exist in the current context
我还没有在网上找到任何关于这个的信息,我真的很困惑。已经尝试过“关闭广告,重新打开unity,打开广告”,但并没有消除错误

这是我的密码:

using UnityEngine;
using UnityEngine.Advertisements;

public class AdManager : MonoBehaviour
{

    public void ShowAd(int roundScore){

        Debug.Log("Recieved request to display an ad");
        Debug.Log(roundScore);

        if(roundScore >= 40){

            Debug.Log("Trying to show an ad because score is larger than 40");

            // Check for ad + show it
            if(Advertisement.IsReady("video")){
                Advertisement.Show("video");
            }
        }else{

            Debug.Log("Trying to show a random ad");

            if(Random.Range(0, 7) == 4){

                Debug.Log("Random ad will be shown if ready");

                //Check for ad + show it
                if(Advertisement.IsReady("video")){

                    Debug.Log("An ad was ready so it is being shown");
                    Advertisement.Show("video");
                }
            }
        }

    }
}

感谢您的帮助。

从软件包管理器中删除sdk,并且如果您已经在unity services下的ads选项卡中启用了内置ads扩展,请将其禁用。然后从项目内的资产存储区安装并导入包。
这个问题会解决的。快乐编码:)

你是通过安装的吗?它安装在v2.0.8版,更新到3.4.2版,现在我有很多错误,比如:
GUID[db87dc7dfd26443b898812877180d0a4]用于资产“Packages/com.unity.ads/Editor/Resources/Purchase.png”与“Assets/Editor/Resources/Purchase.png”(当前所有者)冲突无法分配新GUID,因为资源位于不可变文件夹中。该资产将被忽略这让事情变得更糟,看起来。