예제 #1
0
        public override int Create(string placementId,
                                   AdView adView,
                                   AdSize size)
        {
            AdUtility.prepare();
            AndroidJavaClass  unityPlayer     = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject currentActivity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
            AndroidJavaObject context         = currentActivity.Call <AndroidJavaObject>("getApplicationContext");

            AndroidJavaObject bridgedAdView = new AndroidJavaObject("com.facebook.ads.AdView",
                                                                    context,
                                                                    placementId,
                                                                    javaAdSizeFromAdSize(size));

            AdViewBridgeListenerProxy proxy = new AdViewBridgeListenerProxy(adView, bridgedAdView);

            bridgedAdView.Call("setAdListener", proxy);

            AdViewContainer adViewContainer = new AdViewContainer(adView);

            adViewContainer.bridgedAdView = bridgedAdView;
            adViewContainer.listenerProxy = proxy;

            int key = AdViewBridgeAndroid.lastKey;

            AdViewBridgeAndroid.adViews.Add(key, adViewContainer);
            AdViewBridgeAndroid.lastKey++;
            return(key);
        }
        public override int Create(string placementId, AdView adView, AdSize size)
        {
            AdUtility.prepare();
            AndroidJavaClass          androidJavaClass          = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject         @static                   = androidJavaClass.GetStatic <AndroidJavaObject>("currentActivity");
            AndroidJavaObject         androidJavaObject         = @static.Call <AndroidJavaObject>("getApplicationContext", new object[0]);
            AndroidJavaObject         androidJavaObject2        = new AndroidJavaObject("com.facebook.ads.AdView", androidJavaObject, placementId, javaAdSizeFromAdSize(size));
            AdViewBridgeListenerProxy adViewBridgeListenerProxy = new AdViewBridgeListenerProxy(adView, androidJavaObject2);

            androidJavaObject2.Call("setAdListener", adViewBridgeListenerProxy);
            AdViewContainer adViewContainer = new AdViewContainer(adView);

            adViewContainer.bridgedAdView = androidJavaObject2;
            adViewContainer.listenerProxy = adViewBridgeListenerProxy;
            int num = lastKey;

            adViews.Add(num, adViewContainer);
            lastKey++;
            return(num);
        }
        public override int Create(string placementId, AdView adView, AdSize size)
        {
            AdUtility.prepare();
            AndroidJavaClass  class2 = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject obj3   = class2.GetStatic <AndroidJavaObject>("currentActivity").Call <AndroidJavaObject>("getApplicationContext", new object[0]);

            object[]                  args          = new object[] { obj3, placementId, this.javaAdSizeFromAdSize(size) };
            AndroidJavaObject         bridgedAdView = new AndroidJavaObject("com.facebook.ads.AdView", args);
            AdViewBridgeListenerProxy proxy         = new AdViewBridgeListenerProxy(adView, bridgedAdView);

            object[] objArray2 = new object[] { proxy };
            bridgedAdView.Call("setAdListener", objArray2);
            AdViewContainer container = new AdViewContainer(adView)
            {
                bridgedAdView = bridgedAdView,
                listenerProxy = proxy
            };
            int lastKey = AdViewBridgeAndroid.lastKey;

            adViews.Add(lastKey, container);
            AdViewBridgeAndroid.lastKey++;
            return(lastKey);
        }
        public override int Create (string placementId,
                                    AdView adView,
                                    AdSize size)
        {
            AdUtility.prepare ();
            AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
            AndroidJavaObject context = currentActivity.Call<AndroidJavaObject>("getApplicationContext");

            AndroidJavaObject bridgedAdView = new AndroidJavaObject("com.facebook.ads.AdView",
                                                                    context,
                                                                    placementId,
                                                                    javaAdSizeFromAdSize (size));

            AdViewBridgeListenerProxy proxy = new AdViewBridgeListenerProxy (adView, bridgedAdView);
            bridgedAdView.Call ("setAdListener", proxy);

            AdViewBridgeImpressionListenerProxy impressionListenerProxy = new AdViewBridgeImpressionListenerProxy (adView, bridgedAdView);
            bridgedAdView.Call ("setImpressionListener", impressionListenerProxy);

            AdViewContainer adViewContainer = new AdViewContainer (adView);
            adViewContainer.bridgedAdView = bridgedAdView;
            adViewContainer.listenerProxy = proxy;
            adViewContainer.impressionListenerProxy = impressionListenerProxy;

            int key = AdViewBridgeAndroid.lastKey;
            AdViewBridgeAndroid.adViews.Add(key, adViewContainer);
            AdViewBridgeAndroid.lastKey++;
            return key;
        }