So I have been working on implementing ads into my game, but when I imported the Unity Ads package and used the supplied sample code for a test, I get all kinds of Errors that are saying that the advertisement class does not contain definitions for… anything but I can actually look at the advertisement class and see the variables defined right there.
The script is exactly as provided by the UnityAds page.
using System;
using UnityEngine;
using UnityEngine.Advertisements;
public class Advertisement : MonoBehaviour {
void Awake() {
if (Advertisement.isSupported) {
Advertisement.allowPrecache = true;
Advertisement.Initialize (*censored*);
} else {
Debug.Log("Platform not supported");
}
}
void OnGUI() {
if(GUI.Button(new Rect(10, 10, 150, 50), Advertisement.isReady() ? "Show Ad" : "Waiting...")) {
// Show with default zone, pause engine and print result to debug log
Advertisement.Show(null, new ShowOptions {
pause = true,
resultCallback = result => {
Debug.Log(result.ToString());
}
});
}
}
}