Asteroid avoider

[SOLVED]
I keep getting error EndTimer I have used it like this

Public void Endgame()
{
asteroidSpawner.enabled = false;
int finalScore = scoreSystem.EndTimer();

The EndTimer keeps on getting red underline however it is in my score system script

And so does shouldcount
I have used it like

Void update()

If(!shouldCount) { return; }

it keeps on getting underlined

When you save and return to Unity, are you getting red error messages in the Console window (preventing you from playing)?

Yes I was but got it fixed I am facing a new issue now
With
Advertisement.AddsListener(this)

AddsListener is getting underlined now

Again, the same question applies.
What is the error message if any in the Console?
Paste in the your Ads script and we’ll take a look.

Here it is

For future, please try to crop the screens of error messages, so they’re easier to view in the forums.
It’s telling you that on line 31 of AdManager.cs, there is a reference to “AddsListener” that the Advertisement system doesn’t have a definition for. Try changing it to AdsListener.

I did it’s not working still I have checked all the spelling everywhere in the script

I can’t tell what’s wrong without seeing the script. Be sure to paste in the TEXT of the script, not a screenshot.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;

public class IUnityAdsListener : MonoBehaviour{
}

public class AdManager : MonoBehaviour
{
    [SerializeField] private bool testMode = true;
    public static AdManager Instance;
#if UNITY_ANDROID
    private string gameId = "4710053";
#elif UNITY_IOS    
    private string gameId = "4710052";
#endif  
 
    private GameOverHandler gameOverHandler;

    void Awake()
    {
        if  (Instance != null && Instance != this)
        {
            Destroy(gameObject);
        }
        else
        {
            Instance = this;
            DontDestroyOnLoad(gameObject)
            Advertisement.AdListener(this);
            Advertisement.Initialize("gameId", testMode);
        }
    }

    public void ShowAd(GameOverHandler gameOverHandler)
    {
        this.gameOverHandler = gameOverHandler;
        Advertisement.Show("rewardedVideo");
    }
   
    public void OnUnityAdsDidError(string message)
    {
        Debug.LogError($"Unity Ads Error: {message}");
    }

    public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
    {
        switch (showResult)
        {
            case ShowResult.Finished:
                gameOverHandler.ContinueGame();
                break;
            case ShowResult.Skipped:
                // Ad was skipped
                break;
            case ShowResult.Failed:
                Debug.LogWarning("Ad Failed");
                break;
        }
    }

    public void OnUnityAdsDidStart(string placementId)
    {
        Debug.Log("Ad Started");
    }

    public void OnUnityAdsReady(string placementId)
    {
        Debug.Log("Unity Ads Ready");
    }
}

Sorry about the delay on this, I was away on Easter, and am just getting over a bug that kept me away from the computer.

Now that I can see the script in context, I can see the error. You’re looking to AddListener. In the screenshot, you had AddsListener and I didn’t have enough context for the answer.

This should be your fix.

Advertisement.AddListener(this);

I solved it sir

Privacy & Terms