-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdvertismentManager.cs
51 lines (41 loc) · 1.12 KB
/
AdvertismentManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;
using UnityEngine.UI;
//This class takes care of showing advertisments in the game
public class AdvertismentManager : MonoBehaviour
{
//instance of the class to be able to be called from another classes
public static AdvertismentManager instance;
//the unity id of the game
string id = "3648406";
//check if the game still being tested or not
bool testMode = true;
//Makes sure that the instance is not null
void Awake()
{
if (instance == null)
{
instance = this;
}
}
private void Start()
{
//intialize the advertisment with the game id
Advertisement.Initialize(id, testMode);
}
// Update is called once per frame
void Update()
{
}
//function that will be called from other classes to show a video ad
public void ShowAds()
{
//if the video is ready show the ad!
if (Advertisement.IsReady("video"))
{
Advertisement.Show("video");
}
}
}