-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunity_sdk.cs
33 lines (33 loc) · 1.07 KB
/
unity_sdk.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
using UnityEngine;
using UnityEngine.Advertisements;
public class unity_sdk : MonoBehaviour, IUnityAdsInitializationListener
{
[SerializeField] string _androidGameId; // put your Id,s here
[SerializeField] string _iOSGameId; // put your IOS id here
[SerializeField] bool _testMode = true; // make it True, False on ads type
private string _gameId;
void Awake()
{
InitializeAds();
}
public void InitializeAds()
{
_gameId = (Application.platform == RuntimePlatform.IPhonePlayer)
? _iOSGameId
: _androidGameId;
Advertisement.Initialize(_gameId, _testMode, this);
}
public void OnInitializationComplete()
{
Debug.Log("Unity Ads initialization complete.");
}
public void OnInitializationFailed(UnityAdsInitializationError error, string message)
{
Debug.Log($"Unity Ads Initialization Failed: {error.ToString()} - {message}");
}
}