com.amanotes.gdk 0.2.45 → 0.2.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/Editor/AmaGDKEditor.cs +325 -120
  3. package/Editor/MatchSDKVersion.cs +3 -6
  4. package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs +6 -4
  5. package/Extra/AmaGDKInstaller.unitypackage +0 -0
  6. package/Extra/AmaGDKProject.unitypackage +0 -0
  7. package/Packages/AmaGDKConfig.unitypackage +0 -0
  8. package/Packages/AmaGDKExample.unitypackage +0 -0
  9. package/Packages/AmaGDKTest.unitypackage +0 -0
  10. package/Packages/AppsFlyerAdapter.unitypackage +0 -0
  11. package/Packages/{FirebaseAnalyticsAdapter_v9.1.0.unitypackage.meta → AppsFlyerAdapter.unitypackage.meta} +1 -1
  12. package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
  13. package/Packages/{IronSourceAdapter_v7.5.2.unitypackage.meta → FirebaseAnalyticsAdapter.unitypackage.meta} +1 -1
  14. package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
  15. package/Packages/{FirebaseRemoteConfigAdapter_v9.1.0.unitypackage.meta → FirebaseRemoteConfigAdapter.unitypackage.meta} +1 -1
  16. package/Packages/IronSourceAdapter.unitypackage +0 -0
  17. package/Packages/{AppsFlyerAdapter_v6.5.4.unitypackage.meta → IronSourceAdapter.unitypackage.meta} +1 -1
  18. package/Packages/RevenueCatAdapter.unitypackage +0 -0
  19. package/Packages/RevenueCatAdapter.unitypackage.meta +7 -0
  20. package/Runtime/AmaGDK.Adapters.cs +55 -77
  21. package/Runtime/AmaGDK.Ads.cs +155 -163
  22. package/Runtime/AmaGDK.Analytics.cs +245 -125
  23. package/Runtime/AmaGDK.Config.cs +2 -1
  24. package/Runtime/AmaGDK.IAP.cs +47 -48
  25. package/Runtime/AmaGDK.RemoteConfig.cs +38 -35
  26. package/Runtime/AmaGDK.UserProfile.cs +27 -19
  27. package/Runtime/AmaGDK.cs +158 -111
  28. package/Runtime/Core.meta +8 -0
  29. package/{Editor/Utils/AmaGDKEditor.GUI.cs → Runtime/Internal/AmaGDK.Internal.AmaGUI.cs} +110 -85
  30. package/{Editor/Utils/AmaGDKEditor.GUI.cs.meta → Runtime/Internal/AmaGDK.Internal.AmaGUI.cs.meta} +1 -1
  31. package/Runtime/{AmaGDK.Internal.SemVer.cs → Internal/AmaGDK.Internal.SemVer.cs} +21 -17
  32. package/Runtime/{AmaGDK.Internal.cs → Internal/AmaGDK.Internal.cs} +17 -6
  33. package/Runtime/{AmaGDK.Utils.cs → Internal/AmaGDK.Utils.cs} +91 -17
  34. package/Runtime/Internal.meta +8 -0
  35. package/package.json +1 -1
  36. package/Packages/AppsFlyerAdapter_v6.5.4.unitypackage +0 -0
  37. package/Packages/FirebaseAnalyticsAdapter_v9.1.0.unitypackage +0 -0
  38. package/Packages/FirebaseRemoteConfigAdapter_v9.1.0.unitypackage +0 -0
  39. package/Packages/IronSourceAdapter_v7.5.2.unitypackage +0 -0
  40. package/Packages/IronsourceAdapter_v7.2.6.unitypackage +0 -0
  41. package/Packages/IronsourceAdapter_v7.2.6.unitypackage.meta +0 -7
  42. package/Packages/RevenueCatAdapter_v6.0.0.unitypackage +0 -0
  43. package/Packages/RevenueCatAdapter_v6.0.0.unitypackage.meta +0 -7
  44. /package/Runtime/{AmaGDK.Internal.SemVer.cs.meta → Internal/AmaGDK.Internal.SemVer.cs.meta} +0 -0
  45. /package/Runtime/{AmaGDK.Internal.cs.meta → Internal/AmaGDK.Internal.cs.meta} +0 -0
  46. /package/Runtime/{AmaGDK.Utils.cs.meta → Internal/AmaGDK.Utils.cs.meta} +0 -0
  47. /package/Runtime/{AmaGDK.WebUtils.cs → Internal/AmaGDK.WebUtils.cs} +0 -0
  48. /package/Runtime/{AmaGDK.WebUtils.cs.meta → Internal/AmaGDK.WebUtils.cs.meta} +0 -0
