//Banner Ads using UnityEngine; using System.Collections; using Tizen.AdLib; using System; public class AdListener1 : BannerAdListener { private AdProvider adobj; public AdListener1(AdProvider adobject) { adobj = adobject; } public void OnAdClicked(IntPtr handle) { } public void OnAdLoadFailed(IntPtr handle, ErrorType error) { adobj.BannerAdSetVisibility(handle, false); } public void OnAdLoadSucceeded(IntPtr handle) { adobj.BannerAdSetVisibility(handle, true); } } public class inmobiManager : MonoBehaviour { AdProvider adobject = AdProvider.Instance; // Use this for initialization void Start () { ErrorType result = adobject.InitAdlib("0cb220ea6e514f5894c1d51f12c22e9e", "_inmobi", "https://i.l.inmobicdn.net/sdk/jsac/p1/inmobi.js", "inmobi_conf"); // Your site ID from InMobi IntPtr adhandle; AdListener1 adListener = new AdListener1(adobject); result = adobject.AddBannerAd(BannerAdSize.BANNER_AD_SIZE_SMALL, out adhandle); result = adobject.BannerAdLoad(adhandle); result = adobject.BannerAdEnableAutoRefresh(adhandle, true); result = adobject.BannerAdSetPosition(adhandle, BannerAdPosition.BANNER_AD_POS_BOTTOM_CENTER); adobject.SetBannerAdListener(adhandle, adListener); result = adobject.BannerAdSetVisibility(adhandle, true); } // Update is called once per frame void Update () { if (Input.GetKeyDown(KeyCode.Escape)) { adobject.DeinitAdlib(); Application.Quit(); } } }
//Interstitial Ads using UnityEngine; using System.Collections; using Tizen.AdLib; using System; public class AdListener : InterstitialAdListener { public void OnAdLoadSucceeded(IntPtr handle) { Debug.Log("Entered in to OnAdLoadSucceeded handle is" + handle); AdProvider.Instance.InterstitialAdShow(); } public void OnAdLoadFailed(IntPtr handle, ErrorType error) { Debug.Log("Entered in to OnAdLoadFailed"); } public void OnAdOpened(IntPtr handle) { Debug.Log("Entered in to OnAdOpened handle is" + handle); } public void OnAdClosed(IntPtr handle) { Debug.Log("Entered in to OnAdClicked handle is" + handle); } } public class Paddle : MonoBehaviour { public float paddleSpeed = 1f; private Vector3 playerPos = new Vector3 (0f, -9.63f, 0f); AdProvider adobject = AdProvider.Instance; void Start () { adobject.InitAdlib("a1dfabc3a75a4a8a9145295710b26c2e", "_inmobi", "https://i.l.inmobicdn.net/sdk/jsac/p1/inmobi.js", "inmobi_conf"); // Your site ID from InMobi //IntPtr adhandle; AdListener myListener = new AdListener(); ErrorType result = adobject.AddInterstitialAd(); result = adobject.InterstitialAdLoad(); result = adobject.SetInterstitialAdListener(myListener); result = adobject.InterstitialAdShow(); // Show the interstitial ad }/// // Update is called once per frame void Update () { if (Input.GetKeyDown(KeyCode.Escape)) { adobject.DeinitAdlib(); Application.Quit(); } float xPos = transform.position.x + (Input.GetAxis ("Horizontal") * paddleSpeed); playerPos = new Vector3 (Mathf.Clamp (xPos, -8f, 8f), -9.63f, 0f); transform.position = playerPos; } }
Problems applying InMobi ads in unity. First, I am Korean and I am developing in Korea. I wanted to apply banner ads and interstitials to my application. In the case of Interstitial Ads, when I put my Site Id, I get a gray background instead of advertising. In the case of Banner Ads, using Test Site Id provided by InMobi will normally display the test banner. However, when I put my Site Id, the banner does not pop up. All of the testing was done on a Tizen Z3 device from an Indian server using RTL services. What did I do wrong? I've attached the code. Let me know what's wrong.