|
4 | 4 |
|
5 | 5 | # Use |
6 | 6 | - After installation, open Adsetting to set up AdUnit Id |
7 | | -(Ctrl + E or GameControl -> adSetting to open Adsetting) |
8 | | -- You can choose Ad Network Applovin for Admob |
| 7 | + |
| 8 | + (Ctrl + E or GameControl -> adSetting to open Adsetting) |
| 9 | + |
| 10 | +  |
| 11 | +- You can choose Ad Network Applovin for Admob and click `Create` button to create AdUnitiVariable |
| 12 | +  |
| 13 | + |
| 14 | +- Set id for AdUnitVariable |
| 15 | + |
| 16 | +  |
| 17 | + |
| 18 | + (For Admob, you can get the test Id by going to `Context Menu` and selecting `Get Id Test`) |
| 19 | +  |
| 20 | + |
| 21 | +- Attach `Advertising` to the object in the scene (loading scene) to load the ad |
| 22 | +  |
| 23 | + |
| 24 | +- Script demo show ads |
| 25 | + |
| 26 | +``` |
| 27 | +using System.Collections; |
| 28 | +using System.Collections.Generic; |
| 29 | +using TMPro; |
| 30 | +using UnityEngine; |
| 31 | +using VirtueSky.Ads; |
| 32 | +
|
| 33 | +public class ADs : MonoBehaviour |
| 34 | +{ |
| 35 | + public TextMeshProUGUI textNoti; |
| 36 | + public AdUnitVariable banner; |
| 37 | + public AdUnitVariable inter; |
| 38 | + public AdUnitVariable reward; |
| 39 | +
|
| 40 | + public void ShowBanner() |
| 41 | + { |
| 42 | + Debug.Log(banner.IsReady()); |
| 43 | + banner.Show(); |
| 44 | + } |
| 45 | +
|
| 46 | + public void ShowInter() |
| 47 | + { |
| 48 | + if (inter.IsReady()) |
| 49 | + { |
| 50 | + LogMessage("inter is ready"); |
| 51 | + inter.Show().OnCompleted(() => { LogMessage("inter is completed"); }); |
| 52 | + } |
| 53 | + else |
| 54 | + { |
| 55 | + LogMessage("Inter is not ready"); |
| 56 | + } |
| 57 | + } |
| 58 | +
|
| 59 | + public void ShowReward() |
| 60 | + { |
| 61 | + if (reward.IsReady()) |
| 62 | + { |
| 63 | + LogMessage("reward is ready"); |
| 64 | + reward.Show().OnCompleted(() => { LogMessage("Reward is completed"); }).OnSkipped(() => { LogMessage("reward is skipped"); }); |
| 65 | + } |
| 66 | + else |
| 67 | + { |
| 68 | + LogMessage("reward is not ready"); |
| 69 | + } |
| 70 | + } |
| 71 | +
|
| 72 | + void LogMessage(string message) |
| 73 | + { |
| 74 | + textNoti.text = message; |
| 75 | + Debug.Log(message); |
| 76 | + } |
| 77 | +} |
| 78 | +``` |
0 commit comments