-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release yandex-ads-unity-plugin-0.1.0
- Loading branch information
0 parents
commit ff0ce52
Showing
13 changed files
with
364 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Change Log | ||
|
||
## Version 0.1.0 | ||
|
||
#### Added | ||
* Support for Banner Ads | ||
* Support for Interstitial Ads |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
EULA could be found at: | ||
https://legal.yandex.com/partner_ch/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Yandex Mobile Ads Unity Plugin | ||
|
||
This repository contains Yandex Mobile Ads Unity plugin. This plugin allows Unity developers to easily integrate Yandex Mobile Ads on Android and iOS apps. | ||
|
||
## Documentation | ||
Documentation could be found at the [official website][DOCUMENTATION] | ||
|
||
## License | ||
EULA is available at [EULA website][LICENSE] | ||
|
||
## Quick start | ||
|
||
1. To use Yandex Mobile Ads Unity plugin in your project download folder `mobileads-unity-plugin` | ||
|
||
2. Open your project in the Unity editor | ||
|
||
3. Select `Assets > Import Package > Custom Package` and find the `yandex-mobileads-<version>.unitypackage` file. | ||
|
||
If you are already using [Google resolver] just use `yandex-mobileads-lite-<version>.unitypackage` | ||
|
||
4. Make sure all of the files are selected and click Import. | ||
|
||
5. Add [Metrica Unity plugin](https://appmetrica.yandex.com/doc//mobile-sdk-dg/concepts/unity-plugin-docpage/) to the project. | ||
|
||
6. You can use one of demo scripts in folder `samples` to test plugin. Just add one of this files to your project. | ||
|
||
## Yandex Mobile Ads Mediation | ||
|
||
Third-party networks can be connected to Yandex Mobile Ads Mediation by several steps: | ||
|
||
1. Import `yandex-mobileads-lite-<version>.unitypackage` to your project | ||
|
||
2. Import unity package of the desired third-party network | ||
|
||
3. Set up meditation according to [AdFox documentation](https://tech.yandex.com/mobile-ads/doc/dg/ios/adfox/my-target-adfox-docpage/) | ||
|
||
## Third-party mediation | ||
|
||
### AdMob | ||
|
||
1. Integrate [AdMob](https://developers.google.com/admob/unity/start) | ||
|
||
2. Import package `admob-mobileads-mediation-<version>.unitypackage` from folder `third-party-networks-mediation` | ||
|
||
3. Get the Block ID in the Yandex Partner interface for each Ad Unit created in AdMob. Then set up mediation in [the AdMob web interface](apps.admob.com). | ||
|
||
For more information, please visit [AdMob documentation](https://tech.yandex.com/mobile-ads/doc/dg/android/quick-start/admob-adapter-docpage/#setting) | ||
|
||
### MoPub | ||
|
||
1. Integrate [MoPub](https://developers.mopub.com/docs/unity) | ||
|
||
2. Import package `mopub-mobileads-mediation-<version>.unitypackage` from the folder `third-party-networks-mediation` | ||
|
||
3. Get the Block ID in the Yandex Partner interface for each Ad Unit created in MoPub. Then set up mediation in [the MoPub web interface](app.mopub.com). | ||
|
||
For more information, please visit [MoPub documentation](https://tech.yandex.com/mobile-ads/doc/dg/android/quick-start/mopub-adapter-docpage/) | ||
|
||
## Unity packages | ||
|
||
| Package | Description | | ||
| --- | --- | | ||
| yandex-mobileads | Main Yandex Mobile Ads package | | ||
| yandex-mobileads-lite | Main Yandex Mobile Ads package distributed for using with [Google resolver]| | ||
| mobileads-admob-mediation | AdMob mediation | | ||
| mobileads-facebook-mediation | Facebook mediation | | ||
| mobileads-mytarget-mediation | MyTarget mediation | | ||
| mobileads-startapp-mediation | StartApp mediation | | ||
| admob-mobileads-mediation | Third-party mediation with AdMob | | ||
| mopub-mobileads-mediation| Third-party mediation with MoPub | | ||
|
||
[Google resolver]: https://github.com/googlesamples/unity-jar-resolver | ||
[DOCUMENTATION]: https://tech.yandex.com/mobile-ads/ | ||
[LICENSE]: https://legal.yandex.com/partner_ch/ |
Binary file not shown.
Binary file added
BIN
+895 Bytes
mobileads-mediation/mobileads-facebook-mediation-0.1.0.unitypackage
Binary file not shown.
Binary file added
BIN
+885 Bytes
mobileads-mediation/mobileads-mytarget-mediation-0.1.0.unitypackage
Binary file not shown.
Binary file added
BIN
+884 Bytes
mobileads-mediation/mobileads-startapp-mediation-0.1.0.unitypackage
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* | ||
* This file is a part of the Yandex Advertising Network | ||
* | ||
* Version for Android (C) 2018 YANDEX | ||
* | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at https://legal.yandex.com/partner_ch/ | ||
*/ | ||
|
||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using YandexMobileAds; | ||
using YandexMobileAds.Base; | ||
|
||
public class YandexMobileAdsBannerDemoScript : MonoBehaviour | ||
{ | ||
private readonly float ButtonWidth = 0.8f * Screen.width; | ||
private readonly float ButtonHeight = 0.1f * Screen.height; | ||
private readonly float ColumnPosition = 0.1f * Screen.width; | ||
private readonly float RowFirstPosition = 0.05f * Screen.height; | ||
private readonly float RowSecondPosition = 0.225f * Screen.height; | ||
private readonly int FontSize = (int) (0.035f * Screen.width); | ||
|
||
private Banner banner; | ||
|
||
void Start() { | ||
Screen.orientation = ScreenOrientation.Portrait; | ||
} | ||
|
||
public void OnGUI() | ||
{ | ||
GUIStyle style = new GUIStyle(); | ||
|
||
GUI.skin.button.fontSize = FontSize; | ||
|
||
Rect requestBannerRect = this.CreateButton(ColumnPosition, RowFirstPosition); | ||
if (GUI.Button(requestBannerRect, "Request\nBanner")) | ||
{ | ||
this.RequestBanner(); | ||
} | ||
|
||
Rect destroyBannerRect = this.CreateButton(ColumnPosition, RowSecondPosition); | ||
if (GUI.Button(destroyBannerRect, "Destroy\nBanner")) | ||
{ | ||
this.banner.Destroy(); | ||
} | ||
} | ||
|
||
private void RequestBanner() | ||
{ | ||
// Replace demo R-M-DEMO-320x50 with actual Block ID | ||
// Following demo Block IDs may be used for testing: | ||
// R-M-DEMO-320x50 | ||
// R-M-DEMO-320x50-app_install | ||
// R-M-DEMO-728x90 | ||
// R-M-DEMO-320x100-context | ||
// R-M-DEMO-300x250 | ||
// R-M-DEMO-300x250-context | ||
// R-M-DEMO-300x300-context | ||
string adUnitId = "R-M-DEMO-320x50"; | ||
|
||
if (this.banner != null) | ||
{ | ||
this.banner.Destroy(); | ||
} | ||
|
||
this.banner = new Banner(adUnitId, AdSize.BANNER_320x50, AdPosition.BottomCenter); | ||
|
||
this.banner.OnAdLoaded += this.HandleAdLoaded; | ||
this.banner.OnAdFailedToLoad += this.HandleAdFailedToLoad; | ||
this.banner.OnAdOpened += this.HandleAdOpened; | ||
this.banner.OnAdClosed += this.HandleAdClosed; | ||
this.banner.OnAdLeftApplication += this.HandleAdLeftApplication; | ||
|
||
this.banner.LoadAd(this.CreateAdRequest()); | ||
} | ||
|
||
private Rect CreateButton(float positionX, float positionY) | ||
{ | ||
return new Rect( | ||
positionX, | ||
positionY, | ||
ButtonWidth, | ||
ButtonHeight); | ||
} | ||
|
||
private AdRequest CreateAdRequest() | ||
{ | ||
return new AdRequest.Builder().Build(); | ||
} | ||
|
||
#region Banner callback handlers | ||
|
||
public void HandleAdLoaded(object sender, EventArgs args) | ||
{ | ||
MonoBehaviour.print("HandleAdLoaded event received"); | ||
this.banner.Show(); | ||
} | ||
|
||
public void HandleAdFailedToLoad(object sender, AdFailureEventArgs args) | ||
{ | ||
MonoBehaviour.print("HandleAdFailedToLoad event received with message: " + args.Message); | ||
} | ||
|
||
public void HandleAdOpened(object sender, EventArgs args) | ||
{ | ||
MonoBehaviour.print("HandleAdOpened event received"); | ||
} | ||
|
||
public void HandleAdClosed(object sender, EventArgs args) | ||
{ | ||
MonoBehaviour.print("HandleAdClosed event received"); | ||
} | ||
|
||
public void HandleAdLeftApplication(object sender, EventArgs args) | ||
{ | ||
MonoBehaviour.print("HandleAdLeftApplication event received"); | ||
} | ||
|
||
#endregion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
/* | ||
* This file is a part of the Yandex Advertising Network | ||
* | ||
* Version for Android (C) 2018 YANDEX | ||
* | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at https://legal.yandex.com/partner_ch/ | ||
*/ | ||
|
||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using YandexMobileAds; | ||
using YandexMobileAds.Base; | ||
|
||
public class YandexMobileAdsInterstitialDemoScript : MonoBehaviour | ||
{ | ||
private readonly float ButtonWidth = 0.8f * Screen.width; | ||
private readonly float ButtonHeight = 0.1f * Screen.height; | ||
private readonly float ColumnPosition = 0.1f * Screen.width; | ||
private readonly float RowFirstPosition = 0.05f * Screen.height; | ||
private readonly float RowSecondPosition = 0.225f * Screen.height; | ||
private readonly float RowThirdPosition = 0.4f * Screen.height; | ||
private readonly int FontSize = (int) (0.035f * Screen.width); | ||
|
||
private Interstitial interstitial; | ||
|
||
void Start() { | ||
Screen.orientation = ScreenOrientation.Portrait; | ||
} | ||
|
||
public void OnGUI() | ||
{ | ||
GUIStyle style = new GUIStyle(); | ||
|
||
GUI.skin.button.fontSize = FontSize; | ||
|
||
Rect requestInterstitialRect = this.CreateButton(ColumnPosition, RowFirstPosition); | ||
if (GUI.Button(requestInterstitialRect, "Request\nInterstitial")) | ||
{ | ||
this.RequestInterstitial(); | ||
} | ||
|
||
Rect showInterstitialRect = this.CreateButton(ColumnPosition, RowSecondPosition); | ||
if (GUI.Button(showInterstitialRect, "Show\nInterstitial")) | ||
{ | ||
this.ShowInterstitial(); | ||
} | ||
|
||
Rect destroyInterstitialRect = this.CreateButton(ColumnPosition, RowThirdPosition); | ||
if (GUI.Button(destroyInterstitialRect, "Destroy\nInterstitial")) | ||
{ | ||
this.interstitial.Destroy(); | ||
} | ||
} | ||
|
||
private void RequestInterstitial() | ||
{ | ||
// Replace demo R-M-DEMO-240x400-context with actual Block ID | ||
// Following demo Block IDs may be used for testing: | ||
// R-M-DEMO-240x400-context | ||
// R-M-DEMO-400x240-context | ||
// R-M-DEMO-320x480 | ||
// R-M-DEMO-480x320 | ||
string adUnitId = "R-M-DEMO-240x400-context"; | ||
|
||
if (this.interstitial != null) | ||
{ | ||
this.interstitial.Destroy(); | ||
} | ||
|
||
this.interstitial = new Interstitial(adUnitId); | ||
|
||
this.interstitial.OnInterstitialLoaded += this.HandleInterstitialLoaded; | ||
this.interstitial.OnInterstitialFailedToLoad += this.HandleInterstitialFailedToLoad; | ||
this.interstitial.OnInterstitialOpened += this.HandleInterstitialOpened; | ||
this.interstitial.OnInterstitialClosed += this.HandleInterstitialClosed; | ||
this.interstitial.OnInterstitialLeftApplication += this.HandleInterstitialLeftApplication; | ||
this.interstitial.OnInterstitialShown += this.HandleInterstitialShown; | ||
this.interstitial.OnInterstitialFailedToShow += this.HandleInterstitialFailedToShow; | ||
this.interstitial.OnInterstitialDismissed += this.HandleInterstitialDismissed; | ||
|
||
this.interstitial.LoadAd(this.CreateAdRequest()); | ||
} | ||
|
||
private Rect CreateButton(float positionX, float positionY) | ||
{ | ||
return new Rect( | ||
positionX, | ||
positionY, | ||
ButtonWidth, | ||
ButtonHeight); | ||
} | ||
|
||
private void ShowInterstitial() | ||
{ | ||
if (this.interstitial.IsLoaded()) | ||
{ | ||
this.interstitial.Show(); | ||
} | ||
else | ||
{ | ||
MonoBehaviour.print("Interstitial is not ready yet"); | ||
} | ||
} | ||
|
||
private AdRequest CreateAdRequest() | ||
{ | ||
return new AdRequest.Builder().Build(); | ||
} | ||
|
||
#region Interstitial callback handlers | ||
|
||
public void HandleInterstitialLoaded(object sender, EventArgs args) | ||
{ | ||
MonoBehaviour.print("HandleInterstitialLoaded event received"); | ||
} | ||
|
||
public void HandleInterstitialFailedToLoad(object sender, AdFailureEventArgs args) | ||
{ | ||
MonoBehaviour.print( | ||
"HandleInterstitialFailedToLoad event received with message: " + args.Message); | ||
} | ||
|
||
public void HandleInterstitialOpened(object sender, EventArgs args) | ||
{ | ||
MonoBehaviour.print("HandleInterstitialOpened event received"); | ||
} | ||
|
||
public void HandleInterstitialClosed(object sender, EventArgs args) | ||
{ | ||
MonoBehaviour.print("HandleInterstitialClosed event received"); | ||
} | ||
|
||
public void HandleInterstitialLeftApplication(object sender, EventArgs args) | ||
{ | ||
MonoBehaviour.print("HandleInterstitialLeftApplication event received"); | ||
} | ||
|
||
public void HandleInterstitialShown(object sender, EventArgs args) | ||
{ | ||
MonoBehaviour.print("HandleInterstitialShown event received"); | ||
} | ||
|
||
public void HandleInterstitialFailedToShow(object sender, AdFailureEventArgs args) | ||
{ | ||
MonoBehaviour.print( | ||
"HandleInterstitialFailedToShow event received with message: " + args.Message); | ||
} | ||
|
||
public void HandleInterstitialDismissed(object sender, EventArgs args) | ||
{ | ||
MonoBehaviour.print("HandleInterstitialDismissed event received"); | ||
} | ||
|
||
#endregion | ||
} |
Binary file added
BIN
+7.81 KB
third-party-networks-mediation/admob-mobileads-mediation-0.1.0.unitypackage
Binary file not shown.
Binary file added
BIN
+7.74 KB
third-party-networks-mediation/mopub-mobileads-mediation-0.1.0.unitypackage
Binary file not shown.