com.amanotes.gdk 0.2.74 → 0.2.77
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 +48 -0
- package/Editor/AmaGDKEditor.cs +24 -15
- package/Editor/Utils/GDKPackageInstaller.cs +116 -0
- package/Editor/Utils/GDKPackageInstaller.cs.meta +11 -0
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/Extra/AutoEventQC.unitypackage +0 -0
- package/{Runtime/GDKAudio/Plugins/iOS.meta → Extra/AutoEventQC.unitypackage.meta} +1 -2
- package/Extra/CheckDiskSpace.unitypackage +0 -0
- package/Extra/Consent.unitypackage +0 -0
- package/Extra/ForceUpdate.unitypackage +0 -0
- package/Extra/LegacyGDKUpdateHelper.unitypackage +0 -0
- package/Extra/PostProcessor.unitypackage +0 -0
- package/Packages/AmaGDKConfig.unitypackage +0 -0
- package/Packages/AmaGDKExample.unitypackage +0 -0
- package/Packages/AmaGDKTest.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter.AdRevenue.AF6.14AndOlder.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter.PurchaseConnector.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter.unitypackage +0 -0
- package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
- package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
- package/Packages/IronSourceAdapter.AdQuality.unitypackage +0 -0
- package/{Runtime/GDKAudio/Plugins/macOS.meta → Packages/IronSourceAdapter.AdQuality.unitypackage.meta} +1 -2
- package/Packages/IronSourceAdapter.unitypackage +0 -0
- package/Packages/MaxAdNetworkAdapter.unitypackage +0 -0
- package/Packages/RevenueCatAdapter.unitypackage +0 -0
- package/Packages/SqliteAnalyticsAdapter.unitypackage +0 -0
- package/Runtime/Ad/AdLogic.cs +61 -65
- package/Runtime/Ad/AdShowContext.cs +1 -1
- package/Runtime/Ad/AmaGDK.Ads.cs +2 -1
- package/Runtime/AmaGDK.Analytics.cs +22 -16
- package/Runtime/AmaGDK.Consent.cs +5 -9
- package/Runtime/AmaGDK.Mono.cs +1 -1
- package/Runtime/AmaGDK.RemoteConfig.cs +12 -2
- package/Runtime/AmaGDK.Singleton.cs +3 -1
- package/Runtime/AmaGDK.UserProfile.cs +33 -24
- package/Runtime/AmaGDK.cs +83 -43
- package/Runtime/Core/GDKDebug.cs +12 -5
- package/Runtime/Core/GDKPrefabPool.cs +571 -0
- package/Runtime/Core/GDKPrefabPool.cs.meta +11 -0
- package/Runtime/Core/GDKRoutine.cs +48 -2
- package/Runtime/Internal/AmaGDK.Internal.cs +1 -1
- package/Runtime/Internal/AmaGDK.WebUtils.cs +4 -4
- package/Runtime/Internal/ForceQuitMonitor.cs +2 -2
- package/Runtime/Internal/GDKGeoLocationcs.cs +2 -1
- package/Runtime/Internal/GDKServerTime.cs +2 -1
- package/Runtime/UI/ScrollView/Editor/GDKScrollViewEditor.cs +50 -0
- package/Runtime/UI/ScrollView/Editor/GDKScrollViewEditor.cs.meta +11 -0
- package/Runtime/{GDKAudio/Resources.meta → UI/ScrollView/Editor.meta} +1 -1
- package/Runtime/UI/ScrollView/GDKScrollView.cs +702 -0
- package/Runtime/UI/ScrollView/GDKScrollView.cs.meta +12 -0
- package/Runtime/UI/ScrollView.meta +9 -0
- package/Runtime/UI/ScrollableText/GDKScrollableText.cs +68 -0
- package/Runtime/UI/ScrollableText/GDKScrollableText.cs.meta +3 -0
- package/Runtime/UI/ScrollableText/GDKScrollableText.prefab +806 -0
- package/Runtime/UI/ScrollableText/GDKScrollableText.prefab.meta +7 -0
- package/Runtime/UI/ScrollableText.meta +3 -0
- package/Runtime/{GDKAudio/Plugins.meta → UI.meta} +1 -1
- package/Runtime/Utils/GDKUtils.cs +18 -0
- package/package.json +1 -1
- package/Packages/AppsFlyerAdapter.AdRevenue.unitypackage +0 -0
- package/Runtime/GDKAudio/GDKAudio.cs +0 -483
- package/Runtime/GDKAudio/GDKAudio.cs.meta +0 -3
- package/Runtime/GDKAudio/Plugins/Android/atensor-release.aar +0 -0
- package/Runtime/GDKAudio/Plugins/Android/atensor-release.aar.meta +0 -32
- package/Runtime/GDKAudio/Plugins/Android.meta +0 -3
- package/Runtime/GDKAudio/Plugins/iOS/libatensor.a +0 -0
- package/Runtime/GDKAudio/Plugins/iOS/libatensor.a.meta +0 -68
- package/Runtime/GDKAudio/Plugins/iOS/libcrypto.a +0 -0
- package/Runtime/GDKAudio/Plugins/iOS/libcrypto.a.meta +0 -68
- package/Runtime/GDKAudio/Plugins/iOS/libssl.a +0 -0
- package/Runtime/GDKAudio/Plugins/iOS/libssl.a.meta +0 -68
- package/Runtime/GDKAudio/Plugins/macOS/libatensor.dylib +0 -0
- package/Runtime/GDKAudio/Plugins/macOS/libatensor.dylib.meta +0 -81
- package/Runtime/GDKAudio/Resources/GDKAudioMixer.mixer +0 -133
- package/Runtime/GDKAudio/Resources/GDKAudioMixer.mixer.meta +0 -8
- package/Runtime/GDKAudio.meta +0 -3
- /package/Packages/{AppsFlyerAdapter.AdRevenue.unitypackage.meta → AppsFlyerAdapter.AdRevenue.AF6.14AndOlder.unitypackage.meta} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.77] - 2024-11-07
|
|
4
|
+
- [Release] 0.2.76
|
|
5
|
+
- [Dev] Remove GDKAudio
|
|
6
|
+
- [Dev] Handle format exception in RemoteConfig
|
|
7
|
+
- [Dev] Handle exception of FetchConfig
|
|
8
|
+
- [Fix] Corrected handling of events after LogImmediately()
|
|
9
|
+
- [Dev] Convert value with invariant culture in Remote Config
|
|
10
|
+
- [Feature] Support AppsFlyer 6.15.x by default
|
|
11
|
+
- [Dev] GameOpsSDK
|
|
12
|
+
- [Dev] Fix bug missing ads callback on iOS
|
|
13
|
+
- [Dev] Add OnAdReady logging
|
|
14
|
+
- [Dev] Add more params to impressionData
|
|
15
|
+
- [CI] Update pipeline
|
|
16
|
+
- [Dev] Rework GDK_Example
|
|
17
|
+
- [Dev] Early validate IDFA, GAId and update pattern of AmaDeviceId
|
|
18
|
+
- [Dev] Add device memory info to gdk_init
|
|
19
|
+
- [Dev] Do not use Dispatcher in Init phase (optimize for performance)
|
|
20
|
+
- [Dev] Reduce calls to DoOnMainThread for start stop GDKRoutine
|
|
21
|
+
- [Dev] Minor clean up
|
|
22
|
+
- [Dev] Add memory profiler
|
|
23
|
+
- [CI] Enable cache
|
|
24
|
+
- [Dev] Add Package Installer
|
|
25
|
+
- [Dev] Add Klavar event alias
|
|
26
|
+
- [CI] Disable CI cache temporarily
|
|
27
|
+
- [Dev] Use Array.Fill instead of loop
|
|
28
|
+
- [Fix] Clear cached audio buffer when not playing
|
|
29
|
+
- Revert "[Dev] Upgrade api level 34 for GDKDev"
|
|
30
|
+
- This reverts commit 6ea19dec18c3f2cb0a8000ae746bc58f0b3f3dc2.
|
|
31
|
+
- [Dev] Decouple IronSource AdQuality
|
|
32
|
+
- [Dev] Upgrade api level 34 for GDKDev
|
|
33
|
+
- [Dev] Improve GDKConfig
|
|
34
|
+
- [Dev] Upload test result as artifact
|
|
35
|
+
- [Dev] Add default-manifest for integration test project
|
|
36
|
+
- [CI] Enhance error handling in integration_test.sh
|
|
37
|
+
- [CI] update export-android job to wait for export-ios completion
|
|
38
|
+
- [Dev] Activate Unity license once during integration tests
|
|
39
|
+
- [Dev] Export Packages
|
|
40
|
+
- [Dev] Add AutoEventQC extra package
|
|
41
|
+
- [Dev] Integration test
|
|
42
|
+
- [Dev] Show consent config on Inspector
|
|
43
|
+
- [Dev] Ignore LevelPlay to keep the hard link locally
|
|
44
|
+
|
|
45
|
+
## [0.2.76] - 2024-11-07
|
|
46
|
+
|
|
47
|
+
## [0.2.75] - 2024-09-20
|
|
48
|
+
- [Dev] Use GDKUtils.StartCoroutine to capture exceptions
|
|
49
|
+
- [Fix] Initialize modules lazily to fix AmaGDK serialization layout mismatch
|
|
50
|
+
|
|
3
51
|
## [0.2.74] - 2024-09-17
|
|
4
52
|
- [Dev] Add GDKAudio Example
|
|
5
53
|
- [Feature] Add AudioSource fallback for unsupported platforms
|
package/Editor/AmaGDKEditor.cs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
using System;
|
|
1
|
+
using System;
|
|
2
2
|
using System.Collections.Generic;
|
|
3
3
|
using System.IO;
|
|
4
4
|
using System.Linq;
|
|
@@ -24,11 +24,11 @@ namespace Amanotes.Editor
|
|
|
24
24
|
private static readonly Color ORANGE = new Color32(0xFF, 0xC0, 0x00, 0xFF);
|
|
25
25
|
|
|
26
26
|
[NonSerialized] private static AmaGDK sdk;
|
|
27
|
-
[NonSerialized] private static ConfigAsset configAsset;
|
|
28
27
|
[NonSerialized] private static UnityObject invalidConfigAsset;
|
|
29
28
|
[NonSerialized] private static SerializedObject configSO;
|
|
30
29
|
[NonSerialized] private static UnityEditor.Editor editor;
|
|
31
30
|
|
|
31
|
+
private static ConfigAsset configAsset => AmaGDK.Config;
|
|
32
32
|
private static bool showIRSAdapter;
|
|
33
33
|
private static bool showConfigDetail;
|
|
34
34
|
private static bool showAdapterInstaller;
|
|
@@ -62,7 +62,7 @@ namespace Amanotes.Editor
|
|
|
62
62
|
|
|
63
63
|
SDKStatus.ClearCache();
|
|
64
64
|
RefreshConfigStatus();
|
|
65
|
-
|
|
65
|
+
RefreshListAdapters();
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
internal enum ConfigAssetStatus
|
|
@@ -92,7 +92,6 @@ namespace Amanotes.Editor
|
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
configAsset = Resources.Load<ConfigAsset>("AmaGDKConfig");
|
|
96
95
|
cfgStatus = configAsset != null ? ConfigAssetStatus.AssetOk : ConfigAssetStatus.AssetIsInvalid;
|
|
97
96
|
if (cfgStatus == ConfigAssetStatus.AssetOk) adapterScanned = false;
|
|
98
97
|
}
|
|
@@ -277,12 +276,7 @@ namespace Amanotes.Editor
|
|
|
277
276
|
{
|
|
278
277
|
if (AmaGUI.BigButton("CREATE", 40f, BLUE))
|
|
279
278
|
{
|
|
280
|
-
|
|
281
|
-
var resourcePath = "Assets/AmaGDK/Resources";
|
|
282
|
-
Directory.CreateDirectory(resourcePath);
|
|
283
|
-
|
|
284
|
-
AssetDatabase.CreateAsset(config, Path.Combine(resourcePath, "AmaGDKConfig.asset"));
|
|
285
|
-
AssetDatabase.SaveAssets();
|
|
279
|
+
CreateGDKConfig();
|
|
286
280
|
RefreshConfigStatus();
|
|
287
281
|
}
|
|
288
282
|
|
|
@@ -308,6 +302,16 @@ namespace Amanotes.Editor
|
|
|
308
302
|
GUILayout.ExpandWidth(true));
|
|
309
303
|
}
|
|
310
304
|
|
|
305
|
+
internal static void CreateGDKConfig()
|
|
306
|
+
{
|
|
307
|
+
ScriptableObject config = CreateInstance("Amanotes.Core.AmaGDKConfigAsset");
|
|
308
|
+
var resourcePath = "Assets/AmaGDK/Resources";
|
|
309
|
+
Directory.CreateDirectory(resourcePath);
|
|
310
|
+
|
|
311
|
+
AssetDatabase.CreateAsset(config, Path.Combine(resourcePath, "AmaGDKConfig.asset"));
|
|
312
|
+
AssetDatabase.SaveAssets();
|
|
313
|
+
}
|
|
314
|
+
|
|
311
315
|
public override void OnInspectorGUI()
|
|
312
316
|
{
|
|
313
317
|
Profiler.BeginSample("GDKEditor.OnInspectorGUI()");
|
|
@@ -359,6 +363,7 @@ namespace Amanotes.Editor
|
|
|
359
363
|
DrawProperty(configSO, "enableAudioModule", false);
|
|
360
364
|
DrawProperty(configSO, "enableServerTime", false);
|
|
361
365
|
DrawProperty(configSO, "enableGeoLocation", false);
|
|
366
|
+
DrawProperty(configSO, "autoGetConsent", false);
|
|
362
367
|
GUILayout.Space(8f);
|
|
363
368
|
|
|
364
369
|
for (var i = 0; i < allAdapters.Count; i++)
|
|
@@ -378,6 +383,13 @@ namespace Amanotes.Editor
|
|
|
378
383
|
GDKAutoUpdateAdapter.ImportAdapters();
|
|
379
384
|
}
|
|
380
385
|
|
|
386
|
+
// Always apply changes to the config asset, but only save to disk if not in play mode
|
|
387
|
+
if (configSO.ApplyModifiedProperties() && !Application.isPlaying)
|
|
388
|
+
{
|
|
389
|
+
EditorUtility.SetDirty(configAsset);
|
|
390
|
+
AssetDatabase.SaveAssets();
|
|
391
|
+
}
|
|
392
|
+
|
|
381
393
|
Profiler.EndSample();
|
|
382
394
|
}
|
|
383
395
|
|
|
@@ -553,7 +565,6 @@ namespace Amanotes.Editor
|
|
|
553
565
|
if (adapter is RemoteConfigAdapter) EditorGUILayout.PropertyField(configSO.FindProperty("remoteConfig"), new GUIContent("Shared settings for Remote Config Modules"));
|
|
554
566
|
GUI.contentColor = c;
|
|
555
567
|
}
|
|
556
|
-
configSO.ApplyModifiedProperties();
|
|
557
568
|
}
|
|
558
569
|
EditorGUIUtility.labelWidth -= 70;
|
|
559
570
|
EditorGUI.EndDisabledGroup();
|
|
@@ -578,11 +589,9 @@ namespace Amanotes.Editor
|
|
|
578
589
|
while (property.NextVisible(first))
|
|
579
590
|
{
|
|
580
591
|
first = false;
|
|
581
|
-
if (!property.propertyPath.Contains(basePath)) break;
|
|
582
|
-
EditorGUILayout.PropertyField(property);
|
|
592
|
+
if (!property.propertyPath.Contains(basePath)) break;
|
|
593
|
+
EditorGUILayout.PropertyField(property);
|
|
583
594
|
}
|
|
584
|
-
|
|
585
|
-
so.ApplyModifiedProperties();
|
|
586
595
|
}
|
|
587
596
|
|
|
588
597
|
private static Adapter2 GetAdapter(string id)
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.IO;
|
|
3
|
+
using System.Linq;
|
|
4
|
+
using System.Text.RegularExpressions;
|
|
5
|
+
using Amanotes.Core;
|
|
6
|
+
using UnityEditor;
|
|
7
|
+
using UnityEditor.PackageManager;
|
|
8
|
+
using UnityEditor.PackageManager.Requests;
|
|
9
|
+
using UnityEngine;
|
|
10
|
+
|
|
11
|
+
namespace Amanotes.Editor
|
|
12
|
+
{
|
|
13
|
+
[System.Serializable]
|
|
14
|
+
internal class ScopedRegistry
|
|
15
|
+
{
|
|
16
|
+
public string name;
|
|
17
|
+
public string url;
|
|
18
|
+
public string[] scopes;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
[System.Serializable]
|
|
22
|
+
internal class ScopedRegistries
|
|
23
|
+
{
|
|
24
|
+
public ScopedRegistry[] scopedRegistries;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
internal class GDKPackageInstaller
|
|
28
|
+
{
|
|
29
|
+
private static AddRequest _addRequest;
|
|
30
|
+
private static Action _onAddRequestCompleted;
|
|
31
|
+
|
|
32
|
+
internal static void AddScope(string name, string url, string[] scopes)
|
|
33
|
+
{
|
|
34
|
+
try
|
|
35
|
+
{
|
|
36
|
+
const string manifestPath = "Packages/manifest.json";
|
|
37
|
+
var manifestJson = File.ReadAllText(manifestPath);
|
|
38
|
+
|
|
39
|
+
var registries = JsonUtility.FromJson<ScopedRegistries>(manifestJson);
|
|
40
|
+
var scopedRegistry = registries.scopedRegistries;
|
|
41
|
+
|
|
42
|
+
if (scopedRegistry != null)
|
|
43
|
+
{
|
|
44
|
+
if(IsScopesExist(scopes, scopedRegistry))
|
|
45
|
+
return;
|
|
46
|
+
Array.Resize(ref registries.scopedRegistries, scopedRegistry.Length + 1);
|
|
47
|
+
}
|
|
48
|
+
else
|
|
49
|
+
{
|
|
50
|
+
registries.scopedRegistries = new ScopedRegistry[1];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
registries.scopedRegistries[registries.scopedRegistries.Length - 1] = new ScopedRegistry
|
|
54
|
+
{
|
|
55
|
+
name = name,
|
|
56
|
+
scopes = scopes,
|
|
57
|
+
url = url
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const string pattern = "\"dependencies\"\\s*:\\s*\\{(.+?)\\}";
|
|
61
|
+
Match match = Regex.Match(manifestJson, pattern, RegexOptions.Singleline);
|
|
62
|
+
manifestJson = "{" + $"{match.Value},{JsonUtility.ToJson(registries).Remove(0, 1)}";
|
|
63
|
+
File.WriteAllText(manifestPath, manifestJson);
|
|
64
|
+
|
|
65
|
+
// Double check
|
|
66
|
+
manifestJson = File.ReadAllText(manifestPath);
|
|
67
|
+
registries = JsonUtility.FromJson<ScopedRegistries>(manifestJson);
|
|
68
|
+
scopedRegistry = registries.scopedRegistries;
|
|
69
|
+
|
|
70
|
+
if (scopedRegistry == null || IsScopesExist(scopes, scopedRegistry) == false)
|
|
71
|
+
{
|
|
72
|
+
Debug.LogWarning("Failed to add new scopes to the manifest");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
|
|
76
|
+
Client.Resolve();
|
|
77
|
+
Debug.Log("Successfully add new scopes to the manifest");
|
|
78
|
+
}
|
|
79
|
+
catch (IOException e)
|
|
80
|
+
{
|
|
81
|
+
Debug.LogWarning($"Failed to add new scopes to the manifest : {e}");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private static bool IsScopesExist(string[] scopes, ScopedRegistry[] scopedRegistries)
|
|
86
|
+
{
|
|
87
|
+
return scopes.All(scopeToCheck => scopedRegistries
|
|
88
|
+
.SelectMany(registry => registry.scopes)
|
|
89
|
+
.Any(scope => scope.ToString() == scopeToCheck));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
internal static void InstallPackage(string package, Action callback)
|
|
93
|
+
{
|
|
94
|
+
EditorApplication.update -= AddPackageProgress;
|
|
95
|
+
EditorApplication.update += AddPackageProgress;
|
|
96
|
+
_addRequest = Client.Add(package);
|
|
97
|
+
_onAddRequestCompleted = callback;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private static void AddPackageProgress()
|
|
101
|
+
{
|
|
102
|
+
if (_addRequest == null || _addRequest.IsCompleted == false)
|
|
103
|
+
return;
|
|
104
|
+
if (_addRequest.Status == StatusCode.Success)
|
|
105
|
+
{
|
|
106
|
+
EditorApplication.update -= AddPackageProgress;
|
|
107
|
+
_onAddRequestCompleted?.Invoke();
|
|
108
|
+
}
|
|
109
|
+
else if (_addRequest.Status == StatusCode.Failure)
|
|
110
|
+
{
|
|
111
|
+
Debug.LogWarning("Fail to add new package");
|
|
112
|
+
}
|
|
113
|
+
_addRequest = null;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/Runtime/Ad/AdLogic.cs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
using System;
|
|
1
2
|
using System.Collections;
|
|
2
3
|
using UnityEngine;
|
|
3
4
|
using static Amanotes.Core.GDKDebug;
|
|
@@ -27,7 +28,7 @@ namespace Amanotes.Core.Internal
|
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
internal
|
|
31
|
+
internal GDKRoutine _loadRoutine;
|
|
31
32
|
|
|
32
33
|
public void StartLoadAd()
|
|
33
34
|
{
|
|
@@ -38,7 +39,7 @@ namespace Amanotes.Core.Internal
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
Log("[Ad] StartLoadAd");
|
|
41
|
-
_loadRoutine =
|
|
42
|
+
_loadRoutine = GDKUtils.StartCoroutine(LoadAdRoutine());
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
public void StopLoadAd()
|
|
@@ -48,9 +49,8 @@ namespace Amanotes.Core.Internal
|
|
|
48
49
|
{
|
|
49
50
|
_loadState = LoadAdsState.None;
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
_instance.StopCoroutine(_loadRoutine);
|
|
52
|
+
|
|
53
|
+
_loadRoutine?.StopRoutine();
|
|
54
54
|
_loadRoutine = null;
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -128,21 +128,12 @@ namespace Amanotes.Core.Internal
|
|
|
128
128
|
|
|
129
129
|
// Show Ad logic
|
|
130
130
|
internal ShowAdsState _showState = ShowAdsState.None;
|
|
131
|
-
private
|
|
131
|
+
private GDKRoutine _showAdRoutine;
|
|
132
132
|
protected bool _isRequesting;
|
|
133
133
|
protected bool _isInterstitial => adType == AdType.Interstitial;
|
|
134
134
|
|
|
135
|
-
// Do not warn unused variable, it's been use outside of Editor (Runtime)
|
|
136
|
-
#pragma warning disable
|
|
137
|
-
private bool isFocus;
|
|
138
|
-
#pragma warning enable
|
|
139
|
-
|
|
140
135
|
public void StartShowAd()
|
|
141
136
|
{
|
|
142
|
-
isFocus = false;
|
|
143
|
-
unityCallbacks.OnApplicationFocus -= OnApplicationFocus;
|
|
144
|
-
unityCallbacks.OnApplicationFocus += OnApplicationFocus;
|
|
145
|
-
|
|
146
137
|
if (_showState != ShowAdsState.None)
|
|
147
138
|
{
|
|
148
139
|
LogWarning("[Ad] StartShowAd() --> Invalid _showState: " + _showState);
|
|
@@ -160,16 +151,8 @@ namespace Amanotes.Core.Internal
|
|
|
160
151
|
_isInterstitial ? AmaGDK.Event.INTER_SHOW_CALLED : AmaGDK.Event.REWARD_VIDEO_SHOW_CALLED
|
|
161
152
|
);
|
|
162
153
|
|
|
163
|
-
if (_showAdRoutine != null)
|
|
164
|
-
_showAdRoutine =
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
private void OnApplicationFocus(bool focus)
|
|
168
|
-
{
|
|
169
|
-
if (!focus) return;
|
|
170
|
-
|
|
171
|
-
unityCallbacks.OnApplicationFocus -= OnApplicationFocus;
|
|
172
|
-
isFocus = true;
|
|
154
|
+
if (_showAdRoutine != null) _showAdRoutine.StopRoutine();
|
|
155
|
+
_showAdRoutine = GDKUtils.StartCoroutine(ShowAdRoutine());
|
|
173
156
|
}
|
|
174
157
|
|
|
175
158
|
public void StopShowAd()
|
|
@@ -184,7 +167,7 @@ namespace Amanotes.Core.Internal
|
|
|
184
167
|
|
|
185
168
|
TriggerOnAfterAdShow();
|
|
186
169
|
if (_showAdRoutine == null) return;
|
|
187
|
-
|
|
170
|
+
_showAdRoutine.StopRoutine();
|
|
188
171
|
_showAdRoutine = null;
|
|
189
172
|
|
|
190
173
|
if (Ads.context.adType == AdType.Interstitial)
|
|
@@ -239,14 +222,59 @@ namespace Amanotes.Core.Internal
|
|
|
239
222
|
_showState = ShowAdsState.Showing;
|
|
240
223
|
OnAdShowReadyStatus(true, AdShowReadyStatus.Ready);
|
|
241
224
|
TriggerBeforeAdShow();
|
|
225
|
+
#if !UNITY_EDITOR && UNITY_ANDROID
|
|
226
|
+
GDKUtils.StartCoroutine(HandleAdActivityKilledSilently());
|
|
227
|
+
#endif
|
|
242
228
|
ShowAd();
|
|
243
|
-
|
|
244
229
|
yield return WaitForMediationCallback();
|
|
245
|
-
|
|
246
|
-
// wait 1 frame in case hasReward callback after onClose
|
|
247
|
-
if (!context.hasReward && adType == AdType.VideoReward && !context.hasFailedOrCancelled) yield return null;
|
|
248
230
|
ShowAdRoutineCompleted(context.isSuccess);
|
|
249
231
|
}
|
|
232
|
+
|
|
233
|
+
private IEnumerator WaitForMediationCallback()
|
|
234
|
+
{
|
|
235
|
+
while (context != null && !context.potentiallyCompleted)
|
|
236
|
+
{
|
|
237
|
+
yield return null;
|
|
238
|
+
}
|
|
239
|
+
// wait 1 frame in case hasReward callback after onClose
|
|
240
|
+
if (context != null && !context.hasReward && adType == AdType.VideoReward && !context.hasFailedOrCancelled) yield return null;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
private IEnumerator HandleAdActivityKilledSilently()
|
|
244
|
+
{
|
|
245
|
+
bool hasOutOfFocus = false;
|
|
246
|
+
bool hasFocusAgain = false;
|
|
247
|
+
Action<bool> onApplicationFocusCallback = focus =>
|
|
248
|
+
{
|
|
249
|
+
if (focus)
|
|
250
|
+
{
|
|
251
|
+
hasFocusAgain = true;
|
|
252
|
+
}
|
|
253
|
+
else
|
|
254
|
+
{
|
|
255
|
+
hasOutOfFocus = true;
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
unityCallbacks.OnApplicationFocus += onApplicationFocusCallback;
|
|
259
|
+
int counter = 0;
|
|
260
|
+
while (context != null && !context.potentiallyCompleted)
|
|
261
|
+
{
|
|
262
|
+
if (hasFocusAgain && hasOutOfFocus)
|
|
263
|
+
{
|
|
264
|
+
// Start counting frames only after closed the ad
|
|
265
|
+
counter++;
|
|
266
|
+
}
|
|
267
|
+
if (counter > MAX_FRAMES_WAIT_FOR_CALLBACK)
|
|
268
|
+
{
|
|
269
|
+
// Timeout reached, force close the ad
|
|
270
|
+
LogError("Force close the ad");
|
|
271
|
+
StopShowAd();
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
yield return null;
|
|
275
|
+
}
|
|
276
|
+
unityCallbacks.OnApplicationFocus -= onApplicationFocusCallback;
|
|
277
|
+
}
|
|
250
278
|
|
|
251
279
|
private void EndShowAdRoutineWithFailure(AdShowReadyStatus status)
|
|
252
280
|
{
|
|
@@ -260,7 +288,7 @@ namespace Amanotes.Core.Internal
|
|
|
260
288
|
if (_loadState != LoadAdsState.Requesting) StartLoadAd();
|
|
261
289
|
var counter = 0;
|
|
262
290
|
bool? hasInternet = null;
|
|
263
|
-
if (adConfig.checkInternet)
|
|
291
|
+
if (adConfig.checkInternet) GDKUtils.StartCoroutine(WebUtils.CheckInternet(result => hasInternet = result));
|
|
264
292
|
|
|
265
293
|
var wait1Sec = new WaitForSecondsRealtime(1f);
|
|
266
294
|
while (counter < timeout || timeout == -1)
|
|
@@ -281,40 +309,8 @@ namespace Amanotes.Core.Internal
|
|
|
281
309
|
Log("[Ad] WaitForAd success after " + counter + " | timeout = " + timeout + " secs");
|
|
282
310
|
break;
|
|
283
311
|
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
private IEnumerator WaitForMediationCallback()
|
|
287
|
-
{
|
|
288
|
-
#if UNITY_EDITOR
|
|
289
|
-
while (!context.hasClosed) yield return null;
|
|
290
|
-
yield break;
|
|
291
|
-
#endif
|
|
292
|
-
while (!isFocus) yield return null;
|
|
293
|
-
var wait4CallbackCounter = 0;
|
|
294
|
-
while (!context.potentiallyCompleted && wait4CallbackCounter <= MAX_FRAMES_WAIT_FOR_CALLBACK)
|
|
295
|
-
{
|
|
296
|
-
wait4CallbackCounter++;
|
|
297
|
-
yield return null;
|
|
298
|
-
}
|
|
299
|
-
Log($"[Ad] Waiting for potentially completed callback: {wait4CallbackCounter} frames");
|
|
300
|
-
|
|
301
|
-
if (!context.hasClosed) yield return WaitForAdClosedCallback();
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
private IEnumerator WaitForAdClosedCallback()
|
|
305
|
-
{
|
|
306
|
-
int counter = 0;
|
|
307
|
-
while (!context.hasClosed && counter <= MAX_FRAMES_WAIT_FOR_CALLBACK)
|
|
308
|
-
{
|
|
309
|
-
counter++;
|
|
310
|
-
yield return null;
|
|
311
|
-
}
|
|
312
|
-
Log($"[Ad] Waiting for ad closed callback: {counter} frames");
|
|
313
|
-
if (context.hasClosed) yield break;
|
|
314
|
-
LogWarning("[Ad] Force close ad (mediation missing OnAdClose callback)");
|
|
315
|
-
OnAdClosed();
|
|
316
|
-
}
|
|
317
|
-
|
|
312
|
+
}
|
|
313
|
+
|
|
318
314
|
private void ShowAdRoutineCompleted(bool isSuccess)
|
|
319
315
|
{
|
|
320
316
|
if (_loadState == LoadAdsState.Ready)
|
|
@@ -35,7 +35,7 @@ namespace Amanotes.Core.Internal
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
public bool hasFailedOrCancelled => (adCallback & (AdCallback.Fail | AdCallback.Cancel)) != 0;
|
|
38
|
-
public bool potentiallyCompleted => (adCallback & (AdCallback.Close | AdCallback.Fail | AdCallback.
|
|
38
|
+
public bool potentiallyCompleted => (adCallback & (AdCallback.Close | AdCallback.Fail | AdCallback.Cancel)) != 0;
|
|
39
39
|
public bool hasReward => (adCallback & AdCallback.Reward) != 0;
|
|
40
40
|
public bool hasClosed => (adCallback & AdCallback.Close) != 0;
|
|
41
41
|
public bool hasClicked => (adCallback & AdCallback.Click) != 0;
|
package/Runtime/Ad/AmaGDK.Ads.cs
CHANGED
|
@@ -108,7 +108,8 @@ namespace Amanotes.Core
|
|
|
108
108
|
public static bool allowAdRequest = true;
|
|
109
109
|
|
|
110
110
|
// internal use
|
|
111
|
-
|
|
111
|
+
private static readonly Lazy<AdsData> _localData = new Lazy<AdsData>(() => new AdsData().LoadJsonFromFile());
|
|
112
|
+
internal static AdsData localData => _localData.Value;
|
|
112
113
|
|
|
113
114
|
internal protected static AdShowContext context;
|
|
114
115
|
internal protected static AdAdapter _adapter;
|
|
@@ -197,6 +197,7 @@ namespace Amanotes.Core
|
|
|
197
197
|
var flag = IntegrityFlag.Ok;
|
|
198
198
|
|
|
199
199
|
if (funnelEvents != null)
|
|
200
|
+
{
|
|
200
201
|
foreach (string e in funnelEvents)
|
|
201
202
|
{
|
|
202
203
|
if (localData.funnelSignatures.Contains(e)) continue;
|
|
@@ -204,6 +205,7 @@ namespace Amanotes.Core
|
|
|
204
205
|
flag |= IntegrityFlag.NewFunnel;
|
|
205
206
|
localData.AddFunnelSignature(e);
|
|
206
207
|
}
|
|
208
|
+
}
|
|
207
209
|
|
|
208
210
|
if (eventCountMap != null)
|
|
209
211
|
{
|
|
@@ -308,9 +310,12 @@ namespace Amanotes.Core
|
|
|
308
310
|
internal static Predicate<EventParams> logEventHook;
|
|
309
311
|
internal static readonly ConcurrentQueue<EventParams> eventQueue = new ConcurrentQueue<EventParams>();
|
|
310
312
|
internal static readonly List<AnalyticsAdapter> listAdapters = new List<AnalyticsAdapter>();
|
|
311
|
-
internal static readonly AnalyticsData localData = new AnalyticsData().LoadJsonFromFile().BuildCache();
|
|
312
313
|
internal static SessionStat sessionStat;
|
|
313
314
|
internal static readonly GDKPool.Pool<EventParams> epPool = new GDKPool.Pool<EventParams>(1);
|
|
315
|
+
|
|
316
|
+
private static readonly Lazy<AnalyticsData> _localData = new Lazy<AnalyticsData>(
|
|
317
|
+
() => new AnalyticsData().LoadJsonFromFile().BuildCache());
|
|
318
|
+
internal static AnalyticsData localData => _localData.Value;
|
|
314
319
|
|
|
315
320
|
internal static readonly Dictionary<string, string> reservedPrefixes = new Dictionary<string, string>()
|
|
316
321
|
{
|
|
@@ -413,7 +418,11 @@ namespace Amanotes.Core
|
|
|
413
418
|
|
|
414
419
|
while (eventQueue.TryDequeue(out var eventData))
|
|
415
420
|
{
|
|
416
|
-
if (eventData.isLoggedImmediately)
|
|
421
|
+
if (eventData.isLoggedImmediately)
|
|
422
|
+
{
|
|
423
|
+
epPool.Return(eventData);
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
417
426
|
if (Config.analytics.immediatelyLoggedEvents.Contains(eventData.eventName)){
|
|
418
427
|
GDKUtils.ThrowExceptionIfEditor($"This event '{eventData.eventName}' must be sent immediately by AmaGDK.Analytics.LogEvent(eventName).LogImmediately()");
|
|
419
428
|
}
|
|
@@ -474,7 +483,6 @@ namespace Amanotes.Core
|
|
|
474
483
|
internal static void LogEventImmediately(EventParams eventParams)
|
|
475
484
|
{
|
|
476
485
|
LogEventActually(eventParams);
|
|
477
|
-
epPool.Return(eventParams);
|
|
478
486
|
sessionStat?.Save();
|
|
479
487
|
localData.SaveIfDirty();
|
|
480
488
|
}
|
|
@@ -482,25 +490,23 @@ namespace Amanotes.Core
|
|
|
482
490
|
internal static void UpdateAccumulatedCount(EventParams eventData, int countInSession, ref int totalCount)
|
|
483
491
|
{
|
|
484
492
|
var ACCUMULATED_COUNT = "accumulated_count";
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
if (!eventData.parameters.ContainsKey(ACCUMULATED_COUNT))
|
|
493
|
+
int countByGDK = eventData.withinSession ? countInSession : totalCount;
|
|
494
|
+
if (!eventData.parameters.TryGetValue(ACCUMULATED_COUNT, out object countByGame))
|
|
488
495
|
{
|
|
489
496
|
eventData.AddParam(ACCUMULATED_COUNT, countByGDK);
|
|
490
497
|
return;
|
|
491
498
|
}
|
|
492
499
|
|
|
493
|
-
int.TryParse(
|
|
494
|
-
if (oriAccCount
|
|
500
|
+
int.TryParse(countByGame.ToString(), out int oriAccCount);
|
|
501
|
+
if (oriAccCount == countByGDK) return;
|
|
502
|
+
|
|
503
|
+
// Log($"[Analytics] event <{eventData.eventName}>, game count: {oriAccCount}, AmaGDK count: {countByGDK}");
|
|
504
|
+
if (Config.analytics.migrateAccumulatedCount && !eventData.withinSession)
|
|
495
505
|
{
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
eventData.detail.totalCount = oriAccCount;
|
|
501
|
-
totalCount = oriAccCount;
|
|
502
|
-
localData._dirty = true;
|
|
503
|
-
}
|
|
506
|
+
Log($"[Analytics] Update event count of event <{eventData.eventName}> from {countByGDK} to {oriAccCount}");
|
|
507
|
+
eventData.detail.totalCount = oriAccCount;
|
|
508
|
+
totalCount = oriAccCount;
|
|
509
|
+
localData._dirty = true;
|
|
504
510
|
}
|
|
505
511
|
}
|
|
506
512
|
|