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
NativeOverlayOptions.cs
1using System;
2using GoogleMobileAds.Api;
3using UnityEngine;
4
5namespace SCG.SpaceAdMobile
6{
10 [Serializable]
12 {
16 [Tooltip("If enabled, the NativeOverlay ad will be hidden automatically when the parent script or GameObject is disabled.")]
17 public bool HideOnDisable;
18
20 [Tooltip("The position on the screen where the native overlay ad should be displayed.")]
22
24 [Tooltip("Options for the native ad.")]
26 {
27 AdChoicesPlacement = AdChoicesPlacement.TopRightCorner,
28 MediaAspectRatio = MediaAspectRatio.Any
29 };
30
31 [Tooltip("The background color for the ad's main area.")]
32 public Color MainBackgroundColor = Color.red;
33
35 [Tooltip("Text style options for the ad template.")]
37
38 [SerializeField]
39 [Tooltip("The type of native template to be used for the ad.")]
40 private NativeTemplateType nativeTemplateType = NativeTemplateType.Small;
41
43 [Tooltip("Indicates if the default ad size should be used.")]
44 public bool DefaultAdSize = true;
45#if UNITY_EDITOR
46 [Editor.ShowIf(nameof(DefaultAdSize), invert: true)]
47#endif
49 [Tooltip("The size of the banner ad when not using the default size.")]
51
52 #region Texts Custom
53 [Space(15)]
54
56 [Tooltip("Allows customization of the primary text in the ad.")]
58#if UNITY_EDITOR
59 [Editor.ShowIf(nameof(CustomizablePrimaryText))]
60#endif
62 [Tooltip("The style options for the primary text when customization is enabled.")]
64
66 [Tooltip("Allows customization of the secondary text in the ad.")]
68#if UNITY_EDITOR
69 [Editor.ShowIf(nameof(CustomizableSecondaryText))]
70#endif
72 [Tooltip("The style options for the secondary text when customization is enabled.")]
74
76 [Tooltip("Allows customization of the tertiary text in the ad.")]
78#if UNITY_EDITOR
79 [Editor.ShowIf(nameof(CustomizableTertiaryText))]
80#endif
82 [Tooltip("The style options for the tertiary text when customization is enabled.")]
84 #endregion
85
91 public static implicit operator NativeAdOptions(NativeOverlayOptions nativeOverlayOptions)
92 => nativeOverlayOptions?.NativeAdOptions;
93
98 public string GetNativeTemplateId() =>
99 nativeTemplateType switch
100 {
101 NativeTemplateType.Small => NativeTemplateId.Small,
102 NativeTemplateType.Medium => NativeTemplateId.Medium,
103 _ => throw new ArgumentOutOfRangeException()
104 };
105 }
106
110 [Serializable]
112 {
113 [SerializeField]
114 private Color backgroundColor = Color.green;
115 [SerializeField]
116 private Color textColor = Color.white;
117 [SerializeField]
118 private int fontSize = 9;
119 [SerializeField]
120 private NativeTemplateFontStyle style = NativeTemplateFontStyle.Bold;
121
127 public static implicit operator NativeTemplateTextStyle(NativeTemplateTextStyleOptions styleOptions)
128 {
129 if (styleOptions == null)
130 return null;
131
132 return new NativeTemplateTextStyle
133 {
134 BackgroundColor = styleOptions.backgroundColor,
135 TextColor = styleOptions.textColor,
136 FontSize = styleOptions.fontSize,
137 Style = styleOptions.style
138 };
139 }
140 }
141
146 {
147 [Tooltip("Represents a small-sized template for native ads.")]
148 Small = 0,
149 [Tooltip("Represents a medium-sized template for native ads.")]
150 Medium = 1
151 }
152}
Represents a configurable banner size for ads, allowing for predefined or custom dimensions.
Definition BannerSize.cs:12
NativeTemplateTextStyleOptions PrimaryText
The style options for the primary text when customization is enabled.
bool DefaultAdSize
Indicates if the default ad size should be used.
NativeTemplateTextStyleOptions TemplateTextStyle
Text style options for the ad template.
string GetNativeTemplateId()
Retrieves the identifier of the native ad template based on the selected template type,...
bool CustomizablePrimaryText
Allows customization of the primary text in the ad.
NativeTemplateTextStyleOptions TertiaryText
The style options for the tertiary text when customization is enabled.
bool CustomizableTertiaryText
Allows customization of the tertiary text in the ad.
Color MainBackgroundColor
The background color for the ad's main area.
bool CustomizableSecondaryText
Allows customization of the secondary text in the ad.
AdPosition AdPosition
The position on the screen where the native overlay ad should be displayed.
NativeAdOptions NativeAdOptions
Options for the native ad.
BannerSize AdSize
The size of the banner ad when not using the default size.
NativeTemplateTextStyleOptions SecondaryText
The style options for the secondary text when customization is enabled.
bool HideOnDisable
Flag indicating whether the NativeOverlay ad should be hidden automatically when the script or GameOb...
Represents the configuration options for native overlay ads, including style, position,...
Represents the extended styling options for native ad text, including background color,...
NativeTemplateType
Represents the different template types available for rendering native ads, such as small and medium.