com.amanotes.gdk 0.2.38 → 0.2.40

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,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.40 - 2023-11-27]
4
+ - Fix ShowAdTimeout = 0 should not wait for Ad
5
+
6
+ ## [0.2.39 - 2023-11-27]
7
+ - Fix variable name and variable value of "ChangeDevMode"
8
+ - Load Ad timeout should cancel
9
+
3
10
  ## [0.2.38 - 2023-11-22]
4
11
  - Improve Ads API
5
12
  - Add Ad Quality
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -529,7 +529,7 @@ namespace Amanotes.Core.Internal
529
529
  int timeout = Ads._adConfig.adLoadTimeoutInSecs;
530
530
  var counter = 0;
531
531
 
532
- while (counter < timeout || timeout == 0)
532
+ while (counter < timeout || timeout == -1)
533
533
  {
534
534
  yield return wait1Sec;
535
535
  counter++;
@@ -634,31 +634,46 @@ namespace Amanotes.Core.Internal
634
634
  ShowAdRoutineCompleted(false);
635
635
  yield break;
636
636
  }
637
-
638
- var hasInternet = false;
639
- yield return WebUtils.CheckInternet(result => hasInternet = result);
640
- if (!hasInternet)
637
+
638
+ int timeout = Ads._adConfig.adShowTimeoutInSecs;
639
+ if (timeout == 0) // do not wait for Ad
641
640
  {
642
641
  _showState = ShowAdsState.ShowFail;
643
- OnAdShowReadyStatus(false, AdShowReadyStatus.NoInternet);
642
+ OnAdShowReadyStatus(false, AdShowReadyStatus.TimeOut);
644
643
  ShowAdRoutineCompleted(false);
645
644
  yield break;
646
645
  }
647
-
648
- if (_loadState != LoadAdsState.Requesting) StartLoadAd();
646
+
649
647
  _showState = ShowAdsState.WaitForAd;
650
- int timeout = Ads._adConfig.adShowTimeoutInSecs;
648
+ if (_loadState != LoadAdsState.Requesting) StartLoadAd();
649
+
651
650
  var counter = 0;
652
-
653
- while (counter < timeout || timeout == 0)
651
+ bool? hasInternet = null;
652
+ _instance.StartCoroutine(WebUtils.CheckInternet(result => hasInternet = result));
653
+
654
+ while (counter < timeout || timeout == -1)
654
655
  {
655
656
  yield return wait1Sec;
656
657
  counter++;
657
- if (_loadState == LoadAdsState.Ready) break;
658
- }
659
658
 
659
+ // finish checking internet & result is false
660
+ if (hasInternet == false)
661
+ {
662
+ Log("[Ad] Stop WaitForAd : No internet!");
663
+ _showState = ShowAdsState.ShowFail;
664
+ OnAdShowReadyStatus(false, AdShowReadyStatus.NoInternet);
665
+ ShowAdRoutineCompleted(false);
666
+ yield break;
667
+ }
668
+
669
+ if (_loadState != LoadAdsState.Ready) continue;
670
+ Log("[Ad] WaitForAd success after " + counter + " | timeout = " + timeout + " secs");
671
+ break;
672
+ }
673
+
660
674
  if (!isAdReady)
661
675
  {
676
+ Log("[Ad] WaitForAd failed (timeout) " + counter + " | timeout = " + timeout + " secs");
662
677
  OnAdShowReadyStatus(false, AdShowReadyStatus.TimeOut);
663
678
  ShowAdRoutineCompleted(false);
664
679
  yield break;
@@ -667,7 +682,6 @@ namespace Amanotes.Core.Internal
667
682
 
668
683
  _showState = ShowAdsState.Showing;
669
684
  OnAdShowReadyStatus(true, AdShowReadyStatus.None);
670
-
671
685
  HandleBeforeAdShow();
672
686
  ShowAd();
673
687
 
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.38";
18
+ public const string VERSION = "0.2.40";
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.38",
3
+ "version": "0.2.40",
4
4
  "displayName": "AmaGDK",
5
5
  "description": "Amanotes Game Development Kit",
6
6
  "unity": "2019.4",