File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
samples/HelloWorld/Assets/Snippets Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -133,5 +133,20 @@ private void HandleAppEventExample(Renderer renderer)
133
133
} ;
134
134
// [END handle_app_event_example]
135
135
}
136
+
137
+ private void CreateAnchoredAdaptiveBannerView ( )
138
+ {
139
+ // [START create_anchored_adaptive_banner_view]
140
+ // Get the device safe width in density-independent pixels.
141
+ int deviceWidth = MobileAds . Utils . GetDeviceSafeWidth ( ) ;
142
+
143
+ // Define the anchored adaptive ad size.
144
+ AdSize adaptiveSize =
145
+ AdSize . GetCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth ( deviceWidth ) ;
146
+
147
+ // Create an anchored adaptive banner view.
148
+ bannerView = new AdManagerBannerView ( AD_UNIT_ID , adaptiveSize , AdPosition . Bottom ) ;
149
+ // [END create_anchored_adaptive_banner_view]
150
+ }
136
151
}
137
152
}
Original file line number Diff line number Diff line change @@ -15,6 +15,15 @@ internal class BannerViewSnippets
15
15
#else
16
16
private const string AD_UNIT_ID = "unused" ;
17
17
#endif
18
+
19
+ #if UNITY_ANDROID
20
+ private const string ANCHORED_ADAPTIVE_AD_UNIT_ID = "ca-app-pub-3940256099942544/9214589741" ;
21
+ #elif UNITY_IPHONE
22
+ private const string ANCHORED_ADAPTIVE_AD_UNIT_ID = "ca-app-pub-3940256099942544/2435281174" ;
23
+ #else
24
+ private const string ANCHORED_ADAPTIVE_AD_UNIT_ID = "unused" ;
25
+ #endif
26
+
18
27
BannerView bannerView ;
19
28
20
29
private void CreateBannerView ( )
@@ -112,5 +121,20 @@ private void DestroyBannerView()
112
121
}
113
122
// [END destroy_banner_view]
114
123
}
124
+
125
+ private void CreateAnchoredAdaptiveBannerView ( )
126
+ {
127
+ // [START create_anchored_adaptive_banner_view]
128
+ // Get the device safe width in density-independent pixels.
129
+ int deviceWidth = MobileAds . Utils . GetDeviceSafeWidth ( ) ;
130
+
131
+ // Define the anchored adaptive ad size.
132
+ AdSize adaptiveSize =
133
+ AdSize . GetCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth ( deviceWidth ) ;
134
+
135
+ // Create an anchored adaptive banner view.
136
+ bannerView = new BannerView ( ANCHORED_ADAPTIVE_AD_UNIT_ID , adaptiveSize , AdPosition . Bottom ) ;
137
+ // [END create_anchored_adaptive_banner_view]
138
+ }
115
139
}
116
140
}
You can’t perform that action at this time.
0 commit comments