@@ -3,6 +3,7 @@ using System.Collections;
3
3
  using System.Collections.Generic;
4
4
  using UnityEngine;
5
5
  using Amanotes.Core.Internal;
6
+
6
7
  using static Amanotes.Core.Internal.Logging;
7
8
  using static Amanotes.Core.AmaGDK;
8
9
 
@@ -96,7 +97,6 @@ namespace Amanotes.Core
96
97
  return isValid;
97
98
  }
98
99
  }
99
-
100
100
  public partial class AmaGDK // Ads module
101
101
  {
102
102
  [Serializable]
@@ -168,27 +168,30 @@ namespace Amanotes.Core
168
168
 
169
169
  public partial class Ads
170
170
  {
171
- public static ShowAdContext context;
172
171
  public static bool allowAdRequest = true;
173
172
 
174
- internal static AdAdapterConfig _adConfig;
175
- internal static IAdAdapter _adapter;
176
- internal static float _savedVolume = -1;
177
- internal static float _savedTimeScale = -1;
178
-
173
+ // internal use
179
174
  internal static readonly AdsData localData = new AdsData().LoadJsonFromFile();
180
-
181
- public static AdAdapterConfig adConfig => _adConfig;
175
+
176
+ internal protected static AdShowContext context;
177
+ internal protected static AdAdapter _adapter;
178
+ internal protected static float _savedVolume = -1;
179
+ internal protected static float _savedTimeScale = -1;
182
180
  }
183
181
 
184
182
  public partial class Ads // Public
185
183
  {
186
- internal static void Init()
184
+ internal static bool InitModule()
187
185
  {
188
- _adapter = Adapter.GetSingleAdapter<IAdAdapter>();
189
- _adConfig = ((AdapterContext)_adapter)?.GetAdapterConfig<AdAdapterConfig>();
190
- _adapter?.interstitial.StartLoadAd();
191
- _adapter?.rewardVideo.StartLoadAd();
186
+ _adapter = Adapter2.GetAdapter<AdAdapter>();
187
+ return _adapter == null;
188
+ }
189
+
190
+ internal static void StartModule()
191
+ {
192
+ if (_adapter == null) return;
193
+ _adapter.interstitial.StartLoadAd();
194
+ _adapter.rewardVideo.StartLoadAd();
192
195
 
193
196
  if (_isBannerShowing)
194
197
  {
@@ -201,92 +204,54 @@ namespace Amanotes.Core
201
204
  public static bool HasRewardedVideo => _adapter.rewardVideo.hasAd;
202
205
  public static bool IsBannerShowing => _isBannerShowing;
203
206
  public static bool IsAdShowing => context != null;
204
-
207
+
205
208
  private static bool ClearPrevContext()
206
209
  {
207
210
  if (context == null) return true;
208
211
  float duration = Time.realtimeSinceStartup - context.showCallAt;
209
- // bool willSkip = duration < Mathf.Max(60f, _adConfig.adShowTimeoutInSecs);
210
212
  LogWarning($"[AD] ShowRequest IGNORED as another ad is showing (elapsedTime: {duration:n2}s):\n" + JsonUtility.ToJson(context, true));
211
213
  return false;
212
-
213
- // if (willSkip)
214
- // {
215
- // LogWarning($"[AD] ShowRequest IGNORED as another ad is showing (elapsedTime: {duration:n2}s):\n" + JsonUtility.ToJson(context, true));
216
- // return false;
217
- // }
218
- //
219
- // LogWarning($"[AD] FORCE STOPPED the previous ad, as it seems to hang (elapsedTime: {duration:n2}s):\n" + JsonUtility.ToJson(context, true));
220
- // // possibly hang: force stop
221
- // if (context.adType == AdType.Interstitial)
222
- // {
223
- // _adapter.interstitial.StopShowAd();
224
- // } else
225
- // {
226
- // _adapter.rewardVideo.StopShowAd();
227
- // }
228
- // return true;
229
214
  }
230
215
 
231
216
  public static IAdCallback ShowInterstitial(string placementName = null, Dictionary<string, object> userData = null)
232
217
  {
233
218
  if (!ClearPrevContext()) return null;
234
219
 
235
- context = new ShowAdContext(AdType.Interstitial, placementName, userData);
220
+ context = new AdShowContext(AdType.Interstitial, placementName, userData);
236
221
  _adapter.interstitial.StartShowAd();
237
222
  return context;
238
223
  }
239
224
 
240
- public static bool IsInterstitialShowing
241
- {
242
- get
243
- {
244
- if (context == null) return false;
245
- return context.adType == AdType.Interstitial;
246
- }
247
- }
225
+ public static bool IsInterstitialShowing => (context != null) && (context.adType == AdType.Interstitial);
248
226
 
249
227
  public static IAdCallback ShowRewardedVideo(string placementName = null, Dictionary<string, object> userData = null)
250
228
  {
251
229
  if (!ClearPrevContext()) return null;
252
-
253
- context = new ShowAdContext(AdType.VideoReward, placementName, userData);
230
+
231
+ context = new AdShowContext(AdType.VideoReward, placementName, userData);
254
232
  _adapter.rewardVideo.StartShowAd();
255
233
  return context;
256
234
  }
257
-
258
- public static bool IsRewardedVideoShowing
259
- {
260
- get
261
- {
262
- if (context == null) return false;
263
- return context.adType == AdType.VideoReward;
264
- }
265
- }
266
-
235
+
236
+ public static bool IsRewardedVideoShowing => (context != null) && (context.adType == AdType.VideoReward);
237
+
238
+
267
239
  private static bool _isBannerShowing;
268
- private static BannerPosition? _showingBannerPosition = null;
240
+ private static BannerPosition _showingBannerPosition;
269
241
 
270
242
  public static void ShowBanner(BannerPosition? bannerPosition = null)
271
243
  {
272
244
  if (_isBannerShowing) return;
273
245
  _isBannerShowing = true;
274
- _showingBannerPosition = bannerPosition;
275
-
246
+ _showingBannerPosition = bannerPosition ?? Config.ad.bannerPosition;
247
+
276
248
  if (_adapter == null)
277
249
  {
278
250
  //Debug.LogWarning("Adapter not found???");
279
251
  return;
280
252
  }
281
-
282
- if (_adConfig == null)
283
- {
284
- //Debug.LogWarning("_adConfig not found???");
285
- return;
286
- }
287
-
288
- _showingBannerPosition = bannerPosition ?? _adConfig.bannerPosition;
289
- _adapter.ShowBanner(_showingBannerPosition.Value);
253
+
254
+ _adapter.ShowBanner(_showingBannerPosition);
290
255
  }
291
256
 
292
257
  public static void HideBanner()
@@ -306,7 +271,7 @@ namespace Amanotes.Core
306
271
  else
307
272
  _adapter.rewardVideo.StopShowAd();
308
273
  }
309
-
274
+
310
275
  /// <summary>
311
276
  /// Capping for interstitial ad
312
277
  /// - Time since last interstitial show success > interstitialCappingTime
@@ -321,16 +286,16 @@ namespace Amanotes.Core
321
286
  bool rewardCapped = (rewardedVideoCappingTime > 0) && TimeSinceLastVideoRewardSucceed < rewardedVideoCappingTime;
322
287
  return interCapped || rewardCapped;
323
288
  }
324
-
289
+
325
290
  public static int TimeSinceLastInterstitialSucceed => localData.TimeSinceLastShowSuccess(AdType.Interstitial);
326
291
  public static int TimeSinceLastVideoRewardSucceed => localData.TimeSinceLastShowSuccess(AdType.VideoReward);
327
- public static int TimeSinceLastAdSucceed => Math.Min(TimeSinceLastInterstitialSucceed, TimeSinceLastVideoRewardSucceed) ;
292
+ public static int TimeSinceLastAdSucceed => Math.Min(TimeSinceLastInterstitialSucceed, TimeSinceLastVideoRewardSucceed);
328
293
  public static int TimeSinceLastInterstitialShowCalled => localData.TimeSinceLastShowCalled(AdType.Interstitial);
329
294
  public static int TimeSinceLastVideoRewardShowCalled => localData.TimeSinceLastShowCalled(AdType.VideoReward);
330
-
295
+
331
296
  public static int InterstitialShowCalledInSession => localData.ShowCallCount(AdType.Interstitial);
332
297
  public static int RewardVideoShowCalledInSession => localData.ShowCallCount(AdType.VideoReward);
333
-
298
+
334
299
  public static void SetUserId(string userId)
335
300
  {
336
301
  _adapter.SetUserId(userId);
@@ -341,22 +306,51 @@ namespace Amanotes.Core
341
306
 
342
307
  namespace Amanotes.Core.Internal
343
308
  {
344
- public interface IAdCallback { }
309
+ [Serializable] public class AdModuleConfig
310
+ {
311
+ // [Header("----- MODULE CONFIG -----")]
312
+ // public bool manualInit;
313
+ public int adLoadTimeoutInSecs = 60;
314
+ public int adShowTimeoutInSecs = 5;
315
+ public BannerPosition bannerPosition = BannerPosition.BOTTOM;
316
+ public bool autoLogEvent = true;
317
+
318
+ public bool enableInterstitial = true;
319
+ public bool enableRewarded = true;
320
+ public bool enableBanner = true;
321
+
322
+ public bool autoMute = true;
323
+ public bool autoTimeScale = true;
324
+
325
+ [Header("EDITOR")]
326
+ [Range(0f, 1f)] public float rewardAdShowSuccessRate = 1;
327
+ }
345
328
 
346
- public interface IAdAdapter
329
+ public partial class ConfigAsset
347
330
  {
348
- AdLogic interstitial { get; }
349
- AdLogic rewardVideo { get; }
331
+ [SerializeField] public AdModuleConfig ad;
332
+ }
333
+
334
+ [Serializable] public abstract class AdAdapter : Adapter2
335
+ {
336
+ protected AdShowContext context => Ads.context;
337
+ protected AdModuleConfig moduleConfig => Config.ad;
350
338
 
351
- void HandleBeforeAdShow();
352
- void HandleAfterAdShow();
353
-
354
- void ShowBanner(BannerPosition position);
355
- void HideBanner();
339
+ // APIs
340
+ internal protected abstract AdLogic interstitial { get; }
341
+ internal protected abstract AdLogic rewardVideo { get; }
356
342
 
357
- void SetUserId(string userId);
358
- }
343
+ public abstract void ShowBanner(BannerPosition bannerPosition);
344
+ public abstract void HideBanner();
359
345
 
346
+ // Internally used
347
+ internal protected abstract void HandleBeforeAdShow();
348
+ internal protected abstract void HandleAfterAdShow();
349
+ internal protected abstract void SetUserId(string userId);
350
+ }
351
+
352
+ public interface IAdCallback { }
353
+
360
354
  public enum LoadAdsState
361
355
  {
362
356
  None,
@@ -412,7 +406,7 @@ namespace Amanotes.Core.Internal
412
406
  Ready,
413
407
  }
414
408
 
415
- public class ShowAdContext : IAdCallback
409
+ public class AdShowContext : IAdCallback
416
410
  {
417
411
  public readonly AdType adType;
418
412
  public readonly string placementName;
@@ -433,7 +427,7 @@ namespace Amanotes.Core.Internal
433
427
  public float showCallAt;
434
428
  public float showFinishAt;
435
429
 
436
- public ShowAdContext(AdType adType, string placementName, Dictionary<string, object> userData)
430
+ public AdShowContext(AdType adType, string placementName, Dictionary<string, object> userData)
437
431
  {
438
432
  this.adType = adType;
439
433
  this.userData = userData;
@@ -452,6 +446,10 @@ namespace Amanotes.Core.Internal
452
446
 
453
447
  public abstract class AdLogic
454
448
  {
449
+ internal protected AdAdapter adapter => Ads._adapter;
450
+ protected AdModuleConfig adConfig => Config.ad;
451
+ protected AdShowContext context => Ads.context;
452
+
455
453
  internal LoadAdsState _loadState = LoadAdsState.None;
456
454
  internal bool hasAd
457
455
  {
@@ -463,7 +461,7 @@ namespace Amanotes.Core.Internal
463
461
  _loadState = LoadAdsState.None;
464
462
  StartLoadAd();
465
463
  }
466
-
464
+
467
465
  return _loadState == LoadAdsState.Ready;
468
466
  }
469
467
  }
@@ -481,7 +479,7 @@ namespace Amanotes.Core.Internal
481
479
  Log("[Ad] StartLoadAd");
482
480
  _loadRoutine = _instance.StartCoroutine(LoadAdRoutine());
483
481
  }
484
-
482
+
485
483
  public void StopLoadAd()
486
484
  {
487
485
  Log("[Ad] StopLoadAd");
@@ -489,7 +487,7 @@ namespace Amanotes.Core.Internal
489
487
  {
490
488
  _loadState = LoadAdsState.None;
491
489
  }
492
-
490
+
493
491
  if (_loadRoutine == null) return;
494
492
  _instance.StopCoroutine(_loadRoutine);
495
493
  _loadRoutine = null;
@@ -503,7 +501,7 @@ namespace Amanotes.Core.Internal
503
501
  _loadState = LoadAdsState.Ready;
504
502
  yield break;
505
503
  }
506
-
504
+
507
505
  var wait1Sec = new WaitForSecondsRealtime(1f);
508
506
  Log("[Ad] LoadAdRoutine start(): isAdReady = " + isAdReady);
509
507
  while (true)
@@ -515,19 +513,19 @@ namespace Amanotes.Core.Internal
515
513
  Log("[Ad] LoadAdRoutine: allowAdRequest = false");
516
514
  continue;
517
515
  }
518
-
516
+
519
517
  if (!HasLocalNetworkConnection)
520
518
  {
521
519
  Log("[Ad] LoadAdRoutine: hasInternet = " + HasLocalNetworkConnection);
522
520
  continue;
523
521
  }
524
-
522
+
525
523
  _loadState = LoadAdsState.Requesting;
526
524
  _isRequesting = true;
527
525
  Log("[Ad] LoadAdRoutine: RequestAd()");
528
526
  RequestAd();
529
527
 
530
- int timeout = Ads._adConfig.adLoadTimeoutInSecs;
528
+ int timeout = Config.ad.adLoadTimeoutInSecs;
531
529
  var counter = 0;
532
530
 
533
531
  while (counter < timeout || timeout == -1)
@@ -576,15 +574,15 @@ namespace Amanotes.Core.Internal
576
574
  {
577
575
  LogWarning("[Ad] StartShowAd() --> Invalid _showState: " + _showState);
578
576
  }
579
-
577
+
580
578
  Log($"[Ad] {adType} StartShowAd");
581
579
  _showState = ShowAdsState.ShowCalled;
582
-
583
- AdStat stat = Ads.localData.GetStat(adType);
580
+
581
+ AdStat stat = Ads.localData.GetStat(adType);
584
582
  stat.callCount++;
585
583
  stat.lastCallTime = Time.realtimeSinceStartup;
586
584
  OnAdShowCalled();
587
-
585
+
588
586
  if (_showAdRoutine != null) _instance.StopCoroutine(_showAdRoutine);
589
587
  _showAdRoutine = _instance.StartCoroutine(ShowAdRoutine());
590
588
  }
@@ -598,7 +596,7 @@ namespace Amanotes.Core.Internal
598
596
  _loadState = LoadAdsState.None;
599
597
  StartLoadAd();
600
598
  }
