From 742609d7abaa7604892071fad30b700299f18174 Mon Sep 17 00:00:00 2001 From: Eric Leichtenschlag Date: Fri, 28 Mar 2014 17:03:01 -0700 Subject: [PATCH] Adding a unified Google Mobile Ads plugin, v2.0 --- unity/README.md | 216 +++++++++++++ .../AdMobUnityPlugin.unitypackage | Bin 11926 -> 0 bytes .../Assets/Plugins/AdMobPlugin/AdMobPlugin.cs | 111 ------- .../Plugins/AdMobPlugin/AdMobPlugin.prefab | Bin 5640 -> 0 bytes .../AdMobPlugin/AdMobPluginDemoScript.cs | 63 ---- unity/android-legacy/README.md | 133 -------- .../plugin-library/AndroidManifest.xml | 17 - .../plugin-library/project.properties | 15 - .../src/com/google/unity/AdMobPlugin.java | 292 ----------------- .../GoogleMobileAdsDemoScript.cs | 64 ---- .../GoogleMobileAds/GoogleMobileAdsPlugin.cs | 114 ------- .../GoogleMobileAdsPlugin.prefab | Bin 5736 -> 0 bytes .../GoogleMobileAdsPlugin.unitypackage | Bin 13661 -> 0 bytes unity/android/README.md | 146 --------- .../google/unity/GoogleMobileAdsPlugin.java | 298 ------------------ unity/iOS/AdMobUnityPlugin.unitypackage | Bin 8794 -> 0 bytes unity/iOS/Plugins/AdMobPlugin/AdMobPlugin.cs | 130 -------- .../Plugins/AdMobPlugin/AdMobPlugin.prefab | Bin 5536 -> 0 bytes .../AdMobPlugin/AdMobPluginDemoScript.cs | 71 ----- .../iOS/Plugins/AdMobPlugin/AdMobPluginiOS.cs | 48 --- unity/iOS/Plugins/iOS/AdMobPlugin.h | 33 -- unity/iOS/Plugins/iOS/AdMobPlugin.mm | 257 --------------- unity/iOS/README.md | 130 -------- unity/samples/HelloWorld/.gitignore | 35 ++ .../Assets/GoogleMobileAdsDemoScript.cs | 112 +++++++ .../samples/HelloWorld/Assets/MainScene.unity | Bin 0 -> 12856 bytes .../Assets/GoogleMobileAds/Api/AdPosition.cs | 9 + .../Assets/GoogleMobileAds/Api/AdRequest.cs | 186 +++++++++++ .../Assets/GoogleMobileAds/Api/AdSize.cs | 49 +++ .../Assets/GoogleMobileAds/Api/BannerView.cs | 86 +++++ .../Assets/GoogleMobileAds/Api/Gender.cs | 10 + .../GoogleMobileAds/Common/DummyClient.cs | 38 +++ .../GoogleMobileAds/Common/IAdListener.cs | 15 + .../Common/IGoogleMobileAdsBannerClient.cs | 20 ++ .../Platforms/Android/AdListener.cs | 42 +++ .../Platforms/Android/AndroidBannerClient.cs | 145 +++++++++ .../Platforms/GoogleMobileAdsClientFactory.cs | 24 ++ .../iOS/MonoPInvokeCallbackAttribute.cs | 8 + .../Platforms/iOS/iOSBannerClient.cs | 228 ++++++++++++++ .../Plugins/Android/AndroidManifest.xml | 0 unity/source/Assets/Plugins/iOS/GADUBanner.h | 67 ++++ unity/source/Assets/Plugins/iOS/GADUBanner.m | 161 ++++++++++ .../source/Assets/Plugins/iOS/GADUInterface.m | 135 ++++++++ .../Assets/Plugins/iOS/GADUObjectCache.h | 21 ++ .../Assets/Plugins/iOS/GADUObjectCache.m | 37 +++ unity/source/Assets/Plugins/iOS/GADURequest.h | 61 ++++ unity/source/Assets/Plugins/iOS/GADURequest.m | 73 +++++ unity/source/Assets/Plugins/iOS/GADUTypes.h | 32 ++ .../plugin-library/AndroidManifest.xml | 0 .../plugin-library/project.properties | 0 .../src/com/google/unity/ads/Banner.java | 175 ++++++++++ .../src/com/google/unity/ads/PluginUtils.java | 37 +++ .../com/google/unity/ads/UnityAdListener.java | 15 + 53 files changed, 2037 insertions(+), 1922 deletions(-) create mode 100644 unity/README.md delete mode 100644 unity/android-legacy/AdMobUnityPlugin.unitypackage delete mode 100644 unity/android-legacy/Assets/Plugins/AdMobPlugin/AdMobPlugin.cs delete mode 100644 unity/android-legacy/Assets/Plugins/AdMobPlugin/AdMobPlugin.prefab delete mode 100644 unity/android-legacy/Assets/Plugins/AdMobPlugin/AdMobPluginDemoScript.cs delete mode 100644 unity/android-legacy/README.md delete mode 100644 unity/android-legacy/plugin-library/AndroidManifest.xml delete mode 100644 unity/android-legacy/plugin-library/project.properties delete mode 100644 unity/android-legacy/plugin-library/src/com/google/unity/AdMobPlugin.java delete mode 100755 unity/android/Assets/Plugins/GoogleMobileAds/GoogleMobileAdsDemoScript.cs delete mode 100755 unity/android/Assets/Plugins/GoogleMobileAds/GoogleMobileAdsPlugin.cs delete mode 100755 unity/android/Assets/Plugins/GoogleMobileAds/GoogleMobileAdsPlugin.prefab delete mode 100755 unity/android/GoogleMobileAdsPlugin.unitypackage delete mode 100755 unity/android/README.md delete mode 100755 unity/android/plugin-library/src/com/google/unity/GoogleMobileAdsPlugin.java delete mode 100644 unity/iOS/AdMobUnityPlugin.unitypackage delete mode 100644 unity/iOS/Plugins/AdMobPlugin/AdMobPlugin.cs delete mode 100644 unity/iOS/Plugins/AdMobPlugin/AdMobPlugin.prefab delete mode 100644 unity/iOS/Plugins/AdMobPlugin/AdMobPluginDemoScript.cs delete mode 100644 unity/iOS/Plugins/AdMobPlugin/AdMobPluginiOS.cs delete mode 100644 unity/iOS/Plugins/iOS/AdMobPlugin.h delete mode 100644 unity/iOS/Plugins/iOS/AdMobPlugin.mm delete mode 100644 unity/iOS/README.md create mode 100644 unity/samples/HelloWorld/.gitignore create mode 100644 unity/samples/HelloWorld/Assets/GoogleMobileAdsDemoScript.cs create mode 100644 unity/samples/HelloWorld/Assets/MainScene.unity create mode 100644 unity/source/Assets/GoogleMobileAds/Api/AdPosition.cs create mode 100644 unity/source/Assets/GoogleMobileAds/Api/AdRequest.cs create mode 100644 unity/source/Assets/GoogleMobileAds/Api/AdSize.cs create mode 100644 unity/source/Assets/GoogleMobileAds/Api/BannerView.cs create mode 100644 unity/source/Assets/GoogleMobileAds/Api/Gender.cs create mode 100644 unity/source/Assets/GoogleMobileAds/Common/DummyClient.cs create mode 100644 unity/source/Assets/GoogleMobileAds/Common/IAdListener.cs create mode 100644 unity/source/Assets/GoogleMobileAds/Common/IGoogleMobileAdsBannerClient.cs create mode 100644 unity/source/Assets/GoogleMobileAds/Platforms/Android/AdListener.cs create mode 100644 unity/source/Assets/GoogleMobileAds/Platforms/Android/AndroidBannerClient.cs create mode 100644 unity/source/Assets/GoogleMobileAds/Platforms/GoogleMobileAdsClientFactory.cs create mode 100644 unity/source/Assets/GoogleMobileAds/Platforms/iOS/MonoPInvokeCallbackAttribute.cs create mode 100644 unity/source/Assets/GoogleMobileAds/Platforms/iOS/iOSBannerClient.cs rename unity/{android => source}/Assets/Plugins/Android/AndroidManifest.xml (100%) mode change 100755 => 100644 create mode 100644 unity/source/Assets/Plugins/iOS/GADUBanner.h create mode 100644 unity/source/Assets/Plugins/iOS/GADUBanner.m create mode 100644 unity/source/Assets/Plugins/iOS/GADUInterface.m create mode 100644 unity/source/Assets/Plugins/iOS/GADUObjectCache.h create mode 100644 unity/source/Assets/Plugins/iOS/GADUObjectCache.m create mode 100644 unity/source/Assets/Plugins/iOS/GADURequest.h create mode 100644 unity/source/Assets/Plugins/iOS/GADURequest.m create mode 100644 unity/source/Assets/Plugins/iOS/GADUTypes.h rename unity/{android => source}/plugin-library/AndroidManifest.xml (100%) mode change 100755 => 100644 rename unity/{android => source}/plugin-library/project.properties (100%) mode change 100755 => 100644 create mode 100644 unity/source/plugin-library/src/com/google/unity/ads/Banner.java create mode 100644 unity/source/plugin-library/src/com/google/unity/ads/PluginUtils.java create mode 100644 unity/source/plugin-library/src/com/google/unity/ads/UnityAdListener.java diff --git a/unity/README.md b/unity/README.md new file mode 100644 index 000000000..c4ece75f1 --- /dev/null +++ b/unity/README.md @@ -0,0 +1,216 @@ +Google Mobile Ads Unity Plugin +============================== + +The Google Mobile Ads Unity Plugin helps provides a way to +serve Google Mobile ads in a Unity project deployed as native Android or iOS +applications. Plugin features include: + +* A single package with cross platform (Android/iOS) support +* Mock ad calls when running inside Unity editor +* Support for Banner Ads +* Custom banner sizes +* Banner ad events listeners +* AdRequest targeting methods +* A sample project to demonstrate plugin integration + +Interstitial support coming soon. + +The plugin contains a .unitypackage file for those that want to easily import +the plugin, as well as the source code for those that want to iterate on it. + +Requirements +------------ +* Unity 4.3 (untested on previous versions) +* An ad unit ID +* To deploy on Android: + * Android SDK 3.2 or higher + * [Google Play services](http://developer.android.com/google/play-services/index.html) + 4.0 or higher +* To deploy on iOS: + * XCode 5.1 or above + * [Google Mobile Ads SDK](https://developers.google.com/mobile-ads-sdk/download#downloadios) + + +Integrate the Plugin into your Game +----------------------------------- + +1. Open your project in the Unity editor. +2. Navigate to **Assets -> Import Package -> Custom Package**. +3. Select the GoogleMobileAdsPlugin.unitypackage file. +4. Import all of the files for the plugins by selecting **Import**. Make sure + to check for any conflicts with files. + + +Android Setup +------------- +If you already had an AndroidManifest.xml in Plugins/Android/, keep your current +version and [add the necessary activities and permissions](https://developers.google.com/mobile-ads-sdk/docs#play) +required by the Google Mobile Ads SDK. + +Additional dependencies: + +1. Add the google-play-services_lib folder, + located at /extras/google/google_play_services/libproject, + into the Plugins/Android folder of your project. + +iOS Setup +--------- + +No pre-build setup required. + +Run the project +--------------- + +If you're running the **HelloWorld** sample project, you should be able to run +the project now. + +To build and run on Android, click **File -> Build Settings**, select the +Android platform, then **Switch Platform**, then **Build and Run**. + +To build and run on iOS, click **File -> Build Settings**, select the iOS +platform, then **Switch Platform**, then **Build**. This will export an +XCode project. You'll need to do the following before you can run it: + +1. Add the Google Mobile Ads iOS SDK library. +2. Add the following frameworks if they aren't already part of the project: + * AdSupport + * AudioToolbox + * AVFoundation + * CoreGraphics + * CoreTelephony + * MessageUI + * StoreKit + * SystemConfiguration +3. Add the **-ObjC** linker flag to your **Other Linker Flags** in + **Build Settings**. + +See the [developer docs](https://developers.google.com/mobile-ads-sdk/docs/#ios) +for more information on integrating the Google Mobile Ads iOS library. + +Google Mobile Ads Unity API +=========================== + +The remainder of this guide assumes you are now attempting to write your own +code to integrate Google Mobile Ads into your game. + +Basic Banner Flow +----------------- +Here is the minimal code needed to create a banner. + + using GoogleMobileAds.Api; + ... + // Create a 320x50 banner at the top of the screen. + BannerView bannerView = new BannerView( + "YOUR_AD_UNIT_ID", AdSize.Banner, AdPosition.Top); + // Create an empty ad request. + AdRequest request = new AdRequest.Builder().Build(); + // Load the banner with the request. + bannerView.LoadAd(request); + +The _AdPosition_ enum specifies where to place the banner. + +Custom Ad Sizes +--------------- +In addition to constants on _AdSize_, you can also create a custom size: + + using GoogleMobileAds.Api; + ... + + // Create a 250x250 banner. + AdSize adSize = new AdSize(250, 250); + BannerView bannerView = new BannerView( + "YOUR_AD_UNIT_ID", adSize, AdPosition.Bottom); + +Ad Request Targeting +-------------------- +If you want to provide custom targeting to ad requests, add the targeting +options when building the request. This sample ad request shows what options +you have for targeting. You only need to use the options that make sense for +your application. + + using GoogleMobileAds.Api; + ... + + AdRequest request = new AdRequest.Builder() + .AddTestDevice(AdRequest.TestDeviceSimulator) + .AddTestDevice("0123456789ABCDEF0123456789ABCDEF") + .AddKeyword("unity") + .SetGender(Gender.Male) + .SetBirthday(new DateTime(1985, 1, 1)) + .TagForChildDirectedTreatment(true) + .AddExtra("color_bg", "9B30FF") // Sets text ad background color. + .Build(); + +Test Ads +-------- +To request test ads, add your encrypted device ID when building the ad request. +This ID can only be found in the logs on both Android and iOS when running your +apps and making a request. Once you get your device ID, pass it to +_AddTestDevice_. + +Let's pretend my hashed device ID is _0123456789ABCDEF0123456789ABCDEF_, and I +also want to get test ads on the simulator. Here is how to set up the request: + + using GoogleMobileAds.Api; + ... + + AdRequest request = new AdRequest.Builder() + .AddTestDevice(AdRequest.TestDeviceSimulator) // Simulator. + .AddTestDevice("0123456789ABCDEF0123456789ABCDEF") // Test Device 1. + .Build(); + +Ad Events +--------- +_BannerView_ contains ad events that you can register for: + + using GoogleMobileAds.Api; + ... + + BannerView bannerView = new BannerView( + "YOUR_AD_UNIT_ID", AdSize.Banner, AdPosition.Top); + // Called when an ad request has successfully loaded. + bannerView.AdLoaded += HandleAdLoaded; + // Called when an ad request failed to load. + bannerView.AdFailedToLoad += HandleAdFailedToLoad; + // Called when an ad is clicked. + bannerView.AdOpened += HandleAdOpened; + // Called when the user is about to return to the app after an ad click. + bannerView.AdClosing += HandleAdClosing; + // Called when the user returned from the app after an ad click. + bannerView.AdClosed += HandleAdClosed; + // Called when the ad click caused the user to leave the application. + bannerView.AdLeftApplication += HandleAdLeftApplication; + ... + + public void HandleAdLoaded() + { + print("HandleAdLoaded event received."); + // Handle the ad loaded event. + } + +You only need to register for the events you care about. + +Banner Lifecycle +---------------- +By default, banners are visible. To temporarily hide a banner, call: + + bannerView.Hide(); + +To show it again, call: + + bannerView.Show(); + +When you are finished with a banner, make sure to destroy it before dropping +your reference to it: + + bannerView.Destroy(); + +This lets the plugin know you no longer need the object, and can do any +necessary cleanup on your behalf. + +Additional Resources +==================== +* [Developer documentation](https://developers.google.com/mobile-ads-sdk/docs) +* [Developer forum](https://groups.google.com/group/google-admob-ads-sdk) +* [Google Ads +Page](https://plus.google.com/+GoogleAdsDevelopers) + diff --git a/unity/android-legacy/AdMobUnityPlugin.unitypackage b/unity/android-legacy/AdMobUnityPlugin.unitypackage deleted file mode 100644 index 81b6e5256e7e585183babaaa3955572f9c4cd951..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11926 zcmZWvQ*16=u>ES=wr#sTwRLLSHcoqL+qQLT^Q&#!wtN4Z`*?TO&Q4~Md6|{0J()!m z1r10{TT}*sT?s(xqRBoeM+Oq>(SV|Wh-iC56U$&#sL)gIQ?v`Sle566pbv$H2O$k3 z(z;8a57(|j3|m0(NeqWVbiO`T{B-_J{0ld7qT2iOV)iMK*txdWzV_eQTEnBVSX6|9 zhZLhkoudYgl_Ex)rH03p9Wb7~ec}{0ar%vl5;dIU$juHJMTWvc&3<>%6e>z_4*@_j zhA{mjr`-iGeXzQt2j`C`SfR*SKC%4y_yNz(W`U;-4K3QcbHxQCSAl`21vv;Ri$61k zPk}Wo7pf)R+4(jlg{-suF#u7R_JkKMG;ZLAKMfj0rbe%Z1B2S7aYY3fvcP9fI9LTl z7ykU<2CnDr1wrYK#^WM`lwYV~qmvSnvta*b%@B72!Ram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iXu1yT2-4(*j|BeHZ zQY(iu7RJI46)rH;!{!Dk79;@xQAV@6{{BBeKAA};w!WcF! zM&D=9XD@c5>kn|>G4e&|6IIy%Cm1pq78IVAefwY(kP{B3r%O!^8Ukqy?FlJN5+A^| a0ju=CI{lvsVi#)n2helVkp;K~0R9I%CTME_ diff --git a/unity/android-legacy/Assets/Plugins/AdMobPlugin/AdMobPlugin.cs b/unity/android-legacy/Assets/Plugins/AdMobPlugin/AdMobPlugin.cs deleted file mode 100644 index d86b8ded5..000000000 --- a/unity/android-legacy/Assets/Plugins/AdMobPlugin/AdMobPlugin.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using UnityEngine; - -// The AdMob Plugin used to call into the AdMob Android Unity library. -public class AdMobPlugin : MonoBehaviour { - - // Defines string values for supported ad sizes. - public class AdSize - { - private string adSize; - private AdSize(string value) - { - this.adSize = value; - } - - public override string ToString() - { - return adSize; - } - - public static AdSize Banner = new AdSize("BANNER"); - public static AdSize MediumRectangle = new AdSize("IAB_MRECT"); - public static AdSize IABBanner = new AdSize("IAB_BANNER"); - public static AdSize Leaderboard = new AdSize("IAB_LEADERBOARD"); - public static AdSize SmartBanner = new AdSize("SMART_BANNER"); - } - - // These are the ad callback events that can be hooked into. - public static event Action ReceivedAd = delegate {}; - public static event Action FailedToReceiveAd = delegate {}; - public static event Action ShowingOverlay = delegate {}; - public static event Action DismissedOverlay = delegate {}; - public static event Action LeavingApplication = delegate {}; - - void Awake() - { - gameObject.name = this.GetType().ToString(); - SetCallbackHandlerName(gameObject.name); - DontDestroyOnLoad(this); - } - - // Create a banner view and add it into the view hierarchy. - public static void CreateBannerView(string publisherId, AdSize adSize, bool positionAtTop) - { - AndroidJavaClass playerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); - AndroidJavaObject activity = playerClass.GetStatic("currentActivity"); - AndroidJavaClass pluginClass = new AndroidJavaClass("com.google.unity.AdMobPlugin"); - pluginClass.CallStatic("createBannerView", - new object[4] {activity, publisherId, adSize.ToString(), positionAtTop}); - } - - // Request a new ad for the banner view without any extras. - public static void RequestBannerAd(bool isTesting) - { - AndroidJavaClass pluginClass = new AndroidJavaClass("com.google.unity.AdMobPlugin"); - pluginClass.CallStatic("requestBannerAd", new object[1] {isTesting}); - } - - // Request a new ad for the banner view with extras. - public static void RequestBannerAd(bool isTesting, string extras) - { - AndroidJavaClass pluginClass = new AndroidJavaClass("com.google.unity.AdMobPlugin"); - pluginClass.CallStatic("requestBannerAd", new object[2] {isTesting, extras}); - } - - // Set the name of the callback handler so the right component gets ad callbacks. - public static void SetCallbackHandlerName(string callbackHandlerName) - { - AndroidJavaClass pluginClass = new AndroidJavaClass("com.google.unity.AdMobPlugin"); - pluginClass.CallStatic("setCallbackHandlerName", new object[1] {callbackHandlerName}); - } - - // Hide the banner view from the screen. - public static void HideBannerView() - { - AndroidJavaClass pluginClass = new AndroidJavaClass("com.google.unity.AdMobPlugin"); - pluginClass.CallStatic("hideBannerView"); - } - - // Show the banner view on the screen. - public static void ShowBannerView() { - AndroidJavaClass pluginClass = new AndroidJavaClass("com.google.unity.AdMobPlugin"); - pluginClass.CallStatic("showBannerView"); - } - - public void OnReceiveAd(string unusedMessage) - { - ReceivedAd(); - } - - public void OnFailedToReceiveAd(string message) - { - FailedToReceiveAd(message); - } - - public void OnPresentScreen(string unusedMessage) - { - ShowingOverlay(); - } - - public void OnDismissScreen(string unusedMessage) - { - DismissedOverlay(); - } - - public void OnLeaveApplication(string unusedMessage) - { - LeavingApplication(); - } -} - diff --git a/unity/android-legacy/Assets/Plugins/AdMobPlugin/AdMobPlugin.prefab b/unity/android-legacy/Assets/Plugins/AdMobPlugin/AdMobPlugin.prefab deleted file mode 100644 index a850c87b09f1a4ab2a0e671e7d9df4c061ccbf26..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5640 zcmeHL&u<(x6!rosZTStMK!G;=k~l@ArJ@H^HlZm*BxOlbI7ZH{cQdd%US=js($k)h z;KUgrHJ6@H#hp|C6S#2T1X2&&8s7Ijo_U^~4MG(XhdP=ad;Hn{{QTZ$J4(&oQ0mli zrPK+fW^dD5y*ZbODt77^dmu5*6_h{U!WMp>eCnai}8#YPwzFOp8#KKdAK@a>i17>M--LUgL zP4!3~hkScSC#s_}&0n9vCrT25yjbChFk@F8D+Tix=Dr_hWQ}_Xvk|G3O~?!0w}YXL zNp08_se8Fc^_cojYAgrH79i^j4oyzOEyJkJ9=g#o`ui$)N0m&NoqJaO8 zgT^Pj8V4*o{dLJxR&87N*DV~3;sClLWl|lVW4-D2taTOX zl)|w6S6nYo5WfCX-aF10gj+U^m@woz5JMUeCsIi`kimeEBP#Kw| z$cjdRjg&&5t84=Ot6>A}L*hsc>Kz-Yd!9|XweCdy4jtrqXO;Sgy#zg0H#b|3^qimcfQj)6_q0Aan-@8W4dS1)(8Tj+D#{L zmas@}_V}%r@j0#ualg}|x@*g%bYjA4?1bXqODEsO)@�Mr{|8gRP*5EtH3#QJ6Xn z1s9vNNg?m4p%s%`?X-}y3~^i0M^k|#;@E*JzZEQQjus56p0 zQhHo|I2z`paZhFoN%6$&fv;K!0*deaGy{Hxg`|l3F~if5R85b_S&ejm*WJ^kbWWr5 z-<=?X1+x5aj&;*Dq;GA*DsCr?tH%}Yylw_|WIDw?z`3*(Sv0{@ zT`(!Ks24Pg1(PD{hYse?H`=PgR(cEEQ!1?Qv2M~*VLgsV7XO&xe-7n}Hz~5gi~2zI83mbgxI|sU&X! z`5EJ(>@8K+jo&Nt$f4|?vIc$1B>VGqc>lWp6T|#B-=+=^i%!G)cK!|C4eIo7T6~=0 diff --git a/unity/android-legacy/Assets/Plugins/AdMobPlugin/AdMobPluginDemoScript.cs b/unity/android-legacy/Assets/Plugins/AdMobPlugin/AdMobPluginDemoScript.cs deleted file mode 100644 index 0f4d0bc16..000000000 --- a/unity/android-legacy/Assets/Plugins/AdMobPlugin/AdMobPluginDemoScript.cs +++ /dev/null @@ -1,63 +0,0 @@ -using UnityEngine; - -// Example script showing how you can easily call into the AdMobPlugin. -public class AdMobPluginDemoScript : MonoBehaviour { - - void Start() - { - print("Started"); - AdMobPlugin.CreateBannerView("INSERT_YOUR_AD_UNIT_ID_HERE", - AdMobPlugin.AdSize.Banner, - true); - print("Created Banner View"); - AdMobPlugin.RequestBannerAd(true); - print("Requested Banner Ad"); - } - - void OnEnable() - { - print("Registering for AdMob Events"); - AdMobPlugin.ReceivedAd += HandleReceivedAd; - AdMobPlugin.FailedToReceiveAd += HandleFailedToReceiveAd; - AdMobPlugin.ShowingOverlay += HandleShowingOverlay; - AdMobPlugin.DismissedOverlay += HandleDismissedOverlay; - AdMobPlugin.LeavingApplication += HandleLeavingApplication; - } - - void OnDisable() - { - print("Unregistering for AdMob Events"); - AdMobPlugin.ReceivedAd -= HandleReceivedAd; - AdMobPlugin.FailedToReceiveAd -= HandleFailedToReceiveAd; - AdMobPlugin.ShowingOverlay -= HandleShowingOverlay; - AdMobPlugin.DismissedOverlay -= HandleDismissedOverlay; - AdMobPlugin.LeavingApplication -= HandleLeavingApplication; - } - - public void HandleReceivedAd() - { - print("HandleReceivedAd event received"); - } - - public void HandleFailedToReceiveAd(string message) - { - print("HandleFailedToReceiveAd event received with message:"); - print(message); - } - - public void HandleShowingOverlay() - { - print("HandleShowingOverlay event received"); - } - - public void HandleDismissedOverlay() - { - print("HandleDismissedOverlay event received"); - } - - public void HandleLeavingApplication() - { - print("HandleLeavingApplication event received"); - } -} - diff --git a/unity/android-legacy/README.md b/unity/android-legacy/README.md deleted file mode 100644 index b79013607..000000000 --- a/unity/android-legacy/README.md +++ /dev/null @@ -1,133 +0,0 @@ -About -===== - -Copyright 2013 Google Inc. All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -Features --------- -This is the AdMob Unity Plugin for Android. It provides a way to request -AdMob ads from a Unity project. This plugin was written and tested with -the Google AdMob SDK version 6.4.1 for Android, and Unity 4.1.5. - -The AdMob Unity plugin contains a .unitypackage file for those that want to -easily import the plugin, as well as the source code. - -Requirements: --------------- -* Unity Pro 4.1.5 (untested on previous versions) -* Google AdMob SDK for Android -* AdMob publisher ID - -Directions for importing the plugin: --------------------------------------- -1. Open your project in the Unity editor. -2. On the top toolbar, select "Assets" -> "Import Package" -> "Custom Package". -3. Select the AdMobUnityPlugin.unitypackage file. -4. Import all of the files for the plugins by selecting "Import". Make sure - to check for any conflicts with files. -5. Drag the AdMobPlugin prefab from the Plugins/AdMobPlugin/ folder into - your Unity scene. - -Plugin integrations steps - Android: - -1. If you don't already have an AndroidManifest.xml in Plugins/Android/, copy - the AndroidManifest.xml from Temp/StagingArea into Plugins/Android/. -2. Update Plugins/Android/AndroidManifest.xml and add the necessary AdMob - activities and permissions as explained in - https://developers.google.com/mobile-ads-sdk/docs#android -3. Add the Google AdMob SDK jar into Plugins/Android. - -The plugin also comes with an example plugin usage script, which is already -attached to the AdMobPlugin component for convenience. Simply edit -Plugins/AdMobPlugin/AdMobPluginDemoScript.cs and include your ad unit ID -and run your project to see AdMob working. - - -AdMob Unity Plugin API ------------------------ -The plugin provides the following AdMob methods: - -1. CreateBannerView - - Takes in a publisherId string as well as a constant for the ad size. The - last boolean parameter denotes whether the ad should be shown at the top - or bottom of the screen. - - An example call placing the ad at the top of the screen is provided below: - - AdMobPlugin.CreateBannerView ("INSERT_YOUR_AD_UNIT_ID_HERE", - AdMobPlugin.AdSize.Banner, - true); -2. RequestBannerAd - - Takes in a testing flag as well as an optional string representing a list - of extras. If you don't have any extras, you can request a live ad with: - - AdMobPlugin.RequestBannerAd(false); - - An example call requesting a test ad with some extras is shown below: - - string extras = "{\"color_bg\":\"AAAAFF\", \"color_text\":\"FFFFFF\"}"; - AdMobPlugin.RequestBannerAd(true, extras); - - NOTE: Make sure to use correctly formed JSON when passing an extras string. - -3. HideBannerView - - Called after a BannerView has been created. This method can hide the ad from - showing on screen. An example call of this is shown below: - - AdMobPlugin.HideBannerView(); - -4. ShowBannerView - - Called after a BannerView has been created, this method can show any ad that - has been hidden. An example call of this is shown below: - - AdMobPlugin.ShowBannerView(); - -This plugin also allows you the option to listen for ad events. The following -events are supported: - - public static event Action ReceivedAd; - public static event Action FailedToReceiveAd; - public static event Action ShowingOverlay; - public static event Action DismissedOverlay; - public static event Action LeavingApplication; - -Registering for an event can be done using the += operater as is shown below: - - // Assume HandleReceivedAd is your function. - AdMobPlugin.ReceivedAd += HandleDidReceiveAd; - -Remember to un-register for events when you're cleaning up your GameObjects. -You can unregister using the -= operator as is shown below: - - // Assume HandleReceivedAd is your function. - AdMobPlugin.ReceivedAd -= HandleDidReceiveAd; - -Updating the plugin ---------------------- - -The plugin's .unitypackage only includes the compiled Android library project -with AdMob implementation. If you want to make changes to the library or see -the source code, you can find the project in the examples-android repository. - -Additional Resources ---------------------- -* https://developers.google.com/mobile-ads-sdk/docs -* https://groups.google.com/group/google-admob-ads-sdk -* https://plus.google.com/+GoogleAdsDevelopers - diff --git a/unity/android-legacy/plugin-library/AndroidManifest.xml b/unity/android-legacy/plugin-library/AndroidManifest.xml deleted file mode 100644 index da5388479..000000000 --- a/unity/android-legacy/plugin-library/AndroidManifest.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - diff --git a/unity/android-legacy/plugin-library/project.properties b/unity/android-legacy/plugin-library/project.properties deleted file mode 100644 index 4a46b9d1c..000000000 --- a/unity/android-legacy/plugin-library/project.properties +++ /dev/null @@ -1,15 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -android.library=true -# Project target. -target=android-17 diff --git a/unity/android-legacy/plugin-library/src/com/google/unity/AdMobPlugin.java b/unity/android-legacy/plugin-library/src/com/google/unity/AdMobPlugin.java deleted file mode 100644 index d5568e8b8..000000000 --- a/unity/android-legacy/plugin-library/src/com/google/unity/AdMobPlugin.java +++ /dev/null @@ -1,292 +0,0 @@ -// Copyright 2013 Google Inc. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.unity; - -import com.google.ads.Ad; -import com.google.ads.AdListener; -import com.google.ads.AdRequest; -import com.google.ads.AdRequest.ErrorCode; -import com.google.ads.AdSize; -import com.google.ads.AdView; -import com.google.ads.mediation.admob.AdMobAdapterExtras; - -import android.app.Activity; -import android.util.Log; -import android.view.Gravity; -import android.view.View; -import android.widget.FrameLayout; -import android.widget.LinearLayout; - -import com.unity3d.player.UnityPlayer; - -import org.json.JSONException; -import org.json.JSONObject; - -import java.util.Iterator; - -/** - * This class represents the native implementation for the AdMob Unity plugin. This class is used - * to request AdMob ads natively via the Google AdMob SDK. The Google AdMob SDK is a dependency - * for this plugin. - * - * @author api.eleichtenschl@gmail.com (Eric Leichtenschlag) - */ -public class AdMobPlugin implements AdListener { - /** The plugin version. */ - public static final String VERSION = "1.0"; - - /** Tag used for logging statements. */ - private static final String LOGTAG = "AdMobPlugin"; - - /** A singleton for the plugin. */ - private static AdMobPlugin instance; - - /** The {@link AdView} to display to the user. */ - private AdView adView; - - /** The {@code Activity} that the banner will be displayed in. */ - private Activity activity; - - /** The Unity {@code GameObject} that should receive messages about ad events. */ - private String callbackHandlerName; - - /** Creates an instance of {@code AdMobPlugin}. */ - private AdMobPlugin() { - // Prevent instantiation. - } - - /** - * Gets a singleton instance of {@code AdMobPlugin}. - * - * @return the {@code AdMobPlugin} singleton. - */ - public static AdMobPlugin instance() { - if (instance == null) { - instance = new AdMobPlugin(); - } - return instance; - } - - /** - * Creates an {@link AdView} to old ads. - * - * @param activity The activity to place the {@code AdView}. - * @param publisherId Your publisher ID from the AdMob or DFP console - * @param adSizeString A string ad size constant representing the desired ad size. - * @param positionAtTop True to position the ad at the top of the screen. False to position - * the ad at the bottom of the screen. - */ - public static void createBannerView(final Activity activity, final String publisherId, - final String adSizeString, final boolean positionAtTop) { - Log.d(LOGTAG, "called createBannerView in Java code"); - final AdMobPlugin plugin = AdMobPlugin.instance(); - plugin.activity = activity; - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - AdSize adSize = AdMobPlugin.adSizeFromSize(adSizeString); - if (adSize == null) { - Log.e(AdMobPlugin.LOGTAG, "AdSize is null. Did you use an AdSize constant?"); - return; - } - plugin.adView = new AdView(activity, adSize, publisherId); - plugin.adView.setAdListener(plugin); - LinearLayout layout = new LinearLayout(activity); - FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams( - FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); - layoutParams.gravity = positionAtTop ? Gravity.TOP : Gravity.BOTTOM; - activity.addContentView(layout, layoutParams); - LinearLayout.LayoutParams adParams = new LinearLayout.LayoutParams( - LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT); - layout.addView(plugin.adView, adParams); - } - }); - } - - /** - * Sets the name of the {@code GameComponent} that should listen for ad events. - * - * @param callbackHandlerName the {@code GameComponent} that should listen for ad events. - */ - public static void setCallbackHandlerName(String callbackHandlerName) { - final AdMobPlugin plugin = AdMobPlugin.instance(); - plugin.callbackHandlerName = callbackHandlerName; - } - - /** - * Requests a banner ad without any extras. This method should be called only after a banner - * view has been created. - * - * @param isTesting True to enable test ads. False to get network ads. - */ - public static void requestBannerAd(final boolean isTesting) { - requestBannerAd(isTesting, null); - } - /** - * Requests a banner ad. This method should be called only after a banner view has been created. - * - * @param isTesting True to enable test ads. False to get network ads. - * @param extrasJson A json object with key/value pairs representing what extras to pass in the - * request. - */ - public static void requestBannerAd(final boolean isTesting, final String extrasJson) { - final AdMobPlugin plugin = AdMobPlugin.instance(); - if (plugin.activity == null) { - Log.e(AdMobPlugin.LOGTAG, "Activity is null. Call createBannerView before requestBannerAd."); - return; - } - - plugin.activity.runOnUiThread(new Runnable() { - @Override - public void run() { - if (plugin.adView == null) { - Log.e(AdMobPlugin.LOGTAG, "AdView is null. Aborting requestBannerAd."); - } else { - AdRequest adRequest = new AdRequest(); - if (isTesting) { - // This will request test ads on the emulator only. You can get your hashed device ID - // from LogCat when making a live request. Pass this hashed device ID to addTestDevice - // to get test ads on your device. - adRequest.addTestDevice(AdRequest.TEST_EMULATOR); - } - AdMobAdapterExtras extras = new AdMobAdapterExtras(); - if (extrasJson != null) { - try { - JSONObject extrasObject = new JSONObject(extrasJson); - Iterator extrasIterator = extrasObject.keys(); - while (extrasIterator.hasNext()) { - String key = extrasIterator.next(); - extras.addExtra(key, extrasObject.get(key)); - } - } catch (JSONException exception) { - Log.e(AdMobPlugin.LOGTAG, "Extras are malformed. Ignoring ad request."); - return; - } - } - extras.addExtra("unity", 1); - adRequest.setNetworkExtras(extras); - plugin.adView.loadAd(adRequest); - } - } - }); - } - - /** - * Sets the banner view to be visible. - */ - public static void showBannerView() { - final AdMobPlugin plugin = AdMobPlugin.instance(); - if (plugin.activity == null) { - Log.e(AdMobPlugin.LOGTAG, "Activity is null. Call createBannerView before showBannerView."); - return; - } - - plugin.activity.runOnUiThread(new Runnable() { - @Override - public void run() { - if (plugin.adView == null) { - Log.e(AdMobPlugin.LOGTAG, "AdView is null. Aborting showBannerView."); - return; - } else { - plugin.adView.setVisibility(View.VISIBLE); - } - } - }); - } - - /** - * Hides the banner view from the user. - */ - public static void hideBannerView() { - Log.d("AdMobPlugin", "called hideBannerView in Java code"); - final AdMobPlugin plugin = AdMobPlugin.instance(); - if (plugin.activity == null) { - Log.e(AdMobPlugin.LOGTAG, "Activity is null. Call createBannerView before hideBannerView."); - return; - } - - plugin.activity.runOnUiThread(new Runnable() { - @Override - public void run() { - if (plugin.adView == null) { - Log.e(AdMobPlugin.LOGTAG, "AdView is null. Aborting hideBannerView."); - return; - } else { - plugin.adView.setVisibility(View.GONE); - } - } - }); - } - - /** - * Gets an AdSize object from the string size passed in from JavaScript. Returns null if an - * improper string is provided. - * - * @param size The string size representing an ad format constant. - * @return An AdSize object used to create a banner. - */ - private static AdSize adSizeFromSize(String size) { - if ("BANNER".equals(size)) { - return AdSize.BANNER; - } else if ("IAB_MRECT".equals(size)) { - return AdSize.IAB_MRECT; - } else if ("IAB_BANNER".equals(size)) { - return AdSize.IAB_BANNER; - } else if ("IAB_LEADERBOARD".equals(size)) { - return AdSize.IAB_LEADERBOARD; - } else if ("SMART_BANNER".equals(size)) { - return AdSize.SMART_BANNER; - } else { - Log.w(LOGTAG, String.format("Unexpected ad size string: %s", size)); - return null; - } - } - - /** AdListener implementation. */ - @Override - public void onReceiveAd(Ad ad) { - if (callbackHandlerName != null) { - UnityPlayer.UnitySendMessage(callbackHandlerName, "OnReceiveAd", ""); - } - } - - @Override - public void onFailedToReceiveAd(Ad ad, ErrorCode error) { - if (callbackHandlerName != null) { - UnityPlayer.UnitySendMessage(callbackHandlerName, "OnFailedToReceiveAd", error.toString()); - } - } - - @Override - public void onPresentScreen(Ad ad) { - if (callbackHandlerName != null) { - UnityPlayer.UnitySendMessage(callbackHandlerName, "OnPresentScreen", ""); - } - } - - @Override - public void onDismissScreen(Ad ad) { - if (callbackHandlerName != null) { - UnityPlayer.UnitySendMessage(callbackHandlerName, "OnDismissScreen", ""); - } - } - - @Override - public void onLeaveApplication(Ad ad) { - if (callbackHandlerName != null) { - UnityPlayer.UnitySendMessage(callbackHandlerName, "OnLeaveApplication", ""); - } - } -} diff --git a/unity/android/Assets/Plugins/GoogleMobileAds/GoogleMobileAdsDemoScript.cs b/unity/android/Assets/Plugins/GoogleMobileAds/GoogleMobileAdsDemoScript.cs deleted file mode 100755 index a29d3fd65..000000000 --- a/unity/android/Assets/Plugins/GoogleMobileAds/GoogleMobileAdsDemoScript.cs +++ /dev/null @@ -1,64 +0,0 @@ -using UnityEngine; - -// Example script showing how you can easily call into the GoogleMobileAdsPlugin. -public class GoogleMobileAdsDemoScript : MonoBehaviour { - - void Start() - { - print("Started"); - #error Replace with your own ad unit ID and then remove this error. - GoogleMobileAdsPlugin.CreateBannerView("INSERT_YOUR_AD_UNIT_ID_HERE", - GoogleMobileAdsPlugin.AdSize.SmartBanner, - true); - print("Created Banner View"); - GoogleMobileAdsPlugin.RequestBannerAd(true); - print("Requested Banner Ad"); - } - - void OnEnable() - { - print("Registering for AdMob Events"); - GoogleMobileAdsPlugin.ReceivedAd += HandleReceivedAd; - GoogleMobileAdsPlugin.FailedToReceiveAd += HandleFailedToReceiveAd; - GoogleMobileAdsPlugin.ShowingOverlay += HandleShowingOverlay; - GoogleMobileAdsPlugin.DismissedOverlay += HandleDismissedOverlay; - GoogleMobileAdsPlugin.LeavingApplication += HandleLeavingApplication; - } - - void OnDisable() - { - print("Unregistering for AdMob Events"); - GoogleMobileAdsPlugin.ReceivedAd -= HandleReceivedAd; - GoogleMobileAdsPlugin.FailedToReceiveAd -= HandleFailedToReceiveAd; - GoogleMobileAdsPlugin.ShowingOverlay -= HandleShowingOverlay; - GoogleMobileAdsPlugin.DismissedOverlay -= HandleDismissedOverlay; - GoogleMobileAdsPlugin.LeavingApplication -= HandleLeavingApplication; - } - - public void HandleReceivedAd() - { - print("HandleReceivedAd event received"); - } - - public void HandleFailedToReceiveAd(string message) - { - print("HandleFailedToReceiveAd event received with message:"); - print(message); - } - - public void HandleShowingOverlay() - { - print("HandleShowingOverlay event received"); - } - - public void HandleDismissedOverlay() - { - print("HandleDismissedOverlay event received"); - } - - public void HandleLeavingApplication() - { - print("HandleLeavingApplication event received"); - } -} - diff --git a/unity/android/Assets/Plugins/GoogleMobileAds/GoogleMobileAdsPlugin.cs b/unity/android/Assets/Plugins/GoogleMobileAds/GoogleMobileAdsPlugin.cs deleted file mode 100755 index 4de870247..000000000 --- a/unity/android/Assets/Plugins/GoogleMobileAds/GoogleMobileAdsPlugin.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using UnityEngine; - -// The Google Mobile Ads script used to call into the native Google Mobile Ads Plugin library. -public class GoogleMobileAdsPlugin : MonoBehaviour { - - // The plugin's class name. - private const string PluginClassName = "com.google.unity.GoogleMobileAdsPlugin"; - - // Defines string values for supported ad sizes. - public class AdSize - { - private string adSize; - private AdSize(string value) - { - this.adSize = value; - } - - public override string ToString() - { - return adSize; - } - - public static AdSize Banner = new AdSize("BANNER"); - public static AdSize MediumRectangle = new AdSize("IAB_MRECT"); - public static AdSize IABBanner = new AdSize("IAB_BANNER"); - public static AdSize Leaderboard = new AdSize("IAB_LEADERBOARD"); - public static AdSize SmartBanner = new AdSize("SMART_BANNER"); - } - - // These are the ad callback events that can be hooked into. - public static event Action ReceivedAd = delegate {}; - public static event Action FailedToReceiveAd = delegate {}; - public static event Action ShowingOverlay = delegate {}; - public static event Action DismissedOverlay = delegate {}; - public static event Action LeavingApplication = delegate {}; - - void Awake() - { - gameObject.name = this.GetType().ToString(); - SetCallbackHandlerName(gameObject.name); - DontDestroyOnLoad(this); - } - - // Create a banner view and add it into the view hierarchy. - public static void CreateBannerView(string publisherId, AdSize adSize, bool positionAtTop) - { - AndroidJavaClass playerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); - AndroidJavaObject activity = playerClass.GetStatic("currentActivity"); - AndroidJavaClass pluginClass = new AndroidJavaClass(PluginClassName); - pluginClass.CallStatic("createBannerView", - new object[4] { activity, publisherId, adSize.ToString(), positionAtTop }); - } - - // Request a new ad for the banner view without any extras. - public static void RequestBannerAd(bool isTesting) - { - AndroidJavaClass pluginClass = new AndroidJavaClass(PluginClassName); - pluginClass.CallStatic("requestBannerAd", new object[1] {isTesting}); - } - - // Request a new ad for the banner view with extras. - public static void RequestBannerAd(bool isTesting, string extras) - { - AndroidJavaClass pluginClass = new AndroidJavaClass(PluginClassName); - pluginClass.CallStatic("requestBannerAd", new object[2] {isTesting, extras}); - } - - // Set the name of the callback handler so the right component gets ad callbacks. - public static void SetCallbackHandlerName(string callbackHandlerName) - { - AndroidJavaClass pluginClass = new AndroidJavaClass(PluginClassName); - pluginClass.CallStatic("setCallbackHandlerName", new object[1] {callbackHandlerName}); - } - - // Hide the banner view from the screen. - public static void HideBannerView() - { - AndroidJavaClass pluginClass = new AndroidJavaClass(PluginClassName); - pluginClass.CallStatic("hideBannerView"); - } - - // Show the banner view on the screen. - public static void ShowBannerView() { - AndroidJavaClass pluginClass = new AndroidJavaClass(PluginClassName); - pluginClass.CallStatic("showBannerView"); - } - - public void OnReceiveAd(string unusedMessage) - { - ReceivedAd(); - } - - public void OnFailedToReceiveAd(string message) - { - FailedToReceiveAd(message); - } - - public void OnPresentScreen(string unusedMessage) - { - ShowingOverlay(); - } - - public void OnDismissScreen(string unusedMessage) - { - DismissedOverlay(); - } - - public void OnLeaveApplication(string unusedMessage) - { - LeavingApplication(); - } -} - diff --git a/unity/android/Assets/Plugins/GoogleMobileAds/GoogleMobileAdsPlugin.prefab b/unity/android/Assets/Plugins/GoogleMobileAds/GoogleMobileAdsPlugin.prefab deleted file mode 100755 index c26d1727e0bb5555a243232b335f68367393e646..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5736 zcmeHLy>A>v6d#8qBz!|cAmPgdkf(&%d3wzu zGvhJLW|}AC)D7p8v@p|~@2q{`2F2US&|RL`ac(doieZ?La6<^imj3%YgjoL-J9S~kz)+W1KWu;m)C=_P)K5#w zNrX^n>3<-|R3o8ygXa1MDP2tM+QbdH?Lj3sw-5@AwGPV{uk}N^TbbwS!KGFQS+Y@J zdLhSCdsy{AwsUHaC?QM_sWr7nLp{S6p}feFbW9qrk$KsPAJbB^(xh2tcgzC6;s1}5 z3`XFmS7XYPTaI1r32H;?^HZwz8Sgt*WDoR?S0uwBEaboj)X-J-)j1reIy5pf& z=r#-81Fjk!;#P*8>vfZ%M12#9m)=aV$a&hr4QbC}7}`I-D6Iy{b5?f*t{l#Iu-% zZ_}uVX)$VNSapST99B{ELLa3H%ym0n4QvF837hZ!h!Ds7BI*j`7}3*=p&kZBUc~Ee zyV%U!>z6>sOSFo-h$odevYljnN(lwG=qQjZm}ZTkwW_pw@1gB zsQnhVYX*$_f5`3n5F_pH@lJ8J0^Ij`!hk{15do4yoPssri25Qx0kA&Gh{Di60M@K0 z?M*p-KAE}~7N(TpeU^+vj$OonuG;C)mxA9fM=Xp{0mcc|w! zdJElE`>3Wm*@^;v3S*oPM?UP@n(`nlqeVNQ<~SL#6*!vDM5w8jMx|Q~?SfDp6WboD zUm!uGFk`$sczd3!W1-(@6~pzY&5xL*nHhu2&%fnIzVj{nAsvGUArhxIqarp;Rzyk| zJt>4|wQW){dALHdaUh8l=Do+J#;02)gbuBBiLZeWF{bi9jW}l)j4p(;0HEoD;79>B zM>66xl?&?gU|2IOhTm{mv7=Q6KZK=@(vV1EDNKzmCD+TsW@A^dZS+AA@}fTSSFCo68`h`|PqS4XoYCeXP$nlfdUt<}-IDMFR!uDGe+a>MFeAG}u+ zD7xTjE|MltvW}LD$_L|9PlKb+1x8HXuB(h&l7=PlIFMUwVJ`*N%Fvqgm}E-{dnS*{Tlu8xG>E7lg)9G zQa!xrMq1eMn2gm(umzHQLy2rg`jHpgNj)KXtIi{bvOIOme&b0SzCZ7LS$CqGv`MAL SA#Jer-TFy?`C=Y(G{8U3wz+}; diff --git a/unity/android/GoogleMobileAdsPlugin.unitypackage b/unity/android/GoogleMobileAdsPlugin.unitypackage deleted file mode 100755 index 06ba7c7fd05ed5f042811b1ab34bdb53ae0444db..0000000000000000000000000000000000000000 GIT binary patch literal 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7lcx z`|w}yvA>%h-|7-{IZJc6t2O0a5;FhU-3>psWHP#X-)<@Si7q{K^E|~Rpu!kbYRqn? zw6aHAE~Wk18~NiD1>!4gz|@N$Tbk`K(}vt_%qh&Nv@)Ciu)638{IdG z8+4YMBmJ#}JHED7=Q3f*=0q5QlL~RE4PBedVgizJsx$uF$G$ zH}JmTp>@KUCqR`$Ip6=GMIgMwJ#e;m0{5&1h=8_?A}F|IIb;bs_<#a*VFCR7Hee}t z6Jw=}w>^A?W}N2hk87QO5`McTpP#-h@NLdFf2QkV%M@nwDf+9=a}4pz8Jgb+sescS zWx#}byUAx}DUrH$m;0-p0swWIidYsho)DM6qP$BVp~z z8Q+h!GqGm9V*9Py(K+e1_&w z*8znFe<@C1nf?JkBm8cWVMXdV_^aJ`^KolkS!%_~KFn4opY5zN{uw$sCz9s@jEVPy zoEI`;hD_dPFAGTpZv)BB+NDXxtR{%LwyF=Vves(ap#iyF*1E$P!dv0U9SK1^eyVK+ zJCoJE!73nk5X~A3IHrhwsDOZgo%~Ix->V-MRkAExtwzPf@2IQq7F7x=yZd@-4L^aaV~Dz&i-+T@tu-qH zp8TpA?H*sdIbL!d&cspEiy0_~dP^t^@2mF_jE=T}O*T@Wrt{8-h=DRy6g?>`MZpHq zTh%*wSit9n(67Wo5Ksj{_u`9|Jr4v9ka-jdLbf3=XWd+5z0Lzg6u5@}zs94Z^>!u2 zE$Ao&Y3iIE0ky-nwDfGB+qe#79PDOfU0I1p74oL@Sa}ZHe;gpKOG!E1=XHqRglrsq$y$EsZn=La1#%Fsf%%? z5Bow&xFVPy1X3}zu^==a^0UzIJ?nf(XjBC(wul?eTRaaF;O*%xh$hAIzsd(4rw8y> zdr+j&T?vd-4svRh6C;#FjwTd|K3q07nru "Import Package" -> "Custom Package". -3. Select the GoogleMobileAdsPlugin.unitypackage file. -4. Import all of the files for the plugins by selecting "Import". Make sure - to check for any conflicts with files. -5. Drag the GoogleMobileAds prefab from the Plugins/GoogleMobileAds/ folder into - your Unity scene. - -Note: If you already have an AndroidManifest.xml in Plugins/Android/, you can -just add the necessary activities and permissions to your existing manifest as -explained in https://developers.google.com/mobile-ads-sdk/docs#play instead of -importing the manifest from the .unitypackage. - -Additional dependencies: - -1. Add the google-play-services_lib folder, - located at /extras/google/google_play_services/libproject, - into the Plugins/Android folder of your project. - -This plugin also comes with an example plugin usage script, which is already -attached to the GoogleMobileAdsPlugin component for convenience. Simply edit -Plugins/GoogleMobileAdsPlugin/GoogleMobileAdsDemoScript.cs and include your ad -unit ID and run your project to see plugin working. - - -Google Mobile Ads Unity Plugin API -================================== -The plugin provides the following methods: - -1. CreateBannerView - - Takes in a publisherId string as well as a constant for the ad size. The - last boolean parameter denotes whether the ad should be shown at the top - or bottom of the screen. - - An example call placing the ad at the top of the screen is provided below: - - GoogleMobileAdsPlugin.CreateBannerView("INSERT_YOUR_AD_UNIT_ID_HERE", - GoogleMobileAdsPlugin.AdSize.Banner, - true); -2. RequestBannerAd - - Takes in a testing flag as well as an optional string representing a list - of extras. If you don't have any extras, you can request a live ad with: - - GoogleMobileAdsPlugin.RequestBannerAd(false); - - An example call requesting a test ad with some extras is shown below: - - string extras = "{\"color_bg\":\"AAAAFF\", \"color_text\":\"FFFFFF\"}"; - GoogleMobileAdsPlugin.RequestBannerAd(true, extras); - - NOTE: Make sure to use correctly formed JSON when passing an extras string. - If malformed JSON is passed, the extras will be ignored. - -3. HideBannerView - - Called after a BannerView has been created, this method can hide the ad from - showing on screen. An example call of this is shown below: - - GoogleMobileAdsPlugin.HideBannerView(); - -4. ShowBannerView - - Called after a BannerView has been created, this method can show any ad that - has been hidden. An example call of this is shown below: - - GoogleMobileAdsPlugin.ShowBannerView(); - -This plugin also allows you the option to listen for ad events. The following -events are supported: - - public static event Action ReceivedAd; - public static event Action FailedToReceiveAd; - public static event Action ShowingOverlay; - public static event Action DismissedOverlay; - public static event Action LeavingApplication; - -Registering for an event can be done using the += operater as is shown below: - - // Assume HandleReceivedAd is your function. - GoogleMobileAdsPlugin.ReceivedAd += HandleDidReceiveAd; - -Remember to un-register for events when you're cleaning up your GameObjects. -You can unregister using the -= operator as is shown below: - - // Assume HandleReceivedAd is your function. - GoogleMobileAdsPlugin.ReceivedAd -= HandleDidReceiveAd; - - -Updating the plugin -------------------- - -The plugin's .unitypackage only includes the compiled jar from the library -project. If you want to make changes to the library or see the source code, you -can find the project at -https://github.com/googleads/googleads-mobile-plugins/tree/master/unity. - -The library project depends on Unity's classes.jar, which can be found at -/Applications/Unity/Unity.app/Contents/PlaybackEngines/AndroidDevelopmentPlayer/bin -on Mac and usually at -C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidDevelopmentPlayer\bin -on Windows. - -Additional Resources --------------------- -* https://developers.google.com/mobile-ads-sdk/docs -* https://groups.google.com/group/google-admob-ads-sdk -* https://plus.google.com/+GoogleAdsDevelopers - diff --git a/unity/android/plugin-library/src/com/google/unity/GoogleMobileAdsPlugin.java b/unity/android/plugin-library/src/com/google/unity/GoogleMobileAdsPlugin.java deleted file mode 100755 index 0e130605e..000000000 --- a/unity/android/plugin-library/src/com/google/unity/GoogleMobileAdsPlugin.java +++ /dev/null @@ -1,298 +0,0 @@ -// Copyright 2014 Google Inc. All Rights Reserved. - -package com.google.unity; - -import com.google.android.gms.ads.AdListener; -import com.google.android.gms.ads.AdRequest; -import com.google.android.gms.ads.AdSize; -import com.google.android.gms.ads.AdView; -import com.google.android.gms.ads.mediation.admob.AdMobExtras; - -import android.app.Activity; -import android.graphics.Color; -import android.os.Bundle; -import android.util.Log; -import android.view.Gravity; -import android.view.View; -import android.widget.FrameLayout; - -import com.unity3d.player.UnityPlayer; - -import org.json.JSONException; -import org.json.JSONObject; - -import java.util.Iterator; - -/** - * This class represents the native implementation for the Google Mobile Ads Unity plugin. This - * class is used to request Google Mobile ads natively via the Google Mobile Ads library in Google - * Play services. The Google Play services library is a dependency for this plugin. - */ -public class GoogleMobileAdsPlugin { - /** The plugin version. */ - public static final String VERSION = "1.0"; - - /** Tag used for logging statements. */ - private static final String LOGTAG = "GoogleMobileAdsPlugin"; - - /** The {@code GoogleMobileAdsPlugin} singleton. */ - private static final GoogleMobileAdsPlugin instance = new GoogleMobileAdsPlugin(); - - /** The {@link AdView} to display to the user. */ - private AdView adView; - - /** The {@code Activity} that the banner will be displayed in. */ - private Activity activity; - - /** The Unity {@code GameObject} that should receive messages about ad events. */ - private String callbackHandlerName; - - /** Creates an instance of {@code GoogleMobileAdsPlugin}. */ - private GoogleMobileAdsPlugin() { - // Prevent instantiation. - } - - /** - * Gets a singleton instance of {@code GoogleMobileAdsPlugin}. - * - * @return the {@code GoogleMobileAdsPlugin} singleton. - */ - public static GoogleMobileAdsPlugin instance() { - return instance; - } - - /** - * Creates an {@link AdView} to old ads. - * - * @param activity The activity to place the {@code AdView}. - * @param publisherId Your ad unit ID. - * @param adSizeString A string ad size constant representing the desired ad size. - * @param positionAtTop True to position the ad at the top of the screen. False to position - * the ad at the bottom of the screen. - */ - public static void createBannerView(final Activity activity, final String publisherId, - final String adSizeString, final boolean positionAtTop) { - final GoogleMobileAdsPlugin plugin = GoogleMobileAdsPlugin.instance(); - plugin.activity = activity; - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - AdSize adSize = GoogleMobileAdsPlugin.adSizeFromSize(adSizeString); - if (adSize == null) { - Log.e(GoogleMobileAdsPlugin.LOGTAG, "AdSize is null. Did you use an AdSize constant?"); - return; - } - plugin.adView = new AdView(activity); - // Setting the background color works around an issue where the first ad isn't visible. - plugin.adView.setBackgroundColor(Color.TRANSPARENT); - plugin.adView.setAdUnitId(publisherId); - plugin.adView.setAdSize(adSize); - plugin.adView.setAdListener(new AdListener() { - @Override - public void onAdLoaded() { - if (plugin.callbackHandlerName != null && !plugin.callbackHandlerName.isEmpty()) { - UnityPlayer.UnitySendMessage(plugin.callbackHandlerName, "OnReceiveAd", ""); - } - } - - @Override - public void onAdFailedToLoad(int errorCode) { - if (plugin.callbackHandlerName != null && !plugin.callbackHandlerName.isEmpty()) { - UnityPlayer.UnitySendMessage(plugin.callbackHandlerName, "OnFailedToReceiveAd", - getErrorReason(errorCode)); - } - } - - @Override - public void onAdOpened() { - if (plugin.callbackHandlerName != null && !plugin.callbackHandlerName.isEmpty()) { - UnityPlayer.UnitySendMessage(plugin.callbackHandlerName, "OnPresentScreen", ""); - } - } - - @Override - public void onAdClosed() { - if (plugin.callbackHandlerName != null && !plugin.callbackHandlerName.isEmpty()) { - UnityPlayer.UnitySendMessage(plugin.callbackHandlerName, "OnDismissScreen", ""); - } - } - - @Override - public void onAdLeftApplication() { - if (plugin.callbackHandlerName != null && !plugin.callbackHandlerName.isEmpty()) { - UnityPlayer.UnitySendMessage(plugin.callbackHandlerName, "OnLeaveApplication", ""); - } - } - }); - FrameLayout.LayoutParams adParams = new FrameLayout.LayoutParams( - FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); - adParams.gravity = positionAtTop ? Gravity.TOP : Gravity.BOTTOM; - activity.addContentView(plugin.adView, adParams); - } - }); - } - - /** - * Sets the name of the {@code GameComponent} that should listen for ad events. - * - * @param callbackHandlerName the {@code GameComponent} that should listen for ad events. - */ - public static void setCallbackHandlerName(String callbackHandlerName) { - final GoogleMobileAdsPlugin plugin = GoogleMobileAdsPlugin.instance(); - plugin.callbackHandlerName = callbackHandlerName; - } - - /** - * Requests a banner ad without any extras. This method should be called only after a banner - * view has been created. - * - * @param isTesting True to enable test ads. False to get network ads. - */ - public static void requestBannerAd(final boolean isTesting) { - requestBannerAd(isTesting, null); - } - - /** - * Requests a banner ad. This method should be called only after a banner view has been created. - * - * @param isTesting True to enable test ads. False to get network ads. - * @param extrasJson A json object with key/value pairs representing what extras to pass in the - * request. - */ - public static void requestBannerAd(final boolean isTesting, final String extrasJson) { - final GoogleMobileAdsPlugin plugin = GoogleMobileAdsPlugin.instance(); - if (plugin.activity == null) { - Log.e(GoogleMobileAdsPlugin.LOGTAG, - "Activity is null. Call createBannerView before requestBannerAd."); - return; - } - - plugin.activity.runOnUiThread(new Runnable() { - @Override - public void run() { - if (plugin.adView == null) { - Log.e(GoogleMobileAdsPlugin.LOGTAG, "AdView is null. Aborting requestBannerAd."); - } else { - AdRequest.Builder adRequestBuilder = new AdRequest.Builder(); - if (isTesting) { - // This will request test ads on the emulator only. You can get your hashed device ID - // from LogCat when making a live request. Pass this hashed device ID to addTestDevice - // to get test ads on your device. - adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR); - } - Bundle bundle = new Bundle(); - if (extrasJson != null) { - try { - JSONObject extrasObject = new JSONObject(extrasJson); - Iterator extrasIterator = extrasObject.keys(); - while (extrasIterator.hasNext()) { - String key = extrasIterator.next(); - bundle.putString(key, extrasObject.getString(key)); - } - } catch (JSONException exception) { - Log.e(GoogleMobileAdsPlugin.LOGTAG, - "Extras are malformed. Aborting requestBannerAd."); - return; - } - } - bundle.putInt("unity", 1); - AdMobExtras extras = new AdMobExtras(bundle); - adRequestBuilder.addNetworkExtras(extras); - plugin.adView.loadAd(adRequestBuilder.build()); - } - } - }); - } - - /** - * Sets the banner view to be visible. - */ - public static void showBannerView() { - final GoogleMobileAdsPlugin plugin = GoogleMobileAdsPlugin.instance(); - if (plugin.activity == null) { - Log.e(GoogleMobileAdsPlugin.LOGTAG, - "Activity is null. Call createBannerView before showBannerView."); - return; - } - - plugin.activity.runOnUiThread(new Runnable() { - @Override - public void run() { - if (plugin.adView == null) { - Log.e(GoogleMobileAdsPlugin.LOGTAG, "AdView is null. Aborting showBannerView."); - return; - } - plugin.adView.setVisibility(View.VISIBLE); - } - }); - } - - /** - * Hides the banner view from the user. - */ - public static void hideBannerView() { - final GoogleMobileAdsPlugin plugin = GoogleMobileAdsPlugin.instance(); - if (plugin.activity == null) { - Log.e(GoogleMobileAdsPlugin.LOGTAG, - "Activity is null. Call createBannerView before hideBannerView."); - return; - } - - plugin.activity.runOnUiThread(new Runnable() { - @Override - public void run() { - if (plugin.adView == null) { - Log.e(GoogleMobileAdsPlugin.LOGTAG, "AdView is null. Aborting hideBannerView."); - return; - } - plugin.adView.setVisibility(View.GONE); - } - }); - } - - /** - * Gets an AdSize object from the string size passed in from JavaScript. Returns null if an - * improper string is provided. - * - * @param size The string size representing an ad format constant. - * @return An AdSize object used to create a banner. - */ - private static AdSize adSizeFromSize(String size) { - if ("BANNER".equals(size)) { - return AdSize.BANNER; - } else if ("IAB_MRECT".equals(size)) { - return AdSize.MEDIUM_RECTANGLE; - } else if ("IAB_BANNER".equals(size)) { - return AdSize.FULL_BANNER; - } else if ("IAB_LEADERBOARD".equals(size)) { - return AdSize.LEADERBOARD; - } else if ("SMART_BANNER".equals(size)) { - return AdSize.SMART_BANNER; - } else { - Log.w(LOGTAG, String.format("Unexpected ad size string: %s", size)); - return null; - } - } - - /** - * Gets a string error reason from an error code. - * - * @param errorCode The error code. - * @return The reason for the error. - */ - private static String getErrorReason(int errorCode) { - switch(errorCode) { - case AdRequest.ERROR_CODE_INTERNAL_ERROR: - return "Internal error"; - case AdRequest.ERROR_CODE_INVALID_REQUEST: - return "Invalid request"; - case AdRequest.ERROR_CODE_NETWORK_ERROR: - return "Network Error"; - case AdRequest.ERROR_CODE_NO_FILL: - return "No fill"; - default: - Log.w(LOGTAG, String.format("Unexpected error code: %s", errorCode)); - return ""; - } - } -} diff --git a/unity/iOS/AdMobUnityPlugin.unitypackage b/unity/iOS/AdMobUnityPlugin.unitypackage deleted file mode 100644 index a497cb566f93a8489c63924cb4e0913aedb866bf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8794 zcmZ{KWl)?^uP_uTE$;5_R;)M_w*tkXI20*Tr1;`41r}Rmi@O(hcPUPBDei8&&)4_f zJ9qA%@5h;woMbY|IhiDr9O@V}guYIQCIZr_|JPWG5f6Q6{9K~1$Xd3$*vJg)5xG*a zNpx2B+2LV^K{PSe_p~|XRTFz#R)eK{B7wE}HqJ@+gjU~XV-qa1K$>{OAs(~t8gtQ_ zM5y!$LOcRuBjR(yEwfY-HSep3ge23E1R6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E<6K(5V{^2GMop59u|w1-Q! zNL$tP8+;8zz2O7XtyY-=?H!dpP2SIw1&U@{Y2&s6CCR&{svbvo_j;qQsby0PV;A<) zt@_C4KP-=Gt(FJ8L)%je7xt)$9hRB#D>!HC=qQyPmdR0AEqpvj5EBAaDhD;_j_ejU zXFm{f_S6^kBRnK3%nQtgV}4Ot0GBp+m9F9ut@)VFfuZb*#6o|GyqlF^eXcQ`0<0cs zYg>JBqf1YI5^@)qcidEY;VD<5sGkcb*9ke7Ea4^z!kvG8LXv{QZ@@wFy|0w1_ksqS z+^40)GPc<=(D&EV;%)R9JYsM6uxiHDm5^wtC_bL;GuN;-^ z*Ry0MiqY2-+7@KnoPz^+t=0c@)#co#6m+wyziG*iZ547aTwy%BKy%MSH&W<(5wMIiEG_hf(2so_?QF9nd;&0$!kJ=Q#E1Z zrBMA(qZSf-sk~Fk4+IbS-IJon}dUfU;hqkIoaLx~*7qe!9UC$13paT|!25ElL&O;yDyUr>n(4R@O^yB$hi#^=$V~J4^~V8> z_8*U`sq~EYV&Ox8)e9@Y2*kp#ykagG$6gLEsfmlGUX2NH{{ByT0E#;Sg|LVNpn8$O z#Gww>Cb3r@ejBv1RmDjeuHmHsuDbpHI`Ukn7;fK%Cf zfz2+F6Toi4?TLF5$ifC61Fuk0n9Hn7e%Y{n(Bb$as1rkWTQtvebh==W%(Y1>< FailedToReceiveAd = delegate {}; - public static event Action ShowingOverlay = delegate {}; - public static event Action DismissingOverlay = delegate {}; - public static event Action DismissedOverlay = delegate {}; - public static event Action LeavingApplication = delegate {}; - - void Awake() - { - gameObject.name = this.GetType().ToString(); - SetCallbackHandlerName(gameObject.name); - DontDestroyOnLoad(this); - } - - // Create a GADBannerView and adds it into the view hierarchy. - public static void CreateBannerView(string publisherId, AdSize adSize, bool positionAtTop) - { - // Call plugin only when running on real device. - if (Application.platform == RuntimePlatform.OSXEditor) - { - return; - } - AdMobMobilePlugin.CreateBannerView(publisherId, adSize.ToString(), positionAtTop); - } - - // Request a new ad for the GADBannerView. - public static void RequestBannerAd(bool isTesting, string extras) - { - // Call plugin only when running on real device. - if (Application.platform == RuntimePlatform.OSXEditor) - { - return; - } - AdMobMobilePlugin.RequestBannerAd(isTesting, extras); - } - - // Set the name of the callback handler so the right component gets ad callbacks. - public static void SetCallbackHandlerName(string callbackHandlerName) - { - // Call plugin only when running on real device. - if (Application.platform == RuntimePlatform.OSXEditor) - { - return; - } - AdMobMobilePlugin.SetCallbackHandlerName(callbackHandlerName); - } - - // Hide the GADBannerView from the screen. - public static void HideBannerView() - { - // Call plugin only when running on real device. - if (Application.platform == RuntimePlatform.OSXEditor) - { - return; - } - AdMobMobilePlugin.HideBannerView(); - } - - // Show the GADBannerView on the screen if it's hidden. - public static void ShowBannerView() { - // Call plugin only when running on real device. - if (Application.platform == RuntimePlatform.OSXEditor) - { - return; - } - AdMobMobilePlugin.ShowBannerView(); - } - - public void AdViewDidReceiveAd(string message) - { - ReceivedAd(); - } - - public void AdViewDidFailToReceiveAd(string message) - { - FailedToReceiveAd(message); - } - - public void AdViewWillPresentScreen(string message) - { - ShowingOverlay(); - } - - public void AdViewWillDismissScreen(string message) - { - DismissingOverlay(); - } - - public void AdViewDidDismissScreen(string message) - { - DismissedOverlay(); - } - - public void AdViewWillLeaveApplication(string message) - { - LeavingApplication(); - } -} diff --git a/unity/iOS/Plugins/AdMobPlugin/AdMobPlugin.prefab b/unity/iOS/Plugins/AdMobPlugin/AdMobPlugin.prefab deleted file mode 100644 index be274583d48ef5f2e03903515e6a51a7f35fbd3d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5536 zcmeHLO^+Kj7UKFZfpK;l%Vd7UXPvElgT1fA#tdq8QbI6_T%^Cu^pwB#!4+8 zDW%RTwe&UR>fH+$FRXSis=tnpj~}8sWyf1KwUBHVz7t=7~+$sDCRnUA^DZ znMn&b7LWe`bw@(?2K`Xq@pE2H24?dLPxT;#D0w-QgIr4&{ZbCFkfa<#a`VrS&>SX9 z^?*^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b/unity/iOS/Plugins/AdMobPlugin/AdMobPluginDemoScript.cs deleted file mode 100644 index c9f4426f9..000000000 --- a/unity/iOS/Plugins/AdMobPlugin/AdMobPluginDemoScript.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System.Collections; -using UnityEngine; - -// Example script showing how you can easily call into the AdMobPlugin. -public class AdMobPluginDemoScript : MonoBehaviour { - - void Start() - { - // Pass in any extras you have as JSON. - string extras = "{\"color_bg\":\"AAAAFF\", \"color_bg_top\":\"FFFFFF\"}"; - AdMobPlugin.CreateBannerView("YOUR_AD_UNIT_ID_HERE", - AdMobPlugin.AdSize.Banner, - true); - print("Created Banner View"); - AdMobPlugin.RequestBannerAd(true, extras); - print("Requested Banner Ad"); - } - - void OnEnable() - { - print("Registering for AdMob Events"); - AdMobPlugin.ReceivedAd += HandleReceivedAd; - AdMobPlugin.FailedToReceiveAd += HandleFailedToReceiveAd; - AdMobPlugin.ShowingOverlay += HandleShowingOverlay; - AdMobPlugin.DismissingOverlay += HandleDismissingOverlay; - AdMobPlugin.DismissedOverlay += HandleDismissedOverlay; - AdMobPlugin.LeavingApplication += HandleLeavingApplication; - } - - void OnDisable() - { - print("Unregistering for AdMob Events"); - AdMobPlugin.ReceivedAd -= HandleReceivedAd; - AdMobPlugin.FailedToReceiveAd -= HandleFailedToReceiveAd; - AdMobPlugin.ShowingOverlay -= HandleShowingOverlay; - AdMobPlugin.DismissingOverlay -= HandleDismissingOverlay; - AdMobPlugin.DismissedOverlay -= HandleDismissedOverlay; - AdMobPlugin.LeavingApplication -= HandleLeavingApplication; - } - - public void HandleReceivedAd() - { - print("HandleReceivedAd event received"); - } - - public void HandleFailedToReceiveAd(string message) - { - print("HandleFailedToReceiveAd event received with message:"); - print(message); - } - - public void HandleShowingOverlay() - { - print("HandleShowingOverlay event received"); - } - - public void HandleDismissingOverlay() - { - print("HandleDismissingOverlay event received"); - } - - public void HandleDismissedOverlay() - { - print("HandleDismissedOverlay event received"); - } - - public void HandleLeavingApplication() - { - print("HandleLeavingApplication event received"); - } -} diff --git a/unity/iOS/Plugins/AdMobPlugin/AdMobPluginiOS.cs b/unity/iOS/Plugins/AdMobPlugin/AdMobPluginiOS.cs deleted file mode 100644 index 124d55abb..000000000 --- a/unity/iOS/Plugins/AdMobPlugin/AdMobPluginiOS.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Runtime.InteropServices; -using UnityEngine; - -public class AdMobPluginiOS { - - // These are the interface to native implementation calls for iOS. - [DllImport("__Internal")] - extern static public void _SetCallbackHandlerName(string handlerName); - - [DllImport("__Internal")] - private static extern void _CreateBannerView(string publisherId, - string adSize, - bool positionAtTop); - - [DllImport("__Internal")] - private static extern void _RequestBannerAd(bool isTesting, string extras); - - [DllImport("__Internal")] - private static extern void _HideBannerView(); - - [DllImport("__Internal")] - private static extern void _ShowBannerView(); - - public static void CreateBannerView(string publisherId, string adSize, bool positionAtTop) - { - _CreateBannerView(publisherId, adSize, positionAtTop); - } - - public static void RequestBannerAd(bool isTesting, string extras) - { - _RequestBannerAd(isTesting, extras); - } - - public static void SetCallbackHandlerName(string callbackHandlerName) - { - _SetCallbackHandlerName(callbackHandlerName); - } - - public static void HideBannerView() - { - _HideBannerView(); - } - - public static void ShowBannerView() - { - _ShowBannerView(); - } -} diff --git a/unity/iOS/Plugins/iOS/AdMobPlugin.h b/unity/iOS/Plugins/iOS/AdMobPlugin.h deleted file mode 100644 index f4f03eed5..000000000 --- a/unity/iOS/Plugins/iOS/AdMobPlugin.h +++ /dev/null @@ -1,33 +0,0 @@ -// AdMobPlugin.h -// Copyright 2013 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import -#import - -#import "GADBannerViewDelegate.h" - -@class GADBannerView; - -@interface AdMobPlugin : NSObject { - @private - // Value set by the Unity script to indicate whether the ad is to be - // positioned at the top or bottom of the screen. - BOOL positionAdAtTop_; -} - -@property(nonatomic, retain) GADBannerView *bannerView; -@property(nonatomic, retain) NSString *callbackHandlerName; - -@end diff --git a/unity/iOS/Plugins/iOS/AdMobPlugin.mm b/unity/iOS/Plugins/iOS/AdMobPlugin.mm deleted file mode 100644 index 5433d7bbe..000000000 --- a/unity/iOS/Plugins/iOS/AdMobPlugin.mm +++ /dev/null @@ -1,257 +0,0 @@ -// AdMobPlugin.mm -// Copyright 2013 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import - -#import "AdMobPlugin.h" -#import "GADAdMobExtras.h" -#import "GADAdSize.h" -#import "GADBannerView.h" - -@interface AdMobPlugin () - -// Root view controller for Unity applications can be accessed using this -// method. -extern UIViewController *UnityGetGLViewController(); - -@end - -@implementation AdMobPlugin - -@synthesize bannerView = bannerView_; -@synthesize callbackHandlerName = callbackHandlerName_; - -#pragma mark Unity bridge - -+ (AdMobPlugin *)pluginSharedInstance { - static AdMobPlugin *sharedInstance = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - sharedInstance = [[AdMobPlugin alloc] init]; - }); - return sharedInstance; -} - -- (void)createBannerViewWithPubId:(NSString *)publisherId - bannerTypeString:(NSString *)adSizeString - positionAtTop:(bool)positionAtTop { - GADAdSize adSize = [self GADAdSizeFromString:adSizeString]; - // We need values for adSize and publisherId if we don't want to fail. The - // AdMob library will spit an error if we try using invalid GADAdSize so just - // handle publisherId. - if (!publisherId) { - NSLog(@"AdMobPlugin: Failed because no publisher ID is set."); - return; - } - positionAdAtTop_ = positionAtTop; - [self createGADBannerViewWithPubId:publisherId - bannerType:adSize]; -} - -- (void)requestAdWithTesting:(BOOL)isTesting - extrasString:(NSString *)extrasString { - if (!self.bannerView) { - NSLog(@"AdMobPlugin: Failed because CreateBannerView() must be called" - @"before RequestBannerAd()."); - return; - } - // Turn the incoming JSON string into a NSDictionary. - NSError *error = nil; - NSData *extrasJsonData = - [extrasString dataUsingEncoding:NSUTF8StringEncoding]; - NSDictionary *extrasJsonDictionary = - [NSJSONSerialization JSONObjectWithData:extrasJsonData - options:NSJSONReadingMutableContainers - error:&error]; - if (extrasJsonDictionary) { - // Add a flag to denote that this request is coming from the unity plugin. - NSMutableDictionary *modifiedExtrasDict = - [[NSMutableDictionary alloc] initWithDictionary:extrasJsonDictionary]; - [modifiedExtrasDict removeObjectForKey:@"unity"]; - [modifiedExtrasDict setValue:@"1" forKey:@"unity"]; - [self requestAdWithTesting:isTesting - extras:modifiedExtrasDict]; - } else { - NSLog(@"AdMobPlugin: Error parsing JSON for extras: %@", error); - } -} - -- (void)hideBannerView { - if (!self.bannerView) { - NSLog(@"AdMobPlugin: Failed because a GADBannerView was never created."); - return; - } - self.bannerView.hidden = YES; -} - -- (void)showBannerView { - if (!self.bannerView) { - NSLog(@"AdMobPlugin: Failed because a GADBannerView was never created."); - return; - } - self.bannerView.hidden = NO; -} - -- (GADAdSize)GADAdSizeFromString:(NSString *)string { - if ([string isEqualToString:@"BANNER"]) { - return kGADAdSizeBanner; - } else if ([string isEqualToString:@"IAB_MRECT"]) { - return kGADAdSizeMediumRectangle; - } else if ([string isEqualToString:@"IAB_BANNER"]) { - return kGADAdSizeFullBanner; - } else if ([string isEqualToString:@"IAB_LEADERBOARD"]) { - return kGADAdSizeLeaderboard; - } else if ([string isEqualToString:@"SMART_BANNER"]) { - // Have to choose the right Smart Banner constant according to orientation. - UIDeviceOrientation currentOrientation = - [[UIDevice currentDevice] orientation]; - if (UIInterfaceOrientationIsPortrait(currentOrientation)) { - return kGADAdSizeSmartBannerPortrait; - } else { - return kGADAdSizeSmartBannerLandscape; - } - } else { - return kGADAdSizeInvalid; - } -} - -#pragma mark Ad Banner logic - -- (void)createGADBannerViewWithPubId:(NSString *)pubId - bannerType:(GADAdSize)adSize { - self.bannerView = [[[GADBannerView alloc] initWithAdSize:adSize] autorelease]; - self.bannerView.adUnitID = pubId; - self.bannerView.delegate = self; - self.bannerView.rootViewController = UnityGetGLViewController(); -} - -- (void)requestAdWithTesting:(BOOL)isTesting - extras:(NSDictionary *)extrasDict { - GADRequest *request = [GADRequest request]; - if (isTesting) { - // Make the request for a test ad. Put in an identifier for the simulator as - // well as any devices you want to receive test ads. - request.testDevices = - [NSArray arrayWithObjects: - GAD_SIMULATOR_ID, - // TODO: Add your device test identifiers here. They are - // printed to the console when the app is launched. - nil]; - } - if (extrasDict) { - GADAdMobExtras *extras = [[[GADAdMobExtras alloc] init] autorelease]; - extras.additionalParameters = extrasDict; - [request registerAdNetworkExtras:extras]; - } - [self.bannerView loadRequest:request]; - // Add the ad to the main container view. - [UnityGetGLViewController().view addSubview:self.bannerView]; -} - -#pragma mark GADBannerViewDelegate implementation - -- (void)adViewDidReceiveAd:(GADBannerView *)adView { - UnitySendMessage([callbackHandlerName_ UTF8String], - "AdViewDidReceiveAd", - "Received ad successfully."); -} - -- (void)adView:(GADBannerView *)view - didFailToReceiveAdWithError:(GADRequestError *)error { - NSString *errorMsg = - [NSString stringWithFormat:@"Failed to receive ad with error: %@", - [error localizedFailureReason]]; - UnitySendMessage([callbackHandlerName_ UTF8String], - "AdViewDidFailToReceiveAd", - [errorMsg UTF8String]); -} - -- (void)adViewWillPresentScreen:(GADBannerView *)adView { - UnitySendMessage([callbackHandlerName_ UTF8String], - "AdViewWillPresentScreen", - "Calling AdViewWillPresentScreen."); -} - -- (void)adViewDidDismissScreen:(GADBannerView *)adView { - UnitySendMessage([callbackHandlerName_ UTF8String], - "AdViewDidDismissScreen", - "Calling AdViewDidDismissScreen."); -} - -- (void)adViewWillDismissScreen:(GADBannerView *)adView { - UnitySendMessage([callbackHandlerName_ UTF8String], - "AdViewWillDismissScreen", - "Calling adViewWillDismissScreen."); -} - -- (void)adViewWillLeaveApplication:(GADBannerView *)adView { - UnitySendMessage([callbackHandlerName_ UTF8String], - "AdViewWillLeaveApplication", - "Calling AdViewWillLeaveApplication."); -} - -#pragma mark Cleanup - -- (void)dealloc { - bannerView_.delegate = nil; - [bannerView_ release]; - [super dealloc]; -} - -@end - -// Helper method used to convert NSStrings into C-style strings. -NSString *CreateNSString(const char* string) { - if (string) { - return [NSString stringWithUTF8String:string]; - } else { - return [NSString stringWithUTF8String:""]; - } -} - -// Unity can only talk directly to C code so use these method calls as wrappers -// into the actual plugin logic. -extern "C" { - - void _CreateBannerView(const char *publisherId, - const char *adSize, - bool positionAtTop) { - AdMobPlugin *adMobPlugin = [AdMobPlugin pluginSharedInstance]; - [adMobPlugin createBannerViewWithPubId:CreateNSString(publisherId) - bannerTypeString:CreateNSString(adSize) - positionAtTop:(BOOL)positionAtTop]; - } - - void _RequestBannerAd(bool isTesting, const char *extras) { - AdMobPlugin *adMobPlugin = [AdMobPlugin pluginSharedInstance]; - [adMobPlugin requestAdWithTesting:(BOOL)isTesting - extrasString:CreateNSString(extras)]; - } - - void _SetCallbackHandlerName(const char *callbackHandlerName) { - AdMobPlugin *adMobPlugin = [AdMobPlugin pluginSharedInstance]; - [adMobPlugin setCallbackHandlerName:CreateNSString(callbackHandlerName)]; - } - - void _HideBannerView() { - AdMobPlugin *adMobPlugin = [AdMobPlugin pluginSharedInstance]; - [adMobPlugin hideBannerView]; - } - - void _ShowBannerView() { - AdMobPlugin *adMobPlugin = [AdMobPlugin pluginSharedInstance]; - [adMobPlugin showBannerView]; - } -} diff --git a/unity/iOS/README.md b/unity/iOS/README.md deleted file mode 100644 index 8450b156f..000000000 --- a/unity/iOS/README.md +++ /dev/null @@ -1,130 +0,0 @@ -About -===== -Copyright 2013 Google Inc. All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -Features ---------- -This is the AdMob Unity Plugin for iOS. It provides a way to request -AdMob ads from a Unity project. This plugin was written and tested with -the Google AdMob SDK version 6.4.1 for iOS, and Unity 4.1.2. - -The AdMob Unity plugin contains a .unitypackage file for those that want to -easily import the plugin, as well as the source code. - -Requirements --------------- -* Unity Pro 4.1.2 -* Google AdMob Ads SDK for iOS -* iOS version 4.3 or later as well as XCode 4.5 or later -* AdMob publisher ID - -How to import AdMobUnityPlugin.unitypackage ---------------------------------------------- -1. Open your project in the Unity editor. -2. On the top toolbar, select "Assets" -> "Import Package" -> "Custom Package". -3. Select the AdMobUnityPlugin.unitypackage file. -4. Import all of the files for the plugins by selecting "Import". Make sure - to check for any conflicts with files. -5. Drag the AdMobPlugin prefab from the Plugins/AdMobPlugin/ folder into - your Unity scene. - -The plugin also comes with an example script. Simply attach -AdMobPluginDemoScript (found in Plugins/AdMobPlugin/) to your MainCamera as a -Component and build your project to see AdMob working. - -iOS - Building project ------------------------- -1. Open up AdMobMobilePlugin.cs and make sure that the AdMobMobilePlugin - is set to AdMobPluginiOS. -2. On the top toolbar, select "File" -> "Build Settings". -3. Check off the scenes you wan to build in the "Scenes In Build" section. -4. Switch the platform to iOS, then select "Player Settings". -5. Set "Target iOS Version" to at least iOS 4.3 or above. -6. Select "Build" on the "Build Settings" menu to build a XCode project. - -iOS - Running project ----------------------- -Before running your compiled XCode project, you will need to add some -framework references as well as modify linker flags. You can find a detailed -set of instructions on how to do this at: - -https://developers.google.com/mobile-ads-sdk/docs/ - -Implementation ------------------- -The plugin provides the following AdMob methods: - -1. CreateBannerView - - Takes in a publisherId string as well as a constant for the ad size. The - last boolean parameter denotes whether the ad should be shown at the top - or bottom of the screen. - - An example call placing the ad at the top of the screen is provided below: - - AdMobPlugin.CreateBannerView ("INSERT_PUBLISHER_ID_HERE", - AdMobPlugin.ADSIZE_SMART_BANNER, - true); -2. RequestBannerAd - - Takes in a testing flag as well as a string representing a list of extras. - Make sure to use correctly formed JSON for the extras. Pass in an empty - string ("") if you have no extras. - - An example call requesting a test ad with some extras is shown below: - - AdMobPlugin.RequestBannerAd (true, - "{\"color_bg\":\"AAAAFF\"}"); - -3. HideBannerView - - Called after a BannerView has been created. This method can hide the ad from - showing on screen. An example call of this is shown below: - - AdMobPlugin.HideBannerView(); - -4. ShowBannerView - - Called after a BannerView has been created, this method can show any ad that - has been hidden. An example call of this is shown below: - - AdMobPlugin.ShowBannerView(); - -This plugin also allows you the option to listen for ad events. The following -events are supported: - - public static event Action ReceivedAd; - public static event Action FailedToReceiveAd; - public static event Action ShowingOverlay; - public static event Action DismissingOverlay; - public static event Action DismissedOverlay; - public static event Action LeavingApplication; - -Registering for an event can be done using the += operater as is shown below: - - // Assume HandleReceivedAd is your function. - AdMobPlugin.ReceivedAd += HandleDidReceiveAd; - -Remember to un-register for events when you're cleaning up your GameObjects. -You can unregister using the -= operator as is shown below: - - // Assume HandleReceivedAd is your function. - AdMobPlugin.ReceivedAd -= HandleDidReceiveAd; - -Additional Resources ------------------------ -* https://developers.google.com/mobile-ads-sdk/docs -* https://groups.google.com/group/google-admob-ads-sdk -* https://plus.google.com/+GoogleAdsDevelopers diff --git a/unity/samples/HelloWorld/.gitignore b/unity/samples/HelloWorld/.gitignore new file mode 100644 index 000000000..ac99fe4f4 --- /dev/null +++ b/unity/samples/HelloWorld/.gitignore @@ -0,0 +1,35 @@ +# =============== # +# Unity generated # +# =============== # +Temp/ +Obj/ +UnityGenerated/ +Library/ +ProjectSettings/ +*.meta + +# ===================================== # +# Visual Studio / MonoDevelop generated # +# ===================================== # +ExportedObj/ +*.svd +*.userprefs +*.csproj +*.pidb +*.suo +*.sln +*.user +*.unityproj +*.booproj + +# ============ # +# OS generated # +# ============ # +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +Icon? +ehthumbs.db +Thumbs.db diff --git a/unity/samples/HelloWorld/Assets/GoogleMobileAdsDemoScript.cs b/unity/samples/HelloWorld/Assets/GoogleMobileAdsDemoScript.cs new file mode 100644 index 000000000..462a303a1 --- /dev/null +++ b/unity/samples/HelloWorld/Assets/GoogleMobileAdsDemoScript.cs @@ -0,0 +1,112 @@ +using System; +using UnityEngine; +using GoogleMobileAds; +using GoogleMobileAds.Api; + +// Example script showing how to invoke the Google Mobile Ads Unity plugin. +public class GoogleMobileAdsDemoScript : MonoBehaviour { + + private BannerView bannerView; + + void Start() + { + #if UNITY_EDITOR + string adUnitId = "unused"; + #elif UNITY_ANDROID + string adUnitId = "INSERT_YOUR_ANDROID_AD_UNIT_HERE"; + #elif UNITY_IPHONE + string adUnitId = "INSERT_YOUR_IOS_AD_UNIT_HERE"; + #else + string adUnitId = "unexpected_platform"; + #endif + + // Create a 320x50 banner at the top of the screen. + bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Top); + // Register for ad events. + bannerView.AdLoaded += HandleAdLoaded; + bannerView.AdFailedToLoad += HandleAdFailedToLoad; + bannerView.AdOpened += HandleAdOpened; + bannerView.AdClosing += HandleAdClosing; + bannerView.AdClosed += HandleAdClosed; + bannerView.AdLeftApplication += HandleAdLeftApplication; + } + + void OnGUI() { + // Puts some basic buttons onto the screen. + GUI.skin.button.fontSize = (int) (0.05f * Screen.height); + + Rect buttonRect = new Rect(0.1f * Screen.width, 0.1f * Screen.height, + 0.8f * Screen.width, 0.2f * Screen.height); + if (GUI.Button(buttonRect, "Request Banner")) { + RequestBanner(); + } + + Rect bannerRect = new Rect(0.1f * Screen.width, 0.4f * Screen.height, + 0.8f * Screen.width, 0.2f * Screen.height); + if (GUI.Button(bannerRect, "Show Banner")) { + ShowBanner(); + } + + Rect interstitialRect = new Rect(0.1f * Screen.width, 0.7f * Screen.height, + 0.8f * Screen.width, 0.2f * Screen.height); + if (GUI.Button(interstitialRect, "Hide Banner")) { + HideBanner(); + } + } + + void RequestBanner() { + // Request a banner ad, with optional custom ad targeting. + AdRequest request = new AdRequest.Builder() + .AddTestDevice(AdRequest.TestDeviceSimulator) + .AddTestDevice("0123456789ABCDEF0123456789ABCDEF") + .AddKeyword("game") + .SetGender(Gender.Male) + .SetBirthday(new DateTime(1985, 1, 1)) + .TagForChildDirectedTreatment(false) + .AddExtra("color_bg", "9B30FF") + .Build(); + bannerView.LoadAd(request); + } + + void ShowBanner() { + bannerView.Show(); + } + + void HideBanner() { + bannerView.Hide(); + } + + #region Banner callback handlers + + public void HandleAdLoaded() + { + print("HandleAdLoaded event received."); + } + + public void HandleAdFailedToLoad(string message) + { + print("HandleFailedToReceiveAd event received with message: " + message); + } + + public void HandleAdOpened() + { + print("HandleAdOpened event received"); + } + + void HandleAdClosing () + { + print("HandleAdClosing event received"); + } + + public void HandleAdClosed() + { + print("HandleAdClosed event received"); + } + + public void HandleAdLeftApplication() + { + print("HandleAdLeftApplication event received"); + } + + #endregion +} diff --git a/unity/samples/HelloWorld/Assets/MainScene.unity b/unity/samples/HelloWorld/Assets/MainScene.unity new file mode 100644 index 0000000000000000000000000000000000000000..c3c40a64817673f0dad489f11b35549ff9138309 GIT binary patch literal 12856 zcmeHN&5s;M6)!^o+eyq<2;VUI01QY$Nqq1jtY>!D>s_>Kk9X{#ph#BjOz%u*d%8#6 zJ!`Lt#9WXNR|Hawkjx#4KLH^*5{E?M2I2%at~e4xLc+Y?dsRKJrh6AFL?RMftKR9Z z`c=JGRqwO9jd|`JV_rCKj5%e@w?0O{=G=2HK6h^SdGoIa4<0;5&-C+PD@(KGXk_=} zY?_;8TSQz9ILZn9oADTCnilaejRvhaEzS7Gm7Uk3ez_hGqP4^h3-gGFyI<}~_uX!p zzjSdBmsx)CRvFPCS-M31yLq&0ce*x@(o)7UCkg%mx=_&l1pVPz2(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zxzZVv%t=D=l_P;$_SPyL16dMKmXfa?iS~=Y(61c<-Mq5eo8~x=+Om@g9R&wO&NlRv z4eHv#fY3bt*BemI5II%F7f5v4g`;V91>ZQl2fg9n>y-4R9Rt7F0K7+a?o*V?PVvFm z^A3z32sAVn{_|b>a7SZ#N-wD^Li8#uc*dr|L!k)G87F%pm=wsQHw9ct;<1 z(&^_}Q3TQwI(zBEa$x)YX-;`#Hz7G2DRp98`0f{)>j)o*Gojejd739y@S1K|~ ze(AQ63W>gC^7=eHoT|KjTY!hoUIynl!ASsuH+RbsiuU_pq%lG{-0!Q8o3+Dd>A`SR zz>$B335S`+1xhWtUZrc~F38l3E=UXlXdv}4$!q`YEMGqJtE+$c+n;{?kNaL>(AHS)wvCxB8S}ek)qH{O z-8H*_Ax{6{nU|#fXDe^NwYlUk>I7k&RqOcGDu#t>d6-hS&XdIoNebtI_Hv}q@o2}5%aO8fftA9iS`=sLQ<9)Lv@ z?1zuHuwU3W6zu2ga?AUTeMf;jKrT=qFZhMhZP_?&xi3$kvUqlnfCMF6v!Ka9E`2+G z|9tT45OBzo?$-o)uiC-WoA*|ietzf9(mVI>Fa7fFT_<0lDtmV4jW=j-Zm$|Mak6>0 iO>Mt{PN4wF#ZS~ft6%V|9_iN00)AV+^|a>og8nxWJSsu} literal 0 HcmV?d00001 diff --git a/unity/source/Assets/GoogleMobileAds/Api/AdPosition.cs b/unity/source/Assets/GoogleMobileAds/Api/AdPosition.cs new file mode 100644 index 000000000..04e4e138f --- /dev/null +++ b/unity/source/Assets/GoogleMobileAds/Api/AdPosition.cs @@ -0,0 +1,9 @@ +namespace GoogleMobileAds.Api +{ + // The position of the ad on the screen. + public enum AdPosition + { + Top = 0, + Bottom = 1 + } +} diff --git a/unity/source/Assets/GoogleMobileAds/Api/AdRequest.cs b/unity/source/Assets/GoogleMobileAds/Api/AdRequest.cs new file mode 100644 index 000000000..d5ebd4571 --- /dev/null +++ b/unity/source/Assets/GoogleMobileAds/Api/AdRequest.cs @@ -0,0 +1,186 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace GoogleMobileAds.Api +{ + public class AdRequest + { + public const string Version = "2.0"; + public const string TestDeviceSimulator = "SIMULATOR"; + + public class Builder + { + private List testDevices; + private HashSet keywords; + private DateTime? birthday; + private Gender? gender; + private bool? tagForChildDirectedTreatment; + private Dictionary extras; + + public Builder() + { + this.testDevices = new List(); + this.keywords = new HashSet(); + this.birthday = null; + this.gender = null; + this.tagForChildDirectedTreatment = null; + this.extras = new Dictionary(); + } + + public Builder AddKeyword(string keyword) + { + this.keywords.Add(keyword); + return this; + } + + public Builder AddTestDevice(string deviceId) + { + this.testDevices.Add(deviceId); + return this; + } + + public AdRequest Build() + { + return new AdRequest(this); + } + + public Builder SetBirthday(DateTime birthday) + { + this.birthday = birthday; + return this; + } + + public Builder SetGender(Gender gender) + { + this.gender = gender; + return this; + } + + public Builder TagForChildDirectedTreatment(bool tagForChildDirectedTreatment) + { + this.tagForChildDirectedTreatment = tagForChildDirectedTreatment; + return this; + } + + public Builder AddExtra(string key, string value) + { + this.extras.Add(key, value); + return this; + } + + internal List TestDevices + { + get + { + return testDevices; + } + } + + internal HashSet Keywords + { + get + { + return keywords; + } + } + + internal DateTime? Birthday + { + get + { + return birthday; + } + } + + internal Gender? Gender + { + get + { + return gender; + } + } + + internal bool? ChildDirectedTreatmentTag + { + get + { + return tagForChildDirectedTreatment; + } + } + + internal Dictionary Extras + { + get + { + return extras; + } + } + } + + private List testDevices; + private HashSet keywords; + private DateTime? birthday; + private Gender? gender; + private bool? tagForChildDirectedTreatment; + private Dictionary extras; + + private AdRequest(Builder builder) + { + testDevices = builder.TestDevices; + keywords = builder.Keywords; + birthday = builder.Birthday; + gender = builder.Gender; + tagForChildDirectedTreatment = builder.ChildDirectedTreatmentTag; + extras = builder.Extras; + } + + public List TestDevices + { + get + { + return testDevices; + } + } + + public HashSet Keywords + { + get + { + return keywords; + } + } + + public DateTime? Birthday + { + get + { + return birthday; + } + } + + public Gender? Gender + { + get + { + return gender; + } + } + + public bool? TagForChildDirectedTreatment + { + get + { + return tagForChildDirectedTreatment; + } + } + + public Dictionary Extras + { + get + { + return extras; + } + } + } +} diff --git a/unity/source/Assets/GoogleMobileAds/Api/AdSize.cs b/unity/source/Assets/GoogleMobileAds/Api/AdSize.cs new file mode 100644 index 000000000..4c0137acc --- /dev/null +++ b/unity/source/Assets/GoogleMobileAds/Api/AdSize.cs @@ -0,0 +1,49 @@ +namespace GoogleMobileAds.Api { + public class AdSize { + private bool isSmartBanner; + private int width; + private int height; + + public static readonly AdSize Banner = new AdSize(320, 50); + public static readonly AdSize MediumRectangle = new AdSize(300, 250); + public static readonly AdSize IABBanner = new AdSize(468, 60); + public static readonly AdSize Leaderboard = new AdSize(728, 90); + public static readonly AdSize SmartBanner = new AdSize(true); + + public AdSize(int width, int height) { + isSmartBanner = false; + this.width = width; + this.height = height; + } + + private AdSize(bool isSmartBanner) { + this.isSmartBanner = isSmartBanner; + this.width = 0; + this.height = 0; + } + + public int Width + { + get + { + return width; + } + } + + public int Height + { + get + { + return height; + } + } + + public bool IsSmartBanner + { + get + { + return isSmartBanner; + } + } + } +} diff --git a/unity/source/Assets/GoogleMobileAds/Api/BannerView.cs b/unity/source/Assets/GoogleMobileAds/Api/BannerView.cs new file mode 100644 index 000000000..f747ccac3 --- /dev/null +++ b/unity/source/Assets/GoogleMobileAds/Api/BannerView.cs @@ -0,0 +1,86 @@ +using System; +using GoogleMobileAds.Common; + +namespace GoogleMobileAds.Api +{ + public class BannerView : IAdListener + { + private IGoogleMobileAdsBannerClient client; + + // These are the ad callback events that can be hooked into. + public event Action AdLoaded = delegate {}; + public event Action AdFailedToLoad = delegate {}; + public event Action AdOpened = delegate {}; + // AdClosing will only fire on iOS. + public event Action AdClosing = delegate {}; + public event Action AdClosed = delegate {}; + public event Action AdLeftApplication = delegate {}; + + // Create a BannerView and add it into the view hierarchy. + public BannerView(string adUnitId, AdSize adSize, AdPosition position) + { + client = GoogleMobileAdsClientFactory.GetGoogleMobileAdsBannerClient(this); + client.CreateBannerView(adUnitId, adSize, position); + } + + // Load an ad into the BannerView. + public void LoadAd(AdRequest request) + { + client.LoadAd(request); + } + + // Hide the BannerView from the screen. + public void Hide() + { + client.HideBannerView(); + } + + // Show the BannerView on the screen. + public void Show() + { + client.ShowBannerView(); + } + + // Destroy the BannerView. + public void Destroy() + { + client.DestroyBannerView(); + } + + #region IAdListener implementation + + // The following methods are invoked from an IGoogleMobileAdsClient. Forward these calls + // to the developer. + void IAdListener.FireAdLoaded() + { + AdLoaded(); + } + + void IAdListener.FireAdFailedToLoad(string message) + { + AdFailedToLoad(message); + } + + void IAdListener.FireAdOpened() + { + AdOpened(); + } + + void IAdListener.FireAdClosing() + { + AdClosing(); + } + + void IAdListener.FireAdClosed() + { + AdClosed(); + } + + void IAdListener.FireAdLeftApplication() + { + AdLeftApplication(); + } + + #endregion + } +} diff --git a/unity/source/Assets/GoogleMobileAds/Api/Gender.cs b/unity/source/Assets/GoogleMobileAds/Api/Gender.cs new file mode 100644 index 000000000..0d00ac0f9 --- /dev/null +++ b/unity/source/Assets/GoogleMobileAds/Api/Gender.cs @@ -0,0 +1,10 @@ +namespace GoogleMobileAds.Api +{ + // The gender of the user. + public enum Gender + { + Unknown = 0, + Male = 1, + Female = 2 + } +} diff --git a/unity/source/Assets/GoogleMobileAds/Common/DummyClient.cs b/unity/source/Assets/GoogleMobileAds/Common/DummyClient.cs new file mode 100644 index 000000000..dce509278 --- /dev/null +++ b/unity/source/Assets/GoogleMobileAds/Common/DummyClient.cs @@ -0,0 +1,38 @@ +using UnityEngine; +using GoogleMobileAds.Api; + +namespace GoogleMobileAds.Common +{ + internal class DummyClient : IGoogleMobileAdsBannerClient + { + public DummyClient(IAdListener listener) + { + Debug.Log("Created DummyClient"); + } + + public void CreateBannerView(string adUnitId, AdSize adSize, AdPosition position) + { + Debug.Log("Dummy CreateBannerView"); + } + + public void LoadAd(AdRequest request) + { + Debug.Log("Dummy LoadAd"); + } + + public void ShowBannerView() + { + Debug.Log("Dummy ShowBannerView"); + } + + public void HideBannerView() + { + Debug.Log("Dummy HideBannerView"); + } + + public void DestroyBannerView() + { + Debug.Log("Dummy DestroyBannerView"); + } + } +} diff --git a/unity/source/Assets/GoogleMobileAds/Common/IAdListener.cs b/unity/source/Assets/GoogleMobileAds/Common/IAdListener.cs new file mode 100644 index 000000000..25f636161 --- /dev/null +++ b/unity/source/Assets/GoogleMobileAds/Common/IAdListener.cs @@ -0,0 +1,15 @@ +using System; + +namespace GoogleMobileAds.Common +{ + // Interface for the methods to be invoked by the native plugin. + internal interface IAdListener + { + void FireAdLoaded(); + void FireAdFailedToLoad(string message); + void FireAdOpened(); + void FireAdClosing(); + void FireAdClosed(); + void FireAdLeftApplication(); + } +} diff --git a/unity/source/Assets/GoogleMobileAds/Common/IGoogleMobileAdsBannerClient.cs b/unity/source/Assets/GoogleMobileAds/Common/IGoogleMobileAdsBannerClient.cs new file mode 100644 index 000000000..6e5f2abb0 --- /dev/null +++ b/unity/source/Assets/GoogleMobileAds/Common/IGoogleMobileAdsBannerClient.cs @@ -0,0 +1,20 @@ +using GoogleMobileAds.Api; + +namespace GoogleMobileAds.Common { + internal interface IGoogleMobileAdsBannerClient { + // Create a banner view and add it into the view hierarchy. + void CreateBannerView(string adUnitId, AdSize adSize, AdPosition position); + + // Request a new ad for the banner view. + void LoadAd(AdRequest request); + + // Show the banner view on the screen. + void ShowBannerView(); + + // Hide the banner view from the screen. + void HideBannerView(); + + // Destroys a banner view and to free up memory. + void DestroyBannerView(); + } +} diff --git a/unity/source/Assets/GoogleMobileAds/Platforms/Android/AdListener.cs b/unity/source/Assets/GoogleMobileAds/Platforms/Android/AdListener.cs new file mode 100644 index 000000000..b1b0e0a4a --- /dev/null +++ b/unity/source/Assets/GoogleMobileAds/Platforms/Android/AdListener.cs @@ -0,0 +1,42 @@ +#if UNITY_ANDROID + +using UnityEngine; +using GoogleMobileAds.Common; + +namespace GoogleMobileAds.Android +{ + internal class AdListener : AndroidJavaProxy + { + private const string UnityAdListenerClass = "com.google.unity.ads.UnityAdListener"; + + private IAdListener listener; + internal AdListener(IAdListener listener) : + base(UnityAdListenerClass) + { + this.listener = listener; + } + + void onAdLoaded() { + listener.FireAdLoaded(); + } + + void onAdFailedToLoad(string errorReason) { + listener.FireAdFailedToLoad(errorReason); + } + + void onAdOpened() { + listener.FireAdOpened(); + } + + void onAdClosed() { + listener.FireAdClosing(); + listener.FireAdClosed(); + } + + void onAdLeftApplication() { + listener.FireAdLeftApplication(); + } + } +} + +#endif diff --git a/unity/source/Assets/GoogleMobileAds/Platforms/Android/AndroidBannerClient.cs b/unity/source/Assets/GoogleMobileAds/Platforms/Android/AndroidBannerClient.cs new file mode 100644 index 000000000..8561bf8ed --- /dev/null +++ b/unity/source/Assets/GoogleMobileAds/Platforms/Android/AndroidBannerClient.cs @@ -0,0 +1,145 @@ +#if UNITY_ANDROID + +using System; +using System.Collections.Generic; +using UnityEngine; +using GoogleMobileAds.Api; +using GoogleMobileAds.Common; + +namespace GoogleMobileAds.Android +{ + internal class AndroidBannerClient : IGoogleMobileAdsBannerClient + { + private const string AdListenerClass = "com.google.android.gms.ads.AdListener"; + private const string AdRequestClass = "com.google.android.gms.ads.AdRequest"; + private const string AdRequestBuilderClass = "com.google.android.gms.ads.AdRequest$Builder"; + private const string AdSizeClass = "com.google.android.gms.ads.AdSize"; + private const string AdMobExtrasClass = + "com.google.android.gms.ads.mediation.admob.AdMobExtras"; + private const string BannerViewClass = "com.google.unity.ads.Banner"; + private const string BundleClass = "android.os.Bundle"; + private const string DateClass = "java.util.Date"; + + private AndroidJavaObject bannerView; + + public AndroidBannerClient(IAdListener listener) + { + AndroidJavaClass playerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); + AndroidJavaObject activity = + playerClass.GetStatic("currentActivity"); + bannerView = new AndroidJavaObject(BannerViewClass, activity, new AdListener(listener)); + } + + // Creates a banner view. + public void CreateBannerView(String adUnitId, AdSize adSize, AdPosition position) { + bannerView.Call("create", + new object[3] { adUnitId, GetAdSizeJavaObject(adSize), (int)position }); + } + + // Load an ad. + public void LoadAd(AdRequest request) + { + bannerView.Call("loadAd", GetAdRequestJavaObject(request)); + } + + // Show the banner view on the screen. + public void ShowBannerView() { + bannerView.Call("show"); + } + + // Hide the banner view from the screen. + public void HideBannerView() + { + bannerView.Call("hide"); + } + + public void DestroyBannerView() + { + bannerView.Call("destroy"); + } + + #region JavaObject creators + + private static AndroidJavaObject GetAdSizeJavaObject(AdSize adSize) + { + if (adSize.IsSmartBanner) + { + return new AndroidJavaClass(AdSizeClass) + .GetStatic("SMART_BANNER"); + } + else + { + return new AndroidJavaObject(AdSizeClass, adSize.Width, adSize.Height); + } + } + + private static AndroidJavaObject GetAdRequestJavaObject(AdRequest request) + { + AndroidJavaObject adRequestBuilder = new AndroidJavaObject(AdRequestBuilderClass); + foreach (string keyword in request.Keywords) + { + adRequestBuilder.Call("addKeyword", keyword); + } + foreach (string deviceId in request.TestDevices) + { + if (deviceId == AdRequest.TestDeviceSimulator) { + string emulatorDeviceId = new AndroidJavaClass(AdRequestClass) + .GetStatic("DEVICE_ID_EMULATOR"); + adRequestBuilder.Call("addTestDevice", emulatorDeviceId); + } + else + { + adRequestBuilder.Call("addTestDevice", deviceId); + } + } + if (request.Birthday.HasValue) + { + DateTime birthday = request.Birthday.GetValueOrDefault(); + AndroidJavaObject birthdayObject = new AndroidJavaObject( + DateClass, birthday.Year, birthday.Month, birthday.Day); + adRequestBuilder.Call("setBirthday", birthdayObject); + } + if (request.Gender.HasValue) + { + int? genderCode = null; + switch(request.Gender.GetValueOrDefault()) + { + case Gender.Unknown: + genderCode = new AndroidJavaClass(AdRequestClass) + .GetStatic("GENDER_UNKNOWN"); + break; + case Gender.Male: + genderCode = new AndroidJavaClass(AdRequestClass) + .GetStatic("GENDER_MALE"); + break; + case Gender.Female: + genderCode = new AndroidJavaClass(AdRequestClass) + .GetStatic("GENDER_FEMALE"); + break; + } + if (genderCode.HasValue) + { + adRequestBuilder.Call("setGender", genderCode); + } + } + if (request.TagForChildDirectedTreatment.HasValue) { + adRequestBuilder.Call("tagForChildDirectedTreatment", + request.TagForChildDirectedTreatment.GetValueOrDefault()); + } + AndroidJavaObject bundle = new AndroidJavaObject(BundleClass); + foreach (KeyValuePair entry in request.Extras) + { + bundle.Call("putString", entry.Key, entry.Value); + } + bundle.Call("putInt", "unity", 1); + AndroidJavaObject extras = new AndroidJavaObject(AdMobExtrasClass, bundle); + adRequestBuilder.Call("addNetworkExtras", extras); + + return adRequestBuilder.Call("build"); + } + + #endregion + } +} + +#endif diff --git a/unity/source/Assets/GoogleMobileAds/Platforms/GoogleMobileAdsClientFactory.cs b/unity/source/Assets/GoogleMobileAds/Platforms/GoogleMobileAdsClientFactory.cs new file mode 100644 index 000000000..0dbca5ba1 --- /dev/null +++ b/unity/source/Assets/GoogleMobileAds/Platforms/GoogleMobileAdsClientFactory.cs @@ -0,0 +1,24 @@ +using System; +using UnityEngine; +using GoogleMobileAds.Common; + +namespace GoogleMobileAds +{ + internal class GoogleMobileAdsClientFactory + { + internal static IGoogleMobileAdsBannerClient GetGoogleMobileAdsBannerClient( + IAdListener listener) + { + #if UNITY_EDITOR + // Testing UNITY_EDITOR first because the editor also responds to UNITY_ANROID. + return new GoogleMobileAds.Common.DummyClient(listener); + #elif UNITY_ANDROID + return new GoogleMobileAds.Android.AndroidBannerClient(listener); + #elif UNITY_IPHONE + return new GoogleMobileAds.iOS.IOSBannerClient(listener); + #else + return new GoogleMobileAds.Common.DummyClient(listener); + #endif + } + } +} diff --git a/unity/source/Assets/GoogleMobileAds/Platforms/iOS/MonoPInvokeCallbackAttribute.cs b/unity/source/Assets/GoogleMobileAds/Platforms/iOS/MonoPInvokeCallbackAttribute.cs new file mode 100644 index 000000000..5dcd4b219 --- /dev/null +++ b/unity/source/Assets/GoogleMobileAds/Platforms/iOS/MonoPInvokeCallbackAttribute.cs @@ -0,0 +1,8 @@ +using System; + +// This attribute is used on static functions and it allows Mono's Ahead of Time Compiler +// to generate the code necessary to support native iOS code calling back into C# code. +public sealed class MonoPInvokeCallbackAttribute : Attribute +{ + public MonoPInvokeCallbackAttribute(Type type) {} +} diff --git a/unity/source/Assets/GoogleMobileAds/Platforms/iOS/iOSBannerClient.cs b/unity/source/Assets/GoogleMobileAds/Platforms/iOS/iOSBannerClient.cs new file mode 100644 index 000000000..f42f2863c --- /dev/null +++ b/unity/source/Assets/GoogleMobileAds/Platforms/iOS/iOSBannerClient.cs @@ -0,0 +1,228 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using UnityEngine; +using GoogleMobileAds.Api; +using GoogleMobileAds.Common; + +namespace GoogleMobileAds.iOS +{ + internal class IOSBannerClient : IGoogleMobileAdsBannerClient + { + #region Banner callback types + + private delegate void GADUAdViewDidReceiveAdCallback(IntPtr bannerClient); + private delegate void GADUAdViewDidFailToReceiveAdWithErrorCallback( + IntPtr bannerClient, string error); + private delegate void GADUAdViewWillPresentScreenCallback(IntPtr bannerClient); + private delegate void GADUAdViewWillDismissScreenCallback(IntPtr bannerClient); + private delegate void GADUAdViewDidDismissScreenCallback(IntPtr bannerClient); + private delegate void GADUAdViewWillLeaveApplicationCallback(IntPtr bannerClient); + + #endregion + + #region iOS entry points + + [DllImport("__Internal")] + private static extern IntPtr GADUCreateBannerView(IntPtr bannerClient, + string adUnitId, + int width, + int height, + int positionAtTop); + + [DllImport("__Internal")] + private static extern IntPtr GADUCreateSmartBannerView(IntPtr bannerClient, + string adUnitId, + int positionAtTop); + + [DllImport("__Internal")] + private static extern void GADUSetCallbacks( + IntPtr bannerView, + GADUAdViewDidReceiveAdCallback adReceivedCallback, + GADUAdViewDidFailToReceiveAdWithErrorCallback adFailedCallback, + GADUAdViewWillPresentScreenCallback willPresentCallback, + GADUAdViewWillDismissScreenCallback willDismissCallback, + GADUAdViewDidDismissScreenCallback didDismissCallback, + GADUAdViewWillLeaveApplicationCallback willLeaveCallback); + + [DllImport("__Internal")] + private static extern void GADUHideBannerView(IntPtr bannerView); + + [DllImport("__Internal")] + private static extern void GADUShowBannerView(IntPtr bannerView); + + [DllImport("__Internal")] + private static extern IntPtr GADUCreateRequest(); + + [DllImport("__Internal")] + private static extern void GADUAddTestDevice(IntPtr request, string deviceId); + + [DllImport("__Internal")] + private static extern void GADUAddKeyword(IntPtr request, string keyword); + + [DllImport("__Internal")] + private static extern void GADUSetBirthday(IntPtr request, int year, int month, int day); + + [DllImport("__Internal")] + private static extern void GADUSetGender(IntPtr request, int genderCode); + + [DllImport("__Internal")] + private static extern void GADUTagForChildDirectedTreatment( + IntPtr request, bool childDirectedTreatment); + + [DllImport("__Internal")] + private static extern void GADUSetExtra(IntPtr request, string key, string value); + + [DllImport("__Internal")] + private static extern void GADURequestBannerAd(IntPtr bannerView, IntPtr request); + + [DllImport("__Internal")] + private static extern void GADURelease(IntPtr bannerView); + + #endregion + + private IAdListener listener; + private IntPtr bannerViewPtr; + private static Dictionary bannerClients; + + public IOSBannerClient(IAdListener listener) + { + this.listener = listener; + } + + // This property should be used when setting the bannerViewPtr. + private IntPtr BannerViewPtr + { + get + { + return bannerViewPtr; + } + set + { + GADURelease(bannerViewPtr); + bannerViewPtr = value; + } + } + + #region IGoogleMobileAdsBannerClient implementation + + // Creates a banner view. + public void CreateBannerView(string adUnitId, AdSize adSize, AdPosition position) { + IntPtr bannerClientPtr = (IntPtr) GCHandle.Alloc(this); + + if (adSize.IsSmartBanner) { + BannerViewPtr = GADUCreateSmartBannerView(bannerClientPtr, adUnitId, (int)position); + } + else + { + BannerViewPtr = GADUCreateBannerView( + bannerClientPtr, adUnitId, adSize.Width, adSize.Height, (int)position); + } + GADUSetCallbacks(BannerViewPtr, + AdViewDidReceiveAdCallback, + AdViewDidFailToReceiveAdWithErrorCallback, + AdViewWillPresentScreenCallback, + AdViewWillDismissScreenCallback, + AdViewDidDismissScreenCallback, + AdViewWillLeaveApplicationCallback); + } + + // Load an ad. + public void LoadAd(AdRequest request) + { + IntPtr requestPtr = GADUCreateRequest(); + foreach (string keyword in request.Keywords) + { + GADUAddKeyword(requestPtr, keyword); + } + foreach (string deviceId in request.TestDevices) + { + GADUAddTestDevice(requestPtr, deviceId); + } + if (request.Birthday.HasValue) + { + DateTime birthday = request.Birthday.GetValueOrDefault(); + GADUSetBirthday(requestPtr, birthday.Year, birthday.Month, birthday.Day); + } + if (request.Gender.HasValue) + { + GADUSetGender(requestPtr, (int)request.Gender.GetValueOrDefault()); + } + if (request.TagForChildDirectedTreatment.HasValue) { + GADUTagForChildDirectedTreatment( + requestPtr, request.TagForChildDirectedTreatment.GetValueOrDefault()); + } + foreach (KeyValuePair entry in request.Extras) + { + GADUSetExtra(requestPtr, entry.Key, entry.Value); + } + GADURequestBannerAd(BannerViewPtr, requestPtr); + GADURelease(requestPtr); + } + + // Show the banner view on the screen. + public void ShowBannerView() { + GADUShowBannerView(BannerViewPtr); + } + + // Hide the banner view from the screen. + public void HideBannerView() + { + GADUHideBannerView(BannerViewPtr); + } + + public void DestroyBannerView() + { + GADURelease(BannerViewPtr); + } + + #endregion + + #region Banner callback methods + + [MonoPInvokeCallback(typeof(GADUAdViewDidReceiveAdCallback))] + private static void AdViewDidReceiveAdCallback(IntPtr bannerClient) + { + IntPtrToBannerClient(bannerClient).listener.FireAdLoaded(); + } + + [MonoPInvokeCallback(typeof(GADUAdViewDidFailToReceiveAdWithErrorCallback))] + private static void AdViewDidFailToReceiveAdWithErrorCallback(IntPtr bannerClient, string error) + { + IntPtrToBannerClient(bannerClient).listener.FireAdFailedToLoad(error); + } + + [MonoPInvokeCallback(typeof(GADUAdViewWillPresentScreenCallback))] + private static void AdViewWillPresentScreenCallback(IntPtr bannerClient) + { + IntPtrToBannerClient(bannerClient).listener.FireAdOpened(); + } + + [MonoPInvokeCallback(typeof(GADUAdViewWillDismissScreenCallback))] + private static void AdViewWillDismissScreenCallback(IntPtr bannerClient) + { + IntPtrToBannerClient(bannerClient).listener.FireAdClosing(); + } + + [MonoPInvokeCallback(typeof(GADUAdViewDidDismissScreenCallback))] + private static void AdViewDidDismissScreenCallback(IntPtr bannerClient) + { + IntPtrToBannerClient(bannerClient).listener.FireAdClosed(); + } + + [MonoPInvokeCallback(typeof(GADUAdViewWillLeaveApplicationCallback))] + private static void AdViewWillLeaveApplicationCallback(IntPtr bannerClient) + { + IntPtrToBannerClient(bannerClient).listener.FireAdLeftApplication(); + } + + private static IOSBannerClient IntPtrToBannerClient(IntPtr bannerClient) + { + GCHandle handle = (GCHandle) bannerClient; + return handle.Target as IOSBannerClient; + } + + #endregion + } +} + diff --git a/unity/android/Assets/Plugins/Android/AndroidManifest.xml b/unity/source/Assets/Plugins/Android/AndroidManifest.xml old mode 100755 new mode 100644 similarity index 100% rename from unity/android/Assets/Plugins/Android/AndroidManifest.xml rename to unity/source/Assets/Plugins/Android/AndroidManifest.xml diff --git a/unity/source/Assets/Plugins/iOS/GADUBanner.h b/unity/source/Assets/Plugins/iOS/GADUBanner.h new file mode 100644 index 000000000..576dbe178 --- /dev/null +++ b/unity/source/Assets/Plugins/iOS/GADUBanner.h @@ -0,0 +1,67 @@ +// Copyright 2014 Google Inc. All Rights Reserved. + +#import +#import + +#import "GADUTypes.h" + +@class GADBannerView; +@class GADRequest; + +/// Positions to place a banner. +typedef NS_ENUM(NSUInteger, GADAdPosition) { + kGADAdPositionTopOfScreen = 0, ///< Ad positioned at top of screen. + kGADAdPositionBottomOfScreen = 1 ///< Ad positioned at bottom of screen. +}; + +/// A wrapper around GADBannerView. Includes the ability to create GADBannerView objects, load them +/// with ads, and listen for ad events. +@interface GADUBanner : NSObject + +/// Initializes a GADUBanner with specified width and height, positioned at either the top or +/// bottom of the screen. +- (id)initWithBannerClientReference:(GADUTypeBannerClientRef *)bannerClient + adUnitID:(NSString *)adUnitID + width:(CGFloat)width + height:(CGFloat)height + adPosition:(GADAdPosition)adPosition; + +/// Initializes a full-width GADUBanner, positioned at either the top or bottom of the screen. +- (id)initWithSmartBannerSizeAndBannerClientReference:(GADUTypeBannerClientRef *)bannerClient + adUnitID:(NSString *)adUnitID + adPosition:(GADAdPosition)adPosition; + +/// A reference to the Unity banner client. +@property(nonatomic, assign) GADUTypeBannerClientRef *bannerClient; + +/// A GADBannerView which contains the ad. +@property(nonatomic, retain) GADBannerView *bannerView; + +/// The ad received callback into Unity. +@property(nonatomic, assign) GADUAdViewDidReceiveAdCallback adReceivedCallback; + +/// The ad failed callback into Unity. +@property(nonatomic, assign) GADUAdViewDidFailToReceiveAdWithErrorCallback adFailedCallback; + +/// The will present screen callback into Unity. +@property(nonatomic, assign) GADUAdViewWillPresentScreenCallback willPresentCallback; + +/// The will dismiss screen callback into Unity. +@property(nonatomic, assign) GADUAdViewWillDismissScreenCallback willDismissCallback; + +/// The did dismiss screen callback into Unity. +@property(nonatomic, assign) GADUAdViewDidDismissScreenCallback didDismissCallback; + +/// The will leave application callback into Unity. +@property(nonatomic, assign) GADUAdViewWillLeaveApplicationCallback willLeaveCallback; + +/// Makes an ad request. Additional targeting options can be supplied with a request object. +- (void)loadRequest:(GADRequest *)request; + +/// Makes the GADBannerView hidden on the screen. +- (void)hideBannerView; + +/// Makes the GADBannerView visible on the screen. +- (void)showBannerView; + +@end diff --git a/unity/source/Assets/Plugins/iOS/GADUBanner.m b/unity/source/Assets/Plugins/iOS/GADUBanner.m new file mode 100644 index 000000000..af092e859 --- /dev/null +++ b/unity/source/Assets/Plugins/iOS/GADUBanner.m @@ -0,0 +1,161 @@ +// Copyright 2014 Google Inc. All Rights Reserved. + +#import +#import +#import + +#import "GADUBanner.h" + +#import "GADAdMobExtras.h" +#import "GADAdSize.h" +#import "GADBannerView.h" +#import "GADBannerViewDelegate.h" +#import "UnityAppController.h" + +@interface GADUBanner () + +/// Defines where the ad should be positioned on the screen. +@property(nonatomic, assign) GADAdPosition adPosition; + +@end + +@implementation GADUBanner + ++ (UIViewController *)unityGLViewController { + return ((UnityAppController *)[UIApplication sharedApplication].delegate).rootViewController; +} + +- (id)initWithBannerClientReference:(GADUTypeBannerClientRef *)bannerClient + adUnitID:(NSString *)adUnitID + width:(CGFloat)width + height:(CGFloat)height + adPosition:(GADAdPosition)adPosition { + GADAdSize adSize = GADAdSizeFromCGSize(CGSizeMake(width, height)); + return [self initWithBannerClientReference:bannerClient + adUnitID:adUnitID + adSize:adSize + adPosition:adPosition]; +} + +- (id)initWithSmartBannerSizeAndBannerClientReference:(GADUTypeBannerClientRef *)bannerClient + adUnitID:(NSString *)adUnitID + adPosition:(GADAdPosition)adPosition { + // Choose the correct Smart Banner constant according to orientation. + UIDeviceOrientation currentOrientation = [[UIDevice currentDevice] orientation]; + GADAdSize adSize; + if (UIInterfaceOrientationIsPortrait(currentOrientation)) { + adSize = kGADAdSizeSmartBannerPortrait; + } else { + adSize = kGADAdSizeSmartBannerLandscape; + } + return [self initWithBannerClientReference:bannerClient + adUnitID:adUnitID + adSize:adSize + adPosition:adPosition]; +} + +- (id)initWithBannerClientReference:(GADUTypeBannerClientRef *)bannerClient + adUnitID:(NSString *)adUnitID + adSize:(GADAdSize)size + adPosition:(GADAdPosition)adPosition { + self = [super init]; + if (self) { + self.bannerClient = bannerClient; + self.adPosition = adPosition; + self.bannerView = [[[GADBannerView alloc] initWithAdSize:size] autorelease]; + self.bannerView.adUnitID = adUnitID; + self.bannerView.delegate = self; + UIViewController *unityController = [GADUBanner unityGLViewController]; + self.bannerView.rootViewController = unityController; + [unityController.view addSubview:self.bannerView]; + } + return self; +} + +- (void)loadRequest:(GADRequest *)request { + if (!self.bannerView) { + NSLog(@"GoogleMobileAdsPlugin: BannerView is nil. Aborting ad request. Call CreateBannerView()" + @"before RequestBannerAd()."); + return; + } + [self.bannerView loadRequest:request]; +} + +- (void)hideBannerView { + if (!self.bannerView) { + NSLog(@"GoogleMobileAdsPlugin: BannerView is nil. Call CreateBannerView() before" + @"HideBannerView()."); + return; + } + self.bannerView.hidden = YES; +} + +- (void)showBannerView { + if (!self.bannerView) { + NSLog(@"GoogleMobileAdsPlugin: BannerView is nil. Call CreateBannerView() before" + @"ShowBannerView()."); + return; + } + self.bannerView.hidden = NO; +} + +#pragma mark GADBannerViewDelegate implementation + +- (void)adViewDidReceiveAd:(GADBannerView *)adView { + UIView *unityView = [[GADUBanner unityGLViewController] view]; + CGPoint center; + // Position the GADBannerView. + switch (self.adPosition) { + case kGADAdPositionTopOfScreen: + center = CGPointMake(CGRectGetMidX(unityView.bounds), CGRectGetMidY(adView.bounds)); + break; + case kGADAdPositionBottomOfScreen: + center = CGPointMake(CGRectGetMidX(unityView.bounds), + CGRectGetMaxY(unityView.bounds) - CGRectGetMidY(adView.bounds)); + break; + } + adView.center = center; + if (self.adReceivedCallback) { + self.adReceivedCallback(self.bannerClient); + } +} + +- (void)adView:(GADBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error { + NSString *errorMsg = [NSString + stringWithFormat:@"Failed to receive ad with error: %@", [error localizedFailureReason]]; + self.adFailedCallback(self.bannerClient, [errorMsg cStringUsingEncoding:NSUTF8StringEncoding]); +} + +- (void)adViewWillPresentScreen:(GADBannerView *)adView { + if (self.willPresentCallback) { + self.willPresentCallback(self.bannerClient); + } +} + +- (void)adViewWillDismissScreen:(GADBannerView *)adView { + if (self.willDismissCallback) { + self.willDismissCallback(self.bannerClient); + } +} + +- (void)adViewDidDismissScreen:(GADBannerView *)adView { + if (self.didDismissCallback) { + self.didDismissCallback(self.bannerClient); + } +} + +- (void)adViewWillLeaveApplication:(GADBannerView *)adView { + if (self.willLeaveCallback) { + self.willLeaveCallback(self.bannerClient); + } +} + +#pragma mark Cleanup + +- (void)dealloc { + _bannerView.delegate = nil; + [_bannerView release]; + [super dealloc]; +} + +@end diff --git a/unity/source/Assets/Plugins/iOS/GADUInterface.m b/unity/source/Assets/Plugins/iOS/GADUInterface.m new file mode 100644 index 000000000..ba5f6d534 --- /dev/null +++ b/unity/source/Assets/Plugins/iOS/GADUInterface.m @@ -0,0 +1,135 @@ +// Copyright 2014 Google Inc. All Rights Reserved. + +#import "GADUBanner.h" +#import "GADUObjectCache.h" +#import "GADURequest.h" +#import "GADUTypes.h" + +/// Helper method used to convert C-style strings into NSStrings. +NSString *GADUStringFromUTF8String(const char *bytes) { + if (bytes) { + return @(bytes); + } else { + return @""; + } +} + +/// Creates a GADBannerView with the specified width, height, and position. Returns a reference to +/// the GADUBannerView. +GADUTypeBannerRef GADUCreateBannerView(GADUTypeBannerClientRef *bannerClient, const char *adUnitID, + NSInteger width, NSInteger height, + GADAdPosition adPosition) { + GADUBanner *banner = + [[[GADUBanner alloc] initWithBannerClientReference:bannerClient + adUnitID:GADUStringFromUTF8String(adUnitID) + width:width + height:height + adPosition:adPosition] autorelease]; + GADUObjectCache *cache = [GADUObjectCache sharedInstance]; + [cache.references setObject:banner forKey:[banner gadu_referenceKey]]; + return banner; +} + +/// Creates a full-width GADBannerView in the current orientation and returns a reference to the +/// GADUBannerView. +GADUTypeBannerRef GADUCreateSmartBannerView(GADUTypeBannerClientRef *bannerClient, + const char *adUnitID, GADAdPosition adPosition) { + GADUBanner *banner = [[[GADUBanner alloc] + initWithSmartBannerSizeAndBannerClientReference:bannerClient + adUnitID:GADUStringFromUTF8String(adUnitID) + adPosition:adPosition] autorelease]; + GADUObjectCache *cache = [GADUObjectCache sharedInstance]; + [cache.references setObject:banner forKey:[banner gadu_referenceKey]]; + return banner; +} + +/// Sets the callback methods to be invoked during ad events. +void GADUSetCallbacks(GADUTypeBannerRef banner, GADUAdViewDidReceiveAdCallback adReceivedCallback, + GADUAdViewDidFailToReceiveAdWithErrorCallback adFailedCallback, + GADUAdViewWillPresentScreenCallback willPresentCallback, + GADUAdViewWillDismissScreenCallback willDismissCallback, + GADUAdViewDidDismissScreenCallback didDismissCallback, + GADUAdViewWillLeaveApplicationCallback willLeaveCallback) { + GADUBanner *internalBanner = (GADUBanner *)banner; + internalBanner.adReceivedCallback = adReceivedCallback; + internalBanner.adFailedCallback = adFailedCallback; + internalBanner.willPresentCallback = willPresentCallback; + internalBanner.willDismissCallback = willDismissCallback; + internalBanner.didDismissCallback = didDismissCallback; + internalBanner.willLeaveCallback = willLeaveCallback; +} + +/// Sets the GADBannerView's hidden property to YES. +void GADUHideBannerView(GADUTypeBannerRef banner) { + GADUBanner *internalBanner = (GADUBanner *)banner; + [internalBanner hideBannerView]; +} + +/// Sets the GADBannerView's hidden property to NO. +void GADUShowBannerView(GADUTypeBannerRef banner) { + GADUBanner *internalBanner = (GADUBanner *)banner; + [internalBanner showBannerView]; +} + +/// Creates an empty GADRequest and returns its reference. +GADUTypeRequestRef GADUCreateRequest() { + GADURequest *request = [[[GADURequest alloc] init] autorelease]; + GADUObjectCache *cache = [GADUObjectCache sharedInstance]; + [cache.references setObject:request forKey:[request gadu_referenceKey]]; + return request; +} + +/// Adds a test device to the GADRequest. +void GADUAddTestDevice(GADUTypeRequestRef request, const char *deviceID) { + GADURequest *internalRequest = (GADURequest *)request; + [internalRequest addTestDevice:GADUStringFromUTF8String(deviceID)]; +} + +/// Adds a keyword to the GADRequest. +void GADUAddKeyword(GADUTypeRequestRef request, const char *keyword) { + GADURequest *internalRequest = (GADURequest *)request; + [internalRequest addKeyword:GADUStringFromUTF8String(keyword)]; +} + +/// Sets the user's birthday on the GADRequest. +void GADUSetBirthday(GADUTypeRequestRef request, NSInteger year, NSInteger month, NSInteger day) { + GADURequest *internalRequest = (GADURequest *)request; + [internalRequest setBirthdayWithMonth:month day:day year:year]; +} + +/// Sets the user's gender on the GADRequest. +void GADUSetGender(GADUTypeRequestRef request, NSInteger genderCode) { + GADURequest *internalRequest = (GADURequest *)request; + [internalRequest setGenderWithCode:genderCode]; +} + +/// Tags a GADRequest to specify whether it should be treated as child-directed for purposes of the +/// Children’s Online Privacy Protection Act (COPPA) - +/// http://business.ftc.gov/privacy-and-security/childrens-privacy. +void GADUTagForChildDirectedTreatment(GADUTypeRequestRef request, BOOL childDirectedTreatment) { + GADURequest *internalRequest = (GADURequest *)request; + internalRequest.tagForChildDirectedTreatment = childDirectedTreatment; +} + +/// Sets an extra parameter to be included in the ad request. +void GADUSetExtra(GADUTypeRequestRef request, const char *key, const char *value) { + GADURequest *internalRequest = (GADURequest *)request; + [internalRequest setExtraWithKey:GADUStringFromUTF8String(key) + value:GADUStringFromUTF8String(value)]; +} + +/// Makes an ad request. +void GADURequestBannerAd(GADUTypeBannerRef banner, GADUTypeRequestRef request) { + GADUBanner *internalBanner = (GADUBanner *)banner; + GADURequest *internalRequest = (GADURequest *)request; + [internalBanner loadRequest:[internalRequest request]]; +} + +/// Removes an object from the cache. +void GADURelease(GADUTypeRef ref) { + NSLog(@"Invoking Release"); + if (ref) { + GADUObjectCache *cache = [GADUObjectCache sharedInstance]; + [cache.references removeObjectForKey:[(NSObject *)ref gadu_referenceKey]]; + } +} diff --git a/unity/source/Assets/Plugins/iOS/GADUObjectCache.h b/unity/source/Assets/Plugins/iOS/GADUObjectCache.h new file mode 100644 index 000000000..bceb98592 --- /dev/null +++ b/unity/source/Assets/Plugins/iOS/GADUObjectCache.h @@ -0,0 +1,21 @@ +// Copyright 2014 Google Inc. All Rights Reserved. + +#import + +/// A cache to hold onto objects while Unity is still referencing them. +@interface GADUObjectCache : NSObject + ++ (instancetype)sharedInstance; + +/// References to objects Google Mobile ads objects created from Unity. +@property(nonatomic, strong) NSMutableDictionary *references; + +@end + +@interface NSObject (GADUOwnershipAdditions) + +/// Returns a key used to lookup a Google Mobile Ads object. This method is intended to only be used +/// by Google Mobile Ads objects. +- (NSString *)gadu_referenceKey; + +@end diff --git a/unity/source/Assets/Plugins/iOS/GADUObjectCache.m b/unity/source/Assets/Plugins/iOS/GADUObjectCache.m new file mode 100644 index 000000000..f1a7a48f5 --- /dev/null +++ b/unity/source/Assets/Plugins/iOS/GADUObjectCache.m @@ -0,0 +1,37 @@ +// Copyright 2014 Google Inc. All Rights Reserved. + +#import + +#import "GADUObjectCache.h" + +@implementation GADUObjectCache + ++ (instancetype)sharedInstance { + static GADUObjectCache *sharedInstance; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ sharedInstance = [[self alloc] init]; }); + return sharedInstance; +} + +- (id)init { + self = [super init]; + if (self) { + self.references = [[[NSMutableDictionary alloc] init] autorelease]; + } + return self; +} + +- (void)dealloc { + [_references release]; + [super dealloc]; +} + +@end + +@implementation NSObject (GADUOwnershipAdditions) + +- (NSString *)gadu_referenceKey { + return [NSString stringWithFormat:@"%p", (void *)self]; +} + +@end diff --git a/unity/source/Assets/Plugins/iOS/GADURequest.h b/unity/source/Assets/Plugins/iOS/GADURequest.h new file mode 100644 index 000000000..2db9ab50b --- /dev/null +++ b/unity/source/Assets/Plugins/iOS/GADURequest.h @@ -0,0 +1,61 @@ +// Copyright 2014 Google Inc. All Rights Reserved. + +#import + +#import "GADRequest.h" + +/// Constant to pass to the addTestDevice method to getting test ads on the simulator. +#define GADU_SIMULATOR_ID @"SIMULATOR" + +/// Genders to help deliver more relevant ads. +typedef NS_ENUM(NSInteger, GADUGender) { + kGADUGenderUnknown = 0, ///< Unknown. + kGADUGenderMale = 1, ///< Male. + kGADUGenderFemale = 2 ///< Female. +}; + +// Specifies optional parameters for ad requests. +@interface GADURequest : NSObject + +/// Returns an initialized GADURequest object. +- (id)init; + +/// An array of device identifiers to receive test ads. +@property(nonatomic, retain) NSMutableArray *testDevices; + +/// Words or phrase describing the current activity of the user. +@property(nonatomic, retain) NSMutableArray *keywords; + +/// The user's birthday may be used to deliver more relevant ads. +@property(nonatomic, retain) NSDate *birthday; + +/// The user's gender may be used to deliver more relevant ads. +@property(nonatomic, assign) GADGender *gender; + +/// [Optional] This method allows you to specify whether you would like your app to be treated as +/// child-directed for purposes of the Children’s Online Privacy Protection Act (COPPA) - +/// http://business.ftc.gov/privacy-and-security/childrens-privacy. +@property(nonatomic, assign) BOOL tagForChildDirectedTreatment; + +/// Extra parameters to be sent up in the ad request. +@property(nonatomic, retain) NSMutableDictionary *extras; + +/// Convenience method for adding a single test device. +- (void)addTestDevice:(NSString *)deviceID; + +/// Convenience method for adding a single keyword. +- (void)addKeyword:(NSString *)keyword; + +/// Convenience method for setting the user's birthday. +- (void)setBirthdayWithMonth:(NSInteger)month day:(NSInteger)day year:(NSInteger)year; + +/// Convenience method for setting the user's birthday with a GADUGender. +- (void)setGenderWithCode:(GADUGender)gender; + +/// Convenience method for setting an extra parameters. +- (void)setExtraWithKey:(NSString *)key value:(NSString *)value; + +/// Constructs a GADRequest with the defined targeting values. +- (GADRequest *)request; + +@end diff --git a/unity/source/Assets/Plugins/iOS/GADURequest.m b/unity/source/Assets/Plugins/iOS/GADURequest.m new file mode 100644 index 000000000..3a550069f --- /dev/null +++ b/unity/source/Assets/Plugins/iOS/GADURequest.m @@ -0,0 +1,73 @@ +// Copyright 2014 Google Inc. All Rights Reserved. + +#import + +#import "GADAdMobExtras.h" +#import "GADRequest.h" +#import "GADURequest.h" + +@implementation GADURequest + +- (id)init { + self = [super init]; + if (self) { + self.testDevices = [[[NSMutableArray alloc] init] autorelease]; + self.keywords = [[[NSMutableArray alloc] init] autorelease]; + self.extras = [[[NSMutableDictionary alloc] init] autorelease]; + } + return self; +} + +- (void)addTestDevice:(NSString *)deviceID { + if ([deviceID isEqualToString:GADU_SIMULATOR_ID]) { + [self.testDevices addObject:GAD_SIMULATOR_ID]; + } else { + [self.testDevices addObject:deviceID]; + } +} + +- (void)addKeyword:(NSString *)keyword { + [self.keywords addObject:keyword]; +} + +- (void)setBirthdayWithMonth:(NSInteger)month day:(NSInteger)day year:(NSInteger)year { + NSDateComponents *components = [[[NSDateComponents alloc] init] autorelease]; + components.month = month; + components.day = day; + components.year = year; + NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; + self.birthday = [gregorian dateFromComponents:components]; +} + +- (void)setGenderWithCode:(GADUGender)gender { + switch (gender) { + case kGADUGenderMale: + self.gender = kGADGenderMale; + break; + case kGADUGenderFemale: + self.gender = kGADGenderFemale; + break; + default: + self.gender = kGADGenderUnknown; + } +} + +- (void)setExtraWithKey:(NSString *)key value:(NSString *)value { + [self.extras setValue:value forKey:key]; +} + +- (GADRequest *)request { + GADRequest *request = [GADRequest request]; + request.testDevices = self.testDevices; + request.keywords = self.keywords; + request.birthday = self.birthday; + request.gender = self.gender; + [request tagForChildDirectedTreatment:self.tagForChildDirectedTreatment]; + [self.extras setValue:@"1" forKey:@"unity"]; + GADAdMobExtras *extras = [[[GADAdMobExtras alloc] init] autorelease]; + extras.additionalParameters = self.extras; + [request registerAdNetworkExtras:extras]; + return request; +} + +@end diff --git a/unity/source/Assets/Plugins/iOS/GADUTypes.h b/unity/source/Assets/Plugins/iOS/GADUTypes.h new file mode 100644 index 000000000..5e42d038b --- /dev/null +++ b/unity/source/Assets/Plugins/iOS/GADUTypes.h @@ -0,0 +1,32 @@ +// Copyright 2014 Google Inc. All Rights Reserved. + +/// Base type representing a GADU* pointer. +typedef const void *GADUTypeRef; + +/// Type representing a Unity banner client. +typedef const void *GADUTypeBannerClientRef; + +/// Type representing a GADUBanner. +typedef const void *GADUTypeBannerRef; + +/// Type representing a GADURequest. +typedef const void *GADUTypeRequestRef; + +/// Callback for when an ad request loaded an ad. +typedef void (*GADUAdViewDidReceiveAdCallback)(GADUTypeBannerClientRef *bannerClient); + +/// Callback for when an ad request failed. +typedef void (*GADUAdViewDidFailToReceiveAdWithErrorCallback)(GADUTypeBannerClientRef *bannerClient, + const char *error); + +/// Callback for when a full screen view is about to be presented as a result of an ad click. +typedef void (*GADUAdViewWillPresentScreenCallback)(GADUTypeBannerClientRef *bannerClient); + +/// Callback for when a full screen view is about to be dismissed. +typedef void (*GADUAdViewWillDismissScreenCallback)(GADUTypeBannerClientRef *bannerClient); + +/// Callback for when a full screen view has just been dismissed. +typedef void (*GADUAdViewDidDismissScreenCallback)(GADUTypeBannerClientRef *bannerClient); + +/// Callback for whne an application will background or terminate as a result of an ad click. +typedef void (*GADUAdViewWillLeaveApplicationCallback)(GADUTypeBannerClientRef *bannerClient); diff --git a/unity/android/plugin-library/AndroidManifest.xml b/unity/source/plugin-library/AndroidManifest.xml old mode 100755 new mode 100644 similarity index 100% rename from unity/android/plugin-library/AndroidManifest.xml rename to unity/source/plugin-library/AndroidManifest.xml diff --git a/unity/android/plugin-library/project.properties b/unity/source/plugin-library/project.properties old mode 100755 new mode 100644 similarity index 100% rename from unity/android/plugin-library/project.properties rename to unity/source/plugin-library/project.properties diff --git a/unity/source/plugin-library/src/com/google/unity/ads/Banner.java b/unity/source/plugin-library/src/com/google/unity/ads/Banner.java new file mode 100644 index 000000000..c64172620 --- /dev/null +++ b/unity/source/plugin-library/src/com/google/unity/ads/Banner.java @@ -0,0 +1,175 @@ +// Copyright 2014 Google Inc. All Rights Reserved. + +package com.google.unity.ads; + +import com.google.android.gms.ads.AdListener; +import com.google.android.gms.ads.AdRequest; +import com.google.android.gms.ads.AdSize; +import com.google.android.gms.ads.AdView; + +import android.app.Activity; +import android.graphics.Color; +import android.util.Log; +import android.view.Gravity; +import android.view.View; +import android.widget.FrameLayout; + +/** + * This class represents the native implementation for the Google Mobile Ads Unity plugin. This + * class is used to request Google Mobile ads natively via the Google Mobile Ads library in Google + * Play services. The Google Play services library is a dependency for this plugin. + */ +public class Banner { + /** Banner position constant for the top of the screen. */ + private static final int POSITION_TOP = 0; + + /** Banner position constant for the bottom of the screen. */ + private static final int POSITION_BOTTOM = 1; + + /** The {@link AdView} to display to the user. */ + private AdView adView; + + /** The {@code Activity} that the banner will be displayed in. */ + private Activity activity; + + /** A listener implemented in Unity via {@code AndroidJavaProxy} to receive ad events. */ + private UnityAdListener listener; + + /** + * Creates an instance of {@code Banner}. + * + * @param activity The {@link Activity} that will contain an ad. + * @param listener The {@link UnityAdListener} used to receive synchronous ad events in Unity. + */ + public Banner(Activity activity, UnityAdListener listener) { + this.activity = activity; + this.listener = listener; + } + + /** + * Creates an {@link AdView} to hold banner ads. + * + * @param publisherId Your ad unit ID. + * @param adSize The size of the banner. + * @param positionCode A code indicating where to place the ad. + */ + public void create(final String publisherId, final AdSize adSize, final int positionCode) { + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + adView = new AdView(activity); + // Setting the background color works around an issue where the first ad isn't visible. + adView.setBackgroundColor(Color.TRANSPARENT); + adView.setAdUnitId(publisherId); + adView.setAdSize(adSize); + adView.setAdListener(new AdListener() { + @Override + public void onAdLoaded() { + if (listener != null) { + listener.onAdLoaded(); + } + } + + @Override + public void onAdFailedToLoad(int errorCode) { + if (listener != null) { + listener.onAdFailedToLoad(PluginUtils.getErrorReason(errorCode)); + } + } + + @Override + public void onAdOpened() { + if (listener != null) { + listener.onAdOpened(); + } + } + + @Override + public void onAdClosed() { + if (listener != null) { + listener.onAdClosed(); + } + } + + @Override + public void onAdLeftApplication() { + if (listener != null) { + listener.onAdLeftApplication(); + } + } + }); + FrameLayout.LayoutParams adParams = new FrameLayout.LayoutParams( + FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); + switch(positionCode) { + case POSITION_TOP: + adParams.gravity = Gravity.TOP; + break; + case POSITION_BOTTOM: + adParams.gravity = Gravity.BOTTOM; + break; + } + activity.addContentView(adView, adParams); + } + }); + } + + public void setAdListener(UnityAdListener listener) { + this.listener = listener; + } + + /** + * Loads an ad on a background thread. + * + * @param request The {@link AdRequest} object with targeting parameters. + */ + public void loadAd(final AdRequest request) { + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + Log.d(PluginUtils.LOGTAG, "Calling loadAd() on Android"); + adView.loadAd(request); + } + }); + } + + /** + * Sets the {@link AdView} to be visible. + */ + public void show() { + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + Log.d(PluginUtils.LOGTAG, "Calling show() on Android"); + adView.setVisibility(View.VISIBLE); + adView.resume(); + } + }); + } + + /** + * Sets the {@link AdView} to be gone. + */ + public void hide() { + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + Log.d(PluginUtils.LOGTAG, "Calling hide() on Android"); + adView.setVisibility(View.GONE); + adView.pause(); + } + }); + } + + /** + * Destroys the {@link AdView}. + */ + public void destroy() { + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + Log.d(PluginUtils.LOGTAG, "Calling destroy() on Android"); + adView.destroy(); + } + }); + } +} diff --git a/unity/source/plugin-library/src/com/google/unity/ads/PluginUtils.java b/unity/source/plugin-library/src/com/google/unity/ads/PluginUtils.java new file mode 100644 index 000000000..5baa59e81 --- /dev/null +++ b/unity/source/plugin-library/src/com/google/unity/ads/PluginUtils.java @@ -0,0 +1,37 @@ +// Copyright 2014 Google Inc. All Rights Reserved. + +package com.google.unity.ads; + +import com.google.android.gms.ads.AdRequest; + +import android.util.Log; + +/** + * Utilities for the Google Mobile Ads Unity plugin. + */ +public class PluginUtils { + /** Tag used for logging statements. */ + public static final String LOGTAG = "GoogleMobileAdsUnityPlugin"; + + /** + * Gets a string error reason from an error code. + * + * @param errorCode The error code. + * @return The reason for the error. + */ + public static String getErrorReason(int errorCode) { + switch(errorCode) { + case AdRequest.ERROR_CODE_INTERNAL_ERROR: + return "Internal error"; + case AdRequest.ERROR_CODE_INVALID_REQUEST: + return "Invalid request"; + case AdRequest.ERROR_CODE_NETWORK_ERROR: + return "Network Error"; + case AdRequest.ERROR_CODE_NO_FILL: + return "No fill"; + default: + Log.w(LOGTAG, String.format("Unexpected error code: %s", errorCode)); + return ""; + } + } +} diff --git a/unity/source/plugin-library/src/com/google/unity/ads/UnityAdListener.java b/unity/source/plugin-library/src/com/google/unity/ads/UnityAdListener.java new file mode 100644 index 000000000..c31d1fea6 --- /dev/null +++ b/unity/source/plugin-library/src/com/google/unity/ads/UnityAdListener.java @@ -0,0 +1,15 @@ +// Copyright 2014 Google Inc. All Rights Reserved. + +package com.google.unity.ads; + +/** + * An interface form of {@link UnityAdListener} that can be implemented via + * {@code AndroidJavaProxy} in Unity to receive ad events synchronously. + */ +public interface UnityAdListener { + void onAdLoaded(); + void onAdFailedToLoad(String errorReason); + void onAdOpened(); + void onAdClosed(); + void onAdLeftApplication(); +}