Space Ad Mobile 9.5.1
Space Ad Mobile makes ads easy to add into your mobile game: one unified workflow for LevelPlay, AdMob, Yandex.Ads across banners, interstitials and rewarded.
Loading...
Searching...
No Matches
LevelPlayBannerPosition.cs
1using System;
2using UnityEngine;
3using LPBannerPosition = Unity.Services.LevelPlay.LevelPlayBannerPosition;
4
5namespace SCG.SpaceAdMobile
6{
10 [Serializable]
11 public sealed class LevelPlayBannerPosition
12 {
17 [Tooltip("The predefined banner location to use.")]
19
24#if UNITY_EDITOR
25 [Editor.EnableIf(nameof(BannerPosition), BannerPosition.Custom)]
26#endif
27 [Tooltip("Custom on-screen position used when BannerPosition is Custom.")]
28 public Vector2 CustomPosition;
29
35 public static implicit operator LPBannerPosition(LevelPlayBannerPosition @this) =>
36 @this == null
37 ? LPBannerPosition.BottomCenter
38 : @this.BannerPosition switch
39 {
40 BannerPosition.TopLeft => LPBannerPosition.TopLeft,
41 BannerPosition.TopCenter => LPBannerPosition.TopCenter,
42 BannerPosition.TopRight => LPBannerPosition.TopRight,
43 BannerPosition.CenterLeft => LPBannerPosition.CenterLeft,
44 BannerPosition.Center => LPBannerPosition.Center,
45 BannerPosition.CenterRight => LPBannerPosition.CenterRight,
46 BannerPosition.BottomLeft => LPBannerPosition.BottomLeft,
47 BannerPosition.BottomCenter => LPBannerPosition.BottomCenter,
48 BannerPosition.BottomRight => LPBannerPosition.BottomRight,
49 BannerPosition.Custom => new LPBannerPosition(@this.CustomPosition),
50 _ => throw new ArgumentOutOfRangeException()
51 };
52
57 public static implicit operator LevelPlayBannerPosition(int value) => new((BannerPosition)value);
58
64 public static implicit operator int(LevelPlayBannerPosition @this) =>
65 @this == null
66 ? (int)BannerPosition.BottomCenter
67 : (int)@this.BannerPosition;
68
73
79 public LevelPlayBannerPosition(Vector2 position) : this(BannerPosition.Custom) { CustomPosition = position; }
80
85 public LevelPlayBannerPosition(BannerPosition position) { BannerPosition = position; }
86
87 #region Level Play Bridge
88
92 public static readonly LevelPlayBannerPosition TopLeft = new(BannerPosition.TopLeft);
93
97 public static readonly LevelPlayBannerPosition TopCenter = new(BannerPosition.TopCenter);
98
102 public static readonly LevelPlayBannerPosition TopRight = new(BannerPosition.TopRight);
103
107 public static readonly LevelPlayBannerPosition CenterLeft = new(BannerPosition.CenterLeft);
108
112 public static readonly LevelPlayBannerPosition Center = new(BannerPosition.Center);
113
117 public static readonly LevelPlayBannerPosition CenterRight = new(BannerPosition.CenterRight);
118
122 public static readonly LevelPlayBannerPosition BottomLeft = new(BannerPosition.BottomLeft);
123
127 public static readonly LevelPlayBannerPosition BottomCenter = new(BannerPosition.BottomCenter);
128
132 public static readonly LevelPlayBannerPosition BottomRight = new(BannerPosition.BottomRight);
133
134 #endregion
135 }
136
140 public enum BannerPosition
141 {
142 TopLeft,
143 TopCenter,
144 TopRight,
145 CenterLeft,
146 Center,
147 CenterRight,
148 BottomLeft,
149 BottomCenter,
150 BottomRight,
151 Custom
152 }
153}
static readonly LevelPlayBannerPosition Center
The banner position at the center of the screen.
static readonly LevelPlayBannerPosition BottomRight
The banner position at the bottom-right corner of the screen.
static readonly LevelPlayBannerPosition BottomLeft
The banner position at the bottom-left corner of the screen.
static readonly LevelPlayBannerPosition TopCenter
The banner position at the top-center of the screen.
static readonly LevelPlayBannerPosition TopRight
The banner position at the top-right corner of the screen.
static readonly LevelPlayBannerPosition CenterLeft
The banner position at the center-left side of the screen.
static readonly LevelPlayBannerPosition BottomCenter
The banner position at the bottom-center of the screen.
LevelPlayBannerPosition(Vector2 position)
Creates a banner position with BannerPosition.Custom using the provided custom screen coordinates.
Vector2 CustomPosition
Custom on-screen position used when BannerPosition is BannerPosition.Custom. The value is passed thro...
BannerPosition BannerPosition
The predefined banner location to use. Set to BannerPosition.Custom to place the banner at CustomPosi...
LevelPlayBannerPosition(BannerPosition position)
Creates a banner position using one of the predefined positions.
LevelPlayBannerPosition()
Creates a banner position defaulting to BannerPosition.BottomCenter.
static readonly LevelPlayBannerPosition TopLeft
The banner position at the top-left corner of the screen.
static readonly LevelPlayBannerPosition CenterRight
The banner position at the center-right side of the screen.
BannerPosition
Predefined banner anchor positions used by LevelPlayBannerPosition.