601
-
599
+
602
600
  HandleAfterAdShow();
603
601
  if (_showAdRoutine == null) return;
604
602
  _instance.StopCoroutine(_showAdRoutine);
@@ -606,9 +604,8 @@ namespace Amanotes.Core.Internal
606
604
 
607
605
  if (Ads.context.adType == AdType.Interstitial)
608
606
  {
609
- ShowAdRoutineCompleted(!Ads.context.hasFailedOrCancelled);
610
- }
611
- else
607
+ ShowAdRoutineCompleted(!Ads.context.hasFailedOrCancelled);
608
+ } else
612
609
  {
613
610
  ShowAdRoutineCompleted(Ads.context.hasReward);
614
611
  }
@@ -618,7 +615,7 @@ namespace Amanotes.Core.Internal
618
615
  {
619
616
  // Wait to end frame so that all AdCallbacks finish registering
620
617
  yield return new WaitForEndOfFrame();
621
-
618
+
622
619
  // Wait for Ad
623
620
  if (!isAdReady)
624
621
  {
@@ -627,7 +624,7 @@ namespace Amanotes.Core.Internal
627
624
  LogWarning("[Ad] Inconsistent state report: isAdReady == false while _loadState == Ready");
628
625
  _loadState = LoadAdsState.None;
629
626
  }
630
-
627
+
631
628
  if (!HasLocalNetworkConnection)
632
629
  {
633
630
  _showState = ShowAdsState.ShowFail;
@@ -635,8 +632,8 @@ namespace Amanotes.Core.Internal
635
632
  ShowAdRoutineCompleted(false);
636
633
  yield break;
637
634
  }
638
-
639
- int timeout = Ads._adConfig.adShowTimeoutInSecs;
635
+
636
+ int timeout = Config.ad.adShowTimeoutInSecs;
640
637
  if (timeout == 0) // do not wait for Ad
641
638
  {
642
639
  _showState = ShowAdsState.ShowFail;
@@ -644,15 +641,15 @@ namespace Amanotes.Core.Internal
644
641
  ShowAdRoutineCompleted(false);
645
642
  yield break;
646
643
  }
647
-
644
+
648
645
  _showState = ShowAdsState.WaitForAd;
649
646
  OnAdShowReadyStatus(false, AdShowReadyStatus.WaitForAd);
650
-
647
+
651
648
  if (_loadState != LoadAdsState.Requesting) StartLoadAd();
652
649
  var counter = 0;
653
650
  bool? hasInternet = null;
654
651
  _instance.StartCoroutine(WebUtils.CheckInternet(result => hasInternet = result));
655
-
652
+
656
653
  var wait1Sec = new WaitForSecondsRealtime(1f);
657
654
  while (counter < timeout || timeout == -1)
658
655
  {
@@ -673,7 +670,7 @@ namespace Amanotes.Core.Internal
673
670
  Log("[Ad] WaitForAd success after " + counter + " | timeout = " + timeout + " secs");
674
671
  break;
675
672
  }
676
-
673
+
677
674
  if (!isAdReady)
678
675
  {
679
676
  Log("[Ad] WaitForAd failed (timeout) " + counter + " | timeout = " + timeout + " secs");
@@ -682,13 +679,13 @@ namespace Amanotes.Core.Internal
682
679
  yield break;
683
680
  }
684
681
  }
