์๊น Json ๊ด๋ จ ์ค๋ฅ๋ ์ด์ฐ์ ์ฐ ํด๊ฒฐ๋ผ์ ์ ๋ํฐ ์ ์ฆ ํํธ๋ก ๋์ด๊ฐ๋๋ฐ
๊ฐ์ข๊ฐ ์ข ์์ ์ ๋ง๋ ๊ฑฐ๋ผ ๊ทธ๋ฐ์ง ๋์๋ณด๋ UI๋ ์คํฌ๋ฆฝํธ ์ง๋ ๋ฐฉ์์ด ์์ฆ์ด๋ ๋ค๋ฅธ ๊ฒ ๊ฐ์
๊ฐ์ข์์ ๊ด๊ณ ์คํฌ๋ฆฝํธ ์งค ๋ ์ฒ์์
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 | using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Advertisements; public class AdController : MonoBehaviour { ShowOptions rewardOption; private void Awake() { rewardOption = new ShowOptions { resultCallback = GetReward }; } // Start is called before the first frame update void Start() { if(Advertisement.isSupported) { if(Application.platform == RuntimePlatform.Android) { Advertisement.Initialize("์๋ ID"); } else if(Application.platform == RuntimePlatform.IPhonePlayer) { Advertisement.Initialize("IOS ID"); } } else { Advertisement.Initialize("์๋ ID", true); } } private void GetReward(ShowResult result) { } // Update is called once per frame void Update() { } } | cs |
์ด๋ฐ ์์ผ๋ก ํ๋๋ฐ(๋น์นธ์ ์์ง ์งํ ์ค์ด๋ผ ๊ทธ๋ผ)
์ ๊ธฐ Awake์ resultCallback์ด ์๋์์ฑ์ ์ ๋์ค๋๋ผ
์๋ง ์ง๊ธ์ ์ฌ์ฉ ์ ํ๋ ํค์๋ ๊ฐ์
resultCallback์ ๋นผ๋ ๋๋ ๊ฑด์ง ์๋๋ฉด ์ฝ๋ ์ ์ฒด๋ฅผ ์์ฆ ์ฌ์ฉํ๋ ํํ๋ก ๊ฐ์์์ด์ผ ๋ ์ง ๋ชจ๋ฅด๊ฒ ๋๋ฐ ๋์ ์ข ๋ถํํด์
๊ตฌ๊ธ๋งํด๋ณธ ๊ฒฐ๊ณผ ์ด ๊ธ ๋ฌธ์ ๋ Advertisement.IsReady ์ ๋์ค๋ ๊ฑด ์ผ๋จ ํจํค์ง ๋งค๋์ ์์ Advertisement ๋ฒ์ ์ 4.0.0 ๋ฐ์ผ๋ก ๋ด๋ฆฌ๋๊น ํด๊ฒฐ์ ํ์. ์ด์ฐจํผ ๊ฐ์ข ๋ฐ๋ผ ํ๋ ๊ฑฐ๋ผ ์ค์ ์์ ์ฉ์ผ๋ก ๋ผ ๊ฑด ์๋๋ผ์ ์ด๋ฒ์ ์ด๋ ๊ฒ ๋๊ฒผ๋๋ฐ ๋์ค์ ์ ๋๋ก ๋ง๋ค ๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ ์ฐพ์๋ด์ผ๋ ๋ฏ