com.amanotes.gdk 0.2.37 → 0.2.39

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.39 - 2023-11-27]
4
+ - Fix variable name and variable value of "ChangeDevMode"
5
+ - Fix Timeout = 0 should cancel the wait for Ad
6
+
7
+ ## [0.2.38 - 2023-11-22]
8
+ - Improve Ads API
9
+ - Add Ad Quality
10
+
3
11
  ## [0.2.37 - 2023-11-21]
4
12
  - Improve GDK logs
5
13
  - Banner will not show when ad adapter is not ready
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -69,11 +69,23 @@ namespace Amanotes.Core
69
69
  public static IAdCallback OnAdResult(this IAdCallback ad, Action<bool> callback)
70
70
  {
71
71
  if (!MakeSureAdNotNull(ad)) return null;
72
- Ads.context.onResult -= callback;
73
- Ads.context.onResult += callback;
72
+ Ads.context.onAdResult -= callback;
73
+ Ads.context.onAdResult += callback;
74
74
  return ad;
75
75
  }
76
-
76
+
77
+ /// <summary>
78
+ /// Call right before the ad actually open (that means Ad has already been cached & available to show).
79
+ /// This callback will not be triggered in case Ad is not available or no internet
80
+ /// </summary>
81
+ public static IAdCallback OnBeforeAdOpen(this IAdCallback ad, Action callback)
82
+ {
83
+ if (!MakeSureAdNotNull(ad)) return null;
84
+ Ads.context.onBeforeAdOpen -= callback;
85
+ Ads.context.onBeforeAdOpen += callback;
86
+ return ad;
87
+ }
88
+
77
89
  private static bool MakeSureAdNotNull(IAdCallback ad)
78
90
  {
79
91
  bool isValid = (ad != null);
@@ -165,6 +177,8 @@ namespace Amanotes.Core
165
177
  internal static float _savedTimeScale = -1;
166
178
 
167
179
  internal static readonly AdsData localData = new AdsData().LoadJsonFromFile();
180
+
181
+ public static AdAdapterConfig adConfig => _adConfig;
168
182
  }
169
183
 
170
184
  public partial class Ads // Public
@@ -292,7 +306,22 @@ namespace Amanotes.Core
292
306
  else
293
307
  _adapter.rewardVideo.StopShowAd();
294
308
  }
295
-
309
+
310
+ /// <summary>
311
+ /// Capping for interstitial ad
312
+ /// - Time since last interstitial show success > interstitialCappingTime
313
+ /// - Time since last rewardedVideo show success > rewardVideoCappingTime (for interstitial)
314
+ /// </summary>
315
+ /// <param name="interstitialCappingTime"></param>
316
+ /// <param name="rewardedVideoCappingTime"></param>
317
+ /// <returns></returns>
318
+ public static bool IsCapped(float interstitialCappingTime = 0, float rewardedVideoCappingTime = 0)
319
+ {
320
+ bool interCapped = (interstitialCappingTime > 0) && TimeSinceLastInterstitialSucceed < interstitialCappingTime;
321
+ bool rewardCapped = (rewardedVideoCappingTime > 0) && TimeSinceLastVideoRewardSucceed < rewardedVideoCappingTime;
322
+ return interCapped || rewardCapped;
323
+ }
324
+
296
325
  public static int TimeSinceLastInterstitialSucceed => localData.TimeSinceLastShowSuccess(AdType.Interstitial);
297
326
  public static int TimeSinceLastVideoRewardSucceed => localData.TimeSinceLastShowSuccess(AdType.VideoReward);
298
327
  public static int TimeSinceLastAdSucceed => Math.Min(TimeSinceLastInterstitialSucceed, TimeSinceLastVideoRewardSucceed) ;
@@ -388,6 +417,7 @@ namespace Amanotes.Core.Internal
388
417
  public readonly Dictionary<string, object> userData;
389
418
  public AdCallback adCallback;
390
419
 
420
+ internal Action onBeforeAdOpen;
391
421
  internal Action onOpened;
392
422
  internal Action onRewardReceived;
393
423
  internal Action onClicked;
@@ -395,7 +425,7 @@ namespace Amanotes.Core.Internal
395
425
  internal Action onShowFailed;
396
426
  internal Action onClosed;
397
427
  internal Action<AdShowReadyStatus> onAdShowReadyStatus;
398
- internal Action<bool> onResult;
428
+ internal Action<bool> onAdResult;
399
429
 
400
430
  // Stats
401
431
  public float showCallAt;
@@ -499,7 +529,7 @@ namespace Amanotes.Core.Internal
499
529
  int timeout = Ads._adConfig.adLoadTimeoutInSecs;
500
530
  var counter = 0;