685
-
682
+
686
683
  _showState = ShowAdsState.Showing;
687
684
  OnAdShowReadyStatus(true, AdShowReadyStatus.Ready);
688
685
  HandleBeforeAdShow();
689
686
  ShowAd();
690
-
691
- ShowAdContext context = Ads.context;
687
+
688
+ AdShowContext context = Ads.context;
692
689
  while (!context.potentiallyCompleted)
693
690
  {
694
691
  yield return null; // callback as quickly as possible
@@ -715,7 +712,7 @@ namespace Amanotes.Core.Internal
715
712
  ShowAdRoutineCompleted(context.hasReward);
716
713
  yield break;
717
714
  }
718
-
715
+
719
716
  while (!context.hasClosed)
720
717
  {
721
718
  Log($"[Ad] {adType} Waiting for [close]");
@@ -732,13 +729,13 @@ namespace Amanotes.Core.Internal
732
729
  _loadState = isAdReady ? LoadAdsState.Ready : LoadAdsState.None;
733
730
  if (_loadState == LoadAdsState.None) StartLoadAd();
734
731
  }
735
-
732
+
736
733
  _showState = isSuccess ? ShowAdsState.ShowSuccess : ShowAdsState.ShowFail;
737
-
734
+
738
735
  // Extra callback
