Yandex Mobile Ads
Loading...
Searching...
No Matches
BannerAdSize.cs
Go to the documentation of this file.
1/*
2 * This file is a part of the Yandex Advertising Network
3 *
4 * Version for Unity (C) 2023 YANDEX
5 *
6 * You may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at https://legal.yandex.com/partner_ch/
8 */
9
10using YandexMobileAds.Common;
11using YandexMobileAds.Platforms;
12
14{
18 public enum BannerAdSizeType
19 {
21 Fixed,
23 Inline,
25 Sticky
26 }
27
31 public class BannerAdSize
32 {
33 private const int NotSpecified = -1;
34
38 public int Width
39 {
40 get
41 {
42 return _client.GetWidth();
43 }
44 private set { }
45 }
46
50 public int Height
51 {
52 get
53 {
54 return _client.GetHeight();
55 }
56 private set { }
57 }
58
62 public BannerAdSizeType AdSizeType { get; private set; }
63
64 private readonly IBannerAdSizeClient _client;
65
66 private BannerAdSize(int width, int height, BannerAdSizeType bannerAdSizeType)
67 {
68 AdSizeType = bannerAdSizeType;
69 _client = YandexMobileAdsClientFactory.BuildBannerAdSizeClient(width, height, bannerAdSizeType);
70 }
71
85 public static BannerAdSize FixedSize(int width, int height)
86 {
87 return new BannerAdSize(width, height, BannerAdSizeType.Fixed);
88 }
89
98 public static BannerAdSize StickySize(int width)
99 {
100 return new BannerAdSize(width, NotSpecified, BannerAdSizeType.Sticky);
101 }
102
112 public static BannerAdSize InlineSize(int width, int maxHeight)
113 {
114 return new BannerAdSize(width, maxHeight, BannerAdSizeType.Inline);
115 }
116
117 internal IBannerAdSizeClient GetClient()
118 {
119 return _client;
120 }
121 }
122}
This class is responsible for the banner size.
static BannerAdSize StickySize(int width)
Creates an object of the BannerAdSize class with the specified maximum width of a sticky banner.
static BannerAdSize InlineSize(int width, int maxHeight)
Creates an object of the BannerAdSize class with the specified maximum height and width of the banner...
BannerAdSizeType AdSizeType
Banner size type.
int Width
The calculated width of the banner.
int Height
The calculated height of the banner.
static BannerAdSize FixedSize(int width, int height)
Creates an object of the BannerAdSizeclass with the specified width and height of the banner.
BannerAdSizeType
Banner size type.
@ Inline
with the specified maximum height and width of the banner
@ Fixed
with specified height and width of the banner
@ Sticky
with the specified maximum width of a sticky banner