501
531
 
502
- while (counter < timeout || timeout == 0)
532
+ while (counter < timeout || timeout == -1)
503
533
  {
504
534
  yield return wait1Sec;
505
535
  counter++;
@@ -638,8 +668,8 @@ namespace Amanotes.Core.Internal
638
668
  _showState = ShowAdsState.Showing;
639
669
  OnAdShowReadyStatus(true, AdShowReadyStatus.None);
640
670
 
641
- ShowAd();
642
671
  HandleBeforeAdShow();
672
+ ShowAd();
643
673
 
644
674
  ShowAdContext context = Ads.context;
645
675
  while (!context.potentiallyCompleted)
@@ -694,7 +724,7 @@ namespace Amanotes.Core.Internal
694
724
 
695
725
  // Extra callback
696
726
  Ads.context.showFinishAt = Time.realtimeSinceStartup;
697
- Ads.context.onResult?.Invoke(isSuccess);
727
+ Ads.context.onAdResult?.Invoke(isSuccess);
698
728
 
699
729
  var localData = Ads.localData;
700
730
  var stat = _isInterstitial ? localData.interstitial : localData.reward;
@@ -740,6 +770,7 @@ namespace Amanotes.Core.Internal
740
770
  Time.timeScale = 0;
741
771
  }
742
772
 
773
+ Ads.context.onBeforeAdOpen?.Invoke();
743
774
  Ads._adapter.HandleBeforeAdShow();
744
775
  }
745
776
 
package/Runtime/AmaGDK.cs CHANGED
@@ -9,12 +9,13 @@ using Amanotes.Core.Internal;
9
9
  using UnityEngine;
10
10
  using static Amanotes.Core.Internal.Logging;
11
11
  using static Amanotes.Core.Internal.Messsage;
12
+ using Debug = UnityEngine.Debug;
12
13
 
13
14
  namespace Amanotes.Core
14
15
  {
15
16
  public partial class AmaGDK : MonoBehaviour
16
17
  {
17
- public const string VERSION = "0.2.37";
18
+ public const string VERSION = "0.2.39";
18
19
 
19
20
  internal static AmaGDK _instance;
20
21
  internal static Status _status = Status.None;
@@ -291,17 +292,45 @@ namespace Amanotes.Core
291
292
  public void ChangeDevMode()
292
293
  {
293
294
  string variableName = "GDK_HOME";
294
- string output = RunShellCommand($"source ~/.zshrc && echo file:${variableName}");
295
- output = output.Trim();
296
-
297
- if (string.IsNullOrEmpty(output))
295
+ string zshrcPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".zshrc");
296
+ string zshrcContent;
297
+
298
+ try
299
+ {
300
+ zshrcContent = File.ReadAllText(zshrcPath);
301
+ }
302
+ catch (FileNotFoundException)
303
+ {
304
+ Debug.LogWarning($"Zsh configuration file {zshrcPath} not found.");
305
+ return;
306
+ }
307
+
308
+ if (!zshrcContent.Contains($"export {variableName}="))
298
309
  {
299
- LogWarning($"{variableName} environment variable is not set.");
310
+ Debug.LogWarning($"{variableName} environment variable is not set in {zshrcPath}.");
300
311
  return;
301
312
  }
313
+
314
+ int startIndex = zshrcContent.IndexOf($"export {variableName}=");
315
+ if (startIndex >= 0)
316
+ {
317
+ startIndex += $"export {variableName}=".Length;
318
+ int endIndex = zshrcContent.IndexOfAny(new char[] { '\n', '\r' }, startIndex);
319
+ string gdkHomeValue = endIndex >= 0
320
+ ? zshrcContent.Substring(startIndex, endIndex - startIndex).Trim()
321
+ : zshrcContent.Substring(startIndex).Trim();
302
322
 
303
- UpdateManifest(output);
304
- Log("AmaGDK changes to dev mode successfully");
323
+ if (string.IsNullOrEmpty(gdkHomeValue))
324
+ {
325
+ Debug.LogWarning($"{variableName} environment variable is set but has an empty value in {zshrcPath}.");
326
+ return;
327
+ }
328
+ }
329
+
330
+ string output = RunShellCommand($"source ~/.zshrc && echo file:${variableName}");
331
+ output = output.Trim();
332
+ UpdateManifest(output);
333
+ Debug.Log("AmaGDK changes to dev mode successfully");
305
334
  }
306
335
 
307
336
  private string RunShellCommand(string command)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.amanotes.gdk",
3
- "version": "0.2.37",
3
+ "version": "0.2.39",
4
4
  "displayName": "AmaGDK",
5
5
  "description": "Amanotes Game Development Kit",
6
6
  "unity": "2019.4",