找不到类型或命名空间名称 'GameManager'

The type or namespace name 'GameManager' could not be found

几天来我一直在尝试为我的第一个游戏编写一些代码,这样如果用户没有观看完整的奖励视频广告(来自 admob)并且他提前关闭它,他就不会声明实际奖励是额外的生命。
我尝试做的第一件事是将游戏对象(与“广告脚本”相关联)从菜单场景移动到游戏场景,因为从游戏场景访问功能更容易,我猜..
看完一些教程后,这里是奖励视频广告的代码:

public class ads : MonoBehaviour
{
private RewardedAd rewardedAd;
private void RequestReward()
    {
        string adUnitId = "ca-app-pub-3940256099942544/5224354917";
        this.rewardedAd = new RewardedAd(adUnitId);

        this.rewardedAd.OnAdLoaded += this.HandleOnRewardedAdLoaded;
        this.rewardedAd.OnUserEarnedReward += this.HandleOnRewarded;
        this.rewardedAd.OnAdClosed += this.HandleOnRewardedAdClosed;

        AdRequest request = new AdRequest.Builder().Build();
        this.rewardedAd.LoadAd(request);
    }
public void ShowRewardVideo()
    {
        if (this.rewardedAd.IsLoaded())
        {
            this.rewardedAd.Show();
        }
        else
        {
            Debug.Log("Reward video is not ready yet");
        }
    }
public void HandleOnRewardedAdLoaded(object sender, EventArgs args)
    {
        ShowRewardVideo();
    }
public void HandleOnRewarded(object sender, EventArgs args)
    {
      // SO, If I understand properly, if I want players not to receive the extra life<br>
      before the reward video is finished, I have to write here the code for receiving the extra life 
      instead of writing it in the GameManager script. (script that is down below)

    }
public void HandleOnRewardedAdClosed(object sender, EventArgs args)
    {
        this.rewardedAd.OnAdLoaded -= this.HandleOnRewardedAdLoaded;
        this.rewardedAd.OnUserEarnedReward -= this.HandleOnRewarded;
        this.rewardedAd.OnAdClosed -= this.HandleOnRewardedAdClosed;
    }

这里我有 GameScript 中的 2 个函数可以让我展示广告: 第一个,在按下 in-game 按钮“Watch for extra life”

时调用
public void ShowReward()
{
        birdParent.SetActive(false);
        ads.instance.ShowRewardVideo();
        gameOverCanvas.SetActive(false);
        score.SetActive(false);
      ->rewardPanel.SetActive(true);
        Time.timeScale = 0;
}

点击该按钮后视频开始播放,正如您在函数中看到的那样,带有奖励的面板被激活(无论您是观看完整视频还是关闭它)。然后,看完视频后,您会回到游戏,您会看到一个面板,上面写着类似“感谢您观看视频,这是您的额外生命。按确定”之类的内容。当按下按钮 OK 时,调用此函数

public void ContinueAfterReward()
{
    score.SetActive(true);
    rewardPanel.SetActive(false);
    Time.timeScale = 1;
    Start();
    GameHasStarted();
    bird.Start();
    bird.Update();
    score.SetActive(true);
}

问题是这两个函数在 'GameManager' 脚本中(在 GameManager object 中)但我希望它们以某种方式集成到 [=45= 中的脚本中] 脚本(在标准游戏对象 object 中),因此我可以在该手柄工具中插入或调用函数,以防止用户在想要获得奖励时跳过视频。我试图在广告脚本中声明一个 'public GameManager gameManager'(这样我就可以在广告脚本中调用函数)但它根本不起作用,我从标题中得到了错误。

我不知道你是否明白我想做什么,但如果你有任何想法,请写一个回复,因为我在这件事上苦苦挣扎了几个小时,就是想不通……或者你是否知道其他方法.. :)

编辑:

所以,基本上,在 GameObject 中我有脚本 'ads',在其中我想从 GameManager object 的 'GameManager' 脚本中调用一些函数。即使我在 GM 脚本中声明了 public 静态 GameManager 实例,我也无法在广告脚本中调用 GameManager.instance.ShowReward() 或 public GameManager GameManager。我应该怎么做?

有趣的是,正如您在最后一张照片中看到的,我有一个小鸟游戏 object 关联了一个小鸟脚本,在其中我可以调用 gamemanager 脚本..这不是因为大写字母,我尝试了 gameManager 和 GameManager

在这种情况下,所有迹象都表明 Unity 试图强制 adsGameManager 之前编译。

进入 Unity 编辑器并将 ads 移出 GoogleMobileAds 目录并移至另一个 Assets 目录,因为 GoogleMobileAds 可能专门配置为编译 first/early.

万一不起作用,请将 ads 放在与 GameManager 相同的目录中。