739
736
  Ads.context.showFinishAt = Time.realtimeSinceStartup;
740
737
  Ads.context.onAdResult?.Invoke(isSuccess);
741
-
738
+
742
739
  var localData = Ads.localData;
743
740
  var stat = _isInterstitial ? localData.interstitial : localData.reward;
744
741
  if (isSuccess)
@@ -746,8 +743,7 @@ namespace Amanotes.Core.Internal
746
743
  stat.success++;
747
744
  stat.successTotal++;
748
745
  stat.lastSuccessTime = (int)Time.realtimeSinceStartup;
749
- }
750
- else
746
+ } else
751
747
  {
752
748
  stat.failed++;
753
749
  stat.failedTotal++;
@@ -755,60 +751,60 @@ namespace Amanotes.Core.Internal
755
751
 
756
752
  localData.Save();
757
753
  HandleAfterAdShow();
758
-
754
+
759
755
  Log($"[Ad] {adType} ShowAdRoutineCompleted: {isSuccess}\n{JsonUtility.ToJson(Ads.context)}");
760
756
  Ads.context = null;
761
757
  _showState = ShowAdsState.None;
762
758
  }
763
-
759
+
764
760
  private void HandleBeforeAdShow()
765
761
  {
766
- bool willSaveVolume = Ads._adConfig.autoMute
762
+ bool willSaveVolume = Config.ad.autoMute
767
763
  && AudioListener.volume > 0
768
764
  && Ads._savedVolume < 0;
769
-
770
- bool willSaveTimeScale = Ads._adConfig.autoTimeScale
765
+
766
+ bool willSaveTimeScale = Config.ad.autoTimeScale
771
767
  && Time.timeScale > 0
772
768
  && Ads._savedTimeScale < 0;
773
-
769
+
774
770
  if (willSaveVolume)
775
771
  {
776
772
  Ads._savedVolume = AudioListener.volume;
777
773
  AudioListener.volume = 0;
778
774
  }
779
-
775
+
780
776
  if (willSaveTimeScale)
781
777
  {
782
778
  Ads._savedTimeScale = Time.timeScale;
783
779
  Time.timeScale = 0;
784
780
  }
785
-
781
+
786
782
  Ads.context.onBeforeAdOpen?.Invoke();
787
783
  Ads._adapter.HandleBeforeAdShow();
788
784
  }
