From 1bf5bedded084d5ebed2ae300fa60c09641e40a4 Mon Sep 17 00:00:00 2001 From: DucNV Date: Mon, 2 Dec 2024 15:07:43 +0700 Subject: [PATCH] - update native overlay Co-Authored-By: VirtueSky <126542083+VirtueSky@users.noreply.github.com> --- .../Runtime/Admob/AdmobAdClient.cs | 1 + .../AdmobNativeOverlayVariable.cs | 37 +++++++++++-------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/VirtueSky/Advertising/Runtime/Admob/AdmobAdClient.cs b/VirtueSky/Advertising/Runtime/Admob/AdmobAdClient.cs index 73f51e6e..6d9f5e95 100644 --- a/VirtueSky/Advertising/Runtime/Admob/AdmobAdClient.cs +++ b/VirtueSky/Advertising/Runtime/Admob/AdmobAdClient.cs @@ -35,6 +35,7 @@ public override void Initialize() adSetting.AdmobRewardVariable.Init(); adSetting.AdmobRewardInterVariable.Init(); adSetting.AdmobAppOpenVariable.Init(); + adSetting.AdmobNativeOverlayVariable.Init(); RegisterAppStateChange(); LoadInterstitial(); diff --git a/VirtueSky/Advertising/Runtime/Admob/AdmodUnitVariable/AdmobNativeOverlayVariable.cs b/VirtueSky/Advertising/Runtime/Admob/AdmodUnitVariable/AdmobNativeOverlayVariable.cs index 65bec8a7..7a606502 100644 --- a/VirtueSky/Advertising/Runtime/Admob/AdmodUnitVariable/AdmobNativeOverlayVariable.cs +++ b/VirtueSky/Advertising/Runtime/Admob/AdmodUnitVariable/AdmobNativeOverlayVariable.cs @@ -90,8 +90,10 @@ public override bool IsReady() protected override void ShowImpl() { +#if VIRTUESKY_ADS && VIRTUESKY_ADMOB if (_nativeOverlayAd != null) _nativeOverlayAd.Show(); +#endif } /// @@ -99,11 +101,13 @@ protected override void ShowImpl() /// public override void Destroy() { +#if VIRTUESKY_ADS && VIRTUESKY_ADMOB if (_nativeOverlayAd != null) { _nativeOverlayAd.Destroy(); _nativeOverlayAd = null; } +#endif } /// @@ -111,24 +115,11 @@ public override void Destroy() /// public void Hide() { +#if VIRTUESKY_ADS && VIRTUESKY_ADMOB if (_nativeOverlayAd != null) _nativeOverlayAd.Hide(); +#endif } - public NativeTemplateStyle Style() - { - return new NativeTemplateStyle - { - TemplateId = nativeTemplate.ToString().ToLower(), - // MainBackgroundColor = Color.red, - // CallToActionText = new NativeTemplateTextStyle - // { - // BackgroundColor = Color.green, - // TextColor = Color.white, - // FontSize = 9, - // Style = nativeTemplateFontStyle - // } - }; - } /// /// Render native overlay ads default @@ -177,6 +168,22 @@ public void RenderAd(RectTransform uiElement, Canvas canvas) } #if VIRTUESKY_ADS && VIRTUESKY_ADMOB + public NativeTemplateStyle Style() + { + return new NativeTemplateStyle + { + TemplateId = nativeTemplate.ToString().ToLower(), + // MainBackgroundColor = Color.red, + // CallToActionText = new NativeTemplateTextStyle + // { + // BackgroundColor = Color.green, + // TextColor = Color.white, + // FontSize = 9, + // Style = nativeTemplateFontStyle + // } + }; + } + AdPosition ConvertPosition() { return adsPosition switch