Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions samples/HelloWorld/Assets/Snippets/AdManagerBannerViewSnippets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,20 @@ private void HandleAppEventExample(Renderer renderer)
};
// [END handle_app_event_example]
}

private void CreateAnchoredAdaptiveBannerView()
{
// [START create_anchored_adaptive_banner_view]
// Get the device safe width in density-independent pixels.
int deviceWidth = MobileAds.Utils.GetDeviceSafeWidth();

// Define the anchored adaptive ad size.
AdSize adaptiveSize =
AdSize.GetCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(deviceWidth);

// Create an anchored adaptive banner view.
adManagerBannerView = new AdManagerBannerView(AD_UNIT_ID, adaptiveSize, AdPosition.Bottom);
// [END create_anchored_adaptive_banner_view]
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions samples/HelloWorld/Assets/Snippets/BannerViewSnippets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ internal class BannerViewSnippets
#else
private const string AD_UNIT_ID = "unused";
#endif

#if UNITY_ANDROID
private const string ANCHORED_ADAPTIVE_AD_UNIT_ID = "ca-app-pub-3940256099942544/9214589741";
#elif UNITY_IPHONE
private const string ANCHORED_ADAPTIVE_AD_UNIT_ID = "ca-app-pub-3940256099942544/2435281174";
#else
private const string ANCHORED_ADAPTIVE_AD_UNIT_ID = "unused";
#endif

BannerView bannerView;

private void CreateBannerView()
Expand Down Expand Up @@ -112,5 +121,20 @@ private void DestroyBannerView()
}
// [END destroy_banner_view]
}

private void CreateAnchoredAdaptiveBannerView()
{
// [START create_anchored_adaptive_banner_view]
// Get the device safe width in density-independent pixels.
int deviceWidth = MobileAds.Utils.GetDeviceSafeWidth();

// Define the anchored adaptive ad size.
AdSize adaptiveSize =
AdSize.GetCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(deviceWidth);

// Create an anchored adaptive banner view.
bannerView = new BannerView(ANCHORED_ADAPTIVE_AD_UNIT_ID, adaptiveSize, AdPosition.Bottom);
// [END create_anchored_adaptive_banner_view]
}
}
}
2 changes: 2 additions & 0 deletions samples/HelloWorld/Assets/Snippets/BannerViewSnippets.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.