Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
using UnityEngine;
using System.Collections;
using GoogleMobileAds.Api;

public class InterstitialAdScript : MonoBehaviour
{

    bool hasShownAdOneTime;

    void Start()
    {
        if (GameScript.isGameOver)
        {
            if (!hasShownAdOneTime)
            {
                hasShownAdOneTime = true;
                Invoke("showInterstitialAd", 60.0f);
            }
        }
    }
    
    public void showInterstitialAd()
    {
		 string adID = "ca-app-pub-";

      showInterstitialAd();

            //Stop Sound
            //

            Debug.Log("SHOW AD");
        }

    }
       
#if UNITY_ANDROID
        string adUnitId = adID;
    private static string adID;
    public object interstitialAd;
#elif UNITY_IOS
        string adUnitId = adID;
#else
        string adUnitId = adID;
#endif

   }


What I have tried:

string adUnitId = adID;
private static string adID;
public object interstitialAd;


I don't know how to fix it ... ...
Posted
Updated 10-Feb-19 7:02am
Comments
FernandoUY 10-Feb-19 10:13am    
Which is the error? What do you need to acomplish?
[no name] 10-Feb-19 11:38am    
Targeting multiple platforms; Unity; plugins. Too far into the bleeding edge.

1 solution

You have declared hasShownAdOneTime as bool type, but have not set an initial value.

The line:
C#
string adUnitId = adID;
is trying to address a local variable that only exists in the showInterstitialAd method, which incidentally contains a recursive loop.

You have also got declarations for string adUnitId = adID; in all three cases of your preprocessor #IF clauses; you should place a single copy outside the block, since it will always be generated.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900