789
-
785
+
790
786
  private void HandleAfterAdShow()
791
787
  {
792
- bool willRestoreVolume = Ads._adConfig.autoMute
788
+ bool willRestoreVolume = Config.ad.autoMute
793
789
  && AudioListener.volume == 0
794
790
  && Ads._savedVolume > 0;
795
-
796
- bool willRestoreTimeScale = Ads._adConfig.autoTimeScale
791
+
792
+ bool willRestoreTimeScale = Config.ad.autoTimeScale
797
793
  && Time.timeScale == 0
798
794
  && Ads._savedTimeScale > 0;
799
-
795
+
800
796
  if (willRestoreVolume)
801
797
  {
802
798
  AudioListener.volume = Ads._savedVolume;
803
799
  Ads._savedVolume = -1;
804
800
  }
805
-
801
+
806
802
  if (willRestoreTimeScale)
807
803
  {
808
804
  Time.timeScale = Ads._savedTimeScale;
809
805
  Ads._savedTimeScale = -1;
810
806
  }
811
-
807
+
812
808
  Ads._adapter.HandleAfterAdShow();
813
809
  }
814
810
 
@@ -816,13 +812,12 @@ namespace Amanotes.Core.Internal
816
812
  protected void OnAdClosed()
817
813
  {
818
814
  Log($"[Ad] {adType} OnAdClosed");
819
-
815
+
820
816
  if (Ads.context != null)
821
817
  {
822
818
  Ads.context.adCallback |= AdCallback.Close;
823
819
  Ads.context.onClosed?.Invoke();
824
- }
825
- else
820
+ } else
826
821
  {
827
822
  LogWarning("[Ad] OnAdClosed() Something wrong - No AdContext");
828
823
  }
@@ -831,13 +826,12 @@ namespace Amanotes.Core.Internal
831
826
  protected void OnAdClicked()
832
827
  {
833
828
  Log($"[Ad] {adType} OnAdClicked");
834
-
829
+
835
830
  if (Ads.context != null)
836
831
  {
837
832
  Ads.context.adCallback |= AdCallback.Click;
838
833
  Ads.context.onClicked?.Invoke();
839
- }
840
- else
834
+ } else
841
835
  {
842
836
  LogWarning("[Ad] OnAdClicked() Something wrong - No AdContext");
843
837
  }
@@ -846,13 +840,12 @@ namespace Amanotes.Core.Internal
846
840
  protected void OnAdShowFailed()
847
841
  {
848
842
  Log($"[Ad] {adType} OnAdShowFailed");
849
-
843
+
850
844
  if (Ads.context != null)
851
845
  {
852
846
  Ads.context.adCallback |= AdCallback.Fail;
853
847
  Ads.context.onShowFailed?.Invoke();
854
- }
855
- else
848
+ } else
856
849
  {
857
850
  LogWarning("[Ad] OnAdShowFailed() Something wrong - No AdContext");
858
851
  }
@@ -861,13 +854,12 @@ namespace Amanotes.Core.Internal
861
854
  protected void OnAdShowSucceeded()
862
855
  {
863
856
  Log($"[Ad] {adType} OnAdShowSucceeded");
864
-
857
+
865
858
  if (Ads.context != null)
866
859
  {
867
860
  Ads.context.adCallback |= AdCallback.Success;
868
861
  Ads.context.onShowSuccess?.Invoke();
869
- }
870
- else
862
+ } else
871
863
  {
872
864
  LogWarning("[Ad] OnAdShowSucceeded() Something wrong - No AdContext");
873
865
  }
@@ -880,33 +872,34 @@ namespace Amanotes.Core.Internal
880
872
  LogWarning("[Ad] OnAdOpen() Something wrong - No AdContext");
881
873
  return;
882
874
  }
883
-
884
- Ads.context.adCallback |= AdCallback.ShowReadyStatus;
885
- Ads.context.onAdShowReadyStatus?.Invoke(status);
875
+
876
+ Ads.context.adCallback |= AdCallback.ShowReadyStatus;
877
+ Ads.context.onAdShowReadyStatus?.Invoke(status);
886
878
  if (status == AdShowReadyStatus.Ready)
887
- {
888
- OnAdShowReady();
889
- }
890
- else if (status == AdShowReadyStatus.NoInternet || status == AdShowReadyStatus.TimeOut || status == AdShowReadyStatus.Wifi3GDisabled)
891
879
  {
892
- OnAdShowNotReady(status);
880
+ OnAdShowReady();
881
+ } else if (status == AdShowReadyStatus.NoInternet || status == AdShowReadyStatus.TimeOut || status == AdShowReadyStatus.Wifi3GDisabled)
882
+ {
883
+ OnAdShowNotReady(status);
893
884
  }
894
885
  }
895
-
896
- protected virtual void OnAdShowCalled(){}
897
- protected virtual void OnAdShowReady(){}
898
- protected virtual void OnAdShowNotReady(AdShowReadyStatus status){}
899
-
886
+
887
+ protected virtual void OnAdShowCalled()
888
+ { }
889
+ protected virtual void OnAdShowReady()
890
+ { }
891
+ protected virtual void OnAdShowNotReady(AdShowReadyStatus status)
892
+ { }
893
+
900
894
  protected void OnAdOpen()
901
895
  {
902
896
  Log($"[Ad] {adType} OnAdOpen");
903
-
897
+
904
898
  if (Ads.context != null)
905
899
  {
906
900
  Ads.context.adCallback |= AdCallback.Open;
907
901
  Ads.context.onOpened?.Invoke();
908
- }
909
- else
902
+ } else
910
903
  {
911
904
  LogWarning("[Ad] OnAdOpen() Something wrong - No AdContext");
912
905
  }
@@ -915,13 +908,12 @@ namespace Amanotes.Core.Internal
915
908
  protected void OnAdReward()
916
909
  {
917
910
  Log($"[Ad] {adType} OnAdReward");
918
-
911
+
919
912
  if (Ads.context != null)
920
913
  {
921
914
  Ads.context.adCallback |= AdCallback.Reward;
922
915
  Ads.context.onRewardReceived?.Invoke();
923
- }
924
- else
916
+ } else
925
917
  {
926
918
  LogWarning("[Ad] OnAdReward() Something wrong - No AdContext");
927
919
  }
@@ -930,7 +922,7 @@ namespace Amanotes.Core.Internal
930
922
  protected void OnAdLoadSuccess()
931
923
  {
932
924
  Log($"[Ad] {adType} OnAdLoadSuccess");
933
-
925
+
934
926
  if (!_isRequesting && adType == AdType.Interstitial)
935
927
  {
936
928
  LogWarning("[Ad] Something wrong? OnAdReady called when no ad is loading! AdType=" + adType);