com.amanotes.gdk 0.2.81-alpha.14 → 0.2.81-alpha.17

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 (32) hide show
  1. package/Extra/ABLab.unitypackage +0 -0
  2. package/Extra/ABLab.unitypackage.meta +7 -0
  3. package/Extra/AmaGDKInstaller.unitypackage +0 -0
  4. package/Extra/AutoEventQC.unitypackage +0 -0
  5. package/Extra/CheckDiskSpace.unitypackage +0 -0
  6. package/Extra/Consent.unitypackage +0 -0
  7. package/Extra/CrashlyticHook.unitypackage +0 -0
  8. package/Extra/ForceUpdate.unitypackage +0 -0
  9. package/Extra/LegacyGDKUpdateHelper.unitypackage +0 -0
  10. package/Extra/PostProcessor.unitypackage +0 -0
  11. package/Packages/AmaGDKConfig.unitypackage +0 -0
  12. package/Packages/AmaGDKExample.unitypackage +0 -0
  13. package/Packages/AmaGDKTest.unitypackage +0 -0
  14. package/Packages/AppsFlyerAdapter.PurchaseConnector.unitypackage +0 -0
  15. package/Packages/AppsFlyerAdapter.unitypackage +0 -0
  16. package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
  17. package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
  18. package/Packages/IronSourceAdapter.AdQuality.unitypackage +0 -0
  19. package/Packages/IronSourceAdapter.unitypackage +0 -0
  20. package/Packages/MaxAdNetworkAdapter.unitypackage +0 -0
  21. package/Packages/RevenueCatAdapter.unitypackage +0 -0
  22. package/Packages/SqliteAnalyticsAdapter.unitypackage +0 -0
  23. package/Runtime/Ad/AmaGDK.Ads.cs +8 -5
  24. package/Runtime/AmaGDK.Analytics.cs +8 -5
  25. package/Runtime/AmaGDK.IAP.cs +5 -4
  26. package/Runtime/AmaGDK.Mono.cs +19 -1
  27. package/Runtime/AmaGDK.RemoteConfig.cs +3 -1
  28. package/Runtime/AmaGDK.Singleton.cs +2 -1
  29. package/Runtime/AmaGDK.asmdef +3 -1
  30. package/Runtime/AmaGDK.cs +52 -48
  31. package/Runtime/Consent/AmaGDK.Consent.cs +5 -4
  32. package/package.json +30 -18
Binary file
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 092a3e310bfa5423db4dc58ea256a62a
3
+ DefaultImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -3,7 +3,7 @@ using System.Collections;
3
3
  using System.Collections.Generic;
4
4
  using UnityEngine;
5
5
  using Amanotes.Core.Internal;
6
-
6
+ using Cysharp.Threading.Tasks;
7
7
  using static Amanotes.Core.GDKDebug;
8
8
  using static Amanotes.Core.AmaGDK;
9
9
 
@@ -108,8 +108,7 @@ namespace Amanotes.Core
108
108
  public static bool allowAdRequest = true;
109
109
 
110
110
  // internal use
111
- private static readonly Lazy<AdsData> _localData = new Lazy<AdsData>(() => new AdsData().LoadJsonFromFile());
112
- internal static AdsData localData => _localData.Value;
111
+ internal static AdsData localData;
113
112
 
114
113
  internal protected static AdShowContext context;
115
114
  internal protected static AdAdapter _adapter;
@@ -154,14 +153,18 @@ namespace Amanotes.Core
154
153
 
155
154
  public partial class Ads // Public
156
155
  {
157
- internal static bool InitModule()
156
+ internal static async UniTask InitModule()
158
157
  {
158
+ await UniTask.SwitchToThreadPool();
159
159
  if (Adapter2.GetAllAdapter<AdAdapter>().Count > 1)
160
160
  {
161
161
  GDKUtils.ThrowExceptionIfEditor("Multiple AdAdapters is not supported!");
162
162
  }
163
163
  _adapter = Adapter2.GetAdapter<AdAdapter>();
164
- return _adapter != null;
164
+ if(_adapter != null)
165
+ {
166
+ localData = new AdsData().LoadJsonFromFile();
167
+ }
165
168
  }
166
169
 
167
170
  internal static void StartModule()
@@ -3,6 +3,7 @@ using System.Collections.Concurrent;
3
3
  using System.Collections.Generic;
4
4
  using System.Text;
5
5
  using Amanotes.Core.Internal;
6
+ using Cysharp.Threading.Tasks;
6
7
  using UnityEngine;
7
8
  using UnityEngine.Profiling;
8
9
  using static Amanotes.Core.AmaGDK.Analytics;
@@ -311,10 +312,7 @@ namespace Amanotes.Core
311
312
  internal static readonly List<AnalyticsAdapter> listAdapters = new List<AnalyticsAdapter>();
312
313
  internal static SessionStat sessionStat;
313
314
  internal static readonly GDKPool.Pool<EventParams> epPool = new GDKPool.Pool<EventParams>(1);
314
-
315
- private static readonly Lazy<AnalyticsData> _localData = new Lazy<AnalyticsData>(
316
- () => new AnalyticsData().LoadJsonFromFile().BuildCache());
317
- internal static AnalyticsData localData => _localData.Value;
315
+ internal static AnalyticsData localData;
318
316
 
319
317
  internal static readonly Dictionary<string, string> reservedPrefixes = new Dictionary<string, string>()
320
318
  {
@@ -358,14 +356,19 @@ namespace Amanotes.Core
358
356
  "user_engagement"
359
357
  };
360
358
 
361
- internal static void InitModule()
359
+ internal static async UniTask InitModule()
362
360
  {
361
+ await UniTask.SwitchToThreadPool();
363
362
  if (Config.analytics.enableEventStat)
364
363
  {
365
364
  sessionStat = new SessionStat();
366
365
  }
367
366
  listAdapters.Clear();
368
367
  listAdapters.AddRange(Adapter2.GetAllAdapter<AnalyticsAdapter>());
368
+ if (listAdapters.Count > 0)
369
+ {
370
+ localData = new AnalyticsData().LoadJsonFromFile().BuildCache();
371
+ }
369
372
  }
370
373
 
371
374
  internal static void StartModule()
@@ -4,7 +4,7 @@ using System.Collections.Generic;
4
4
  using System.Globalization;
5
5
  using UnityEngine;
6
6
  using Amanotes.Core.Internal;
7
-
7
+ using Cysharp.Threading.Tasks;
8
8
  using static Amanotes.Core.AmaGDK.IAP;
9
9
  using static Amanotes.Core.GDKDebug;
10
10
 
@@ -176,12 +176,13 @@ namespace Amanotes.Core
176
176
 
177
177
  private static bool IsModuleReady => _syncTaskTracker.HasCompleted && _getProductsTaskTracker.HasCompleted;
178
178
  private static Action _onModuleReady;
179
- internal static bool InitModule()
179
+ internal static async UniTask InitModule()
180
180
  {
181
+ await UniTask.SwitchToThreadPool();
181
182
  _adapter = Adapter2.GetAdapter<IAPAdapter>();
182
- if (_adapter == null) return false;
183
+ if (_adapter == null)
184
+ return;
183
185
  localData = new IAPData().LoadJsonFromFile();
184
- return true;
185
186
  }
186
187
 
187
188
  internal static void StartModule()
@@ -3,6 +3,7 @@ using System;
3
3
  using System.Collections;
4
4
  using System.Collections.Generic;
5
5
  using System.Threading;
6
+ using Cysharp.Threading.Tasks;
6
7
  using UnityEngine;
7
8
 
8
9
  namespace Amanotes.Core
@@ -78,7 +79,18 @@ namespace Amanotes.Core.Internal
78
79
  {
79
80
  StartCoroutine(DelayCallRoutine(seconds, action));
80
81
  }
81
-
82
+
83
+ public static async UniTask TimeoutTask(float timeoutInSecs, Func<bool> completeCheckFunc)
84
+ {
85
+ float time = Time.realtimeSinceStartup;
86
+ while (completeCheckFunc() == false)
87
+ {
88
+ await UniTask.Yield();
89
+ if (Time.realtimeSinceStartup - time > timeoutInSecs)
90
+ return;
91
+ }
92
+ }
93
+
82
94
  public static IEnumerator Timeout(float timeoutInSecs, Func<bool> completeCheckFunc)
83
95
  {
84
96
  float time = Time.realtimeSinceStartup;
@@ -88,6 +100,12 @@ namespace Amanotes.Core.Internal
88
100
  if (Time.realtimeSinceStartup - time > timeoutInSecs) yield break;
89
101
  }
90
102
  }
103
+
104
+ private static async UniTask DelayCallRoutineTask(float seconds, Action callback)
105
+ {
106
+ await UniTask.Delay(TimeSpan.FromSeconds(seconds));
107
+ callback();
108
+ }
91
109
 
92
110
  private static IEnumerator DelayCallRoutine(float seconds, Action callback)
93
111
  {
@@ -5,6 +5,7 @@ using System.IO;
5
5
  using System.Text;
6
6
  using UnityEngine;
7
7
  using Amanotes.Core.Internal;
8
+ using Cysharp.Threading.Tasks;
8
9
  using UnityEngine.Profiling;
9
10
  using UnityEngine.Serialization;
10
11
  using static Amanotes.Core.GDKDebug;
@@ -173,8 +174,9 @@ namespace Amanotes.Core
173
174
  actions[result ? 1 : 0]();
174
175
  }
175
176
 
176
- internal static void InitModule()
177
+ internal static async UniTask InitModule()
177
178
  {
179
+ await UniTask.SwitchToThreadPool();
178
180
  adapter = Adapter2.GetAdapter<RemoteConfigAdapter>();
179
181
  }
180
182
 
@@ -1,6 +1,7 @@
1
1
 
2
2
  using Amanotes.Core.Internal;
3
3
  using System.Threading;
4
+ using Cysharp.Threading.Tasks;
4
5
  using static Amanotes.Core.GDKDebug;
5
6
  using static Amanotes.Core.Internal.Messsage;
6
7
 
@@ -23,7 +24,7 @@ namespace Amanotes.Core
23
24
  mainThreadId = Thread.CurrentThread.ManagedThreadId;
24
25
  DontDestroyOnLoad(this);
25
26
 
26
- GDKUtils.StartCoroutine(InitRoutine());
27
+ InitRoutine().Forget();
27
28
  }
28
29
  }
29
30
  }
@@ -1,7 +1,9 @@
1
1
  {
2
2
  "name": "AmaGDK",
3
3
  "rootNamespace": "",
4
- "references": [],
4
+ "references": [
5
+ "UniTask"
6
+ ],
5
7
  "includePlatforms": [],
6
8
  "excludePlatforms": [],
7
9
  "allowUnsafeCode": true,
package/Runtime/AmaGDK.cs CHANGED
@@ -15,6 +15,7 @@ using Amanotes.Core.Internal;
15
15
  using static Amanotes.Core.GDKDebug;
16
16
  using static Amanotes.Core.Internal.Messsage;
17
17
  using System.Threading.Tasks;
18
+ using Cysharp.Threading.Tasks;
18
19
 
19
20
 
20
21
  #if UNITY_EDITOR
@@ -27,7 +28,7 @@ namespace Amanotes.Core
27
28
  {
28
29
  public partial class AmaGDK : MonoBehaviour
29
30
  {
30
- public const string VERSION = "v0.2.81-alpha.14";
31
+ public const string VERSION = "v0.2.81-alpha.17";
31
32
 
32
33
  internal static Status _status = Status.None;
33
34
  internal static ConfigAsset _config = null;
@@ -81,8 +82,8 @@ namespace Amanotes.Core
81
82
  return _config;
82
83
  }
83
84
  }
84
-
85
- IEnumerator InitHook()
85
+
86
+ async UniTask InitHook()
86
87
  {
87
88
  // dispatcher.Dispatch(Event.GDK_HOOK_START);
88
89
  if (_onHookStart!= null) GDKUtils.SafeInvokeAndClear(ref _onHookStart);
@@ -91,24 +92,23 @@ namespace Amanotes.Core
91
92
  {
92
93
  Log($"[Hook] No hook registered!");
93
94
  if (_onHookEnd!= null) GDKUtils.SafeInvokeAndClear(ref _onHookEnd);
94
- yield break;
95
+ return;
95
96
  }
96
-
97
+
97
98
  //TODO: Sort Hook by orderId
98
99
  var hookCompleted = false;
99
-
100
+
100
101
  float stTime = Time.realtimeSinceStartup;
101
102
  Hook.TriggerHooks(() =>
102
103
  {
103
104
  hookCompleted = true;
104
105
  });
105
- yield return new WaitUntil(() => hookCompleted);
106
+ await UniTask.WaitUntil(() => hookCompleted);
106
107
  float elapsed = Time.realtimeSinceStartup - stTime;
107
108
  Log($"[Hook] {nHooks} hooks complete after {elapsed} secs");
108
109
  if (_onHookEnd!= null) GDKUtils.SafeInvokeAndClear(ref _onHookEnd);
109
110
  }
110
-
111
- IEnumerator WaitForManualInit()
111
+ async UniTask WaitForManualInit()
112
112
  {
113
113
  var counter = 0;
114
114
  const int INIT_TOLERANCE = 10 * 60;
@@ -117,7 +117,7 @@ namespace Amanotes.Core
117
117
  while (!_allowInit)
118
118
  {
119
119
  counter++;
120
- yield return null;
120
+ await UniTask.Yield();
121
121
 
122
122
  if (counter > INIT_TOLERANCE && counter % INIT_WARN_CYCLE == 1)
123
123
  {
@@ -126,17 +126,20 @@ namespace Amanotes.Core
126
126
  }
127
127
  }
128
128
 
129
- void InitModules()
129
+ async UniTask InitModules()
130
130
  {
131
131
  Profiler.BeginSample("AmaGDK.InitModules()");
132
132
  {
133
133
  User.InitModule();
134
- Consent.InitModule();
135
- Analytics.InitModule();
136
- Ads.InitModule();
137
- IAP.InitModule();
138
- RemoteConfig.InitModule();
139
- if (Config.enableAudioModule) Audio.InitModule();
134
+ if (Config.enableAudioModule)
135
+ {
136
+ Audio.InitModule();
137
+ }
138
+ await Consent.InitModule();
139
+ await Analytics.InitModule();
140
+ await Ads.InitModule();
141
+ await IAP.InitModule();
142
+ await RemoteConfig.InitModule();
140
143
  }
141
144
  Profiler.EndSample();
142
145
  }
@@ -154,13 +157,13 @@ namespace Amanotes.Core
154
157
  Profiler.EndSample();
155
158
  }
156
159
 
157
- IEnumerator InitAdapters(StringBuilder sb)
160
+ async UniTask InitAdapters(StringBuilder sb)
158
161
  {
159
162
  // sort on priority
160
163
  List<Adapter2> listAdapters = Adapter2.adapterMap
161
164
  .Values.ToList();
162
165
  listAdapters.Sort((a1, a2) => a1.initOrder.CompareTo(a2.initOrder));
163
-
166
+
164
167
  foreach (Adapter2 adapter in listAdapters)
165
168
  {
166
169
  if (!adapter.enabled)
@@ -168,7 +171,7 @@ namespace Amanotes.Core
168
171
  Log($"Adapter <{adapter.adapterId} is disabled!");
169
172
  continue;
170
173
  }
171
-
174
+
172
175
  // Log($"Initiating {adapter.adapterId} --> initOrder: {adapter.initOrder} | {adapter.status}");
173
176
  var startTime = Time.realtimeSinceStartup;
174
177
  Profiler.BeginSample($"AmaGDK.adapter.InitSDK-{adapter.adapterId}");
@@ -178,9 +181,9 @@ namespace Amanotes.Core
178
181
  if (adapter.status != Status.Ready)
179
182
  {
180
183
  var beginTime = Time.realtimeSinceStartup;
181
- yield return GDKUtils.Timeout(adapter.Timeout,() => adapter.status != Status.Initialize);
182
- var endTime = Time.realtimeSinceStartup;
183
-
184
+ await GDKUtils.TimeoutTask(adapter.Timeout,() => adapter.status != Status.Initialize);
185
+ var endTime = Time.realtimeSinceStartup;
186
+
184
187
  if (adapter.status == Status.Initialize)
185
188
  {
186
189
  LogWarning($"{adapter.adapterId} init time out: {adapter.Timeout:#0.00}");
@@ -189,65 +192,66 @@ namespace Amanotes.Core
189
192
  Log($"{adapter.adapterId} init took: {(endTime-beginTime):#0.00} s");
190
193
  }
191
194
  }
192
-
195
+
193
196
  GDKUtils.SafeInvoke(_onAdapterReady, adapter.adapterId);
194
197
  sb.AppendLine($"[{(adapter.IsReady ? " OK " : "FAIL")}] {adapter.adapterId} (~ {Time.realtimeSinceStartup - startTime:#0.00}s)");
195
-
198
+
196
199
  // Wait for postprocessing of each adapter
197
- yield return null;
200
+ await UniTask.Yield();
198
201
  }
199
202
  }
200
-
201
- IEnumerator InitRoutine()
203
+
204
+ public async UniTask InitRoutine()
202
205
  {
203
206
  _allowInit = _allowInit || autoInit;
204
-
207
+
205
208
  if (Config == null)
206
209
  {
207
210
  throw new Exception("[AmaGDK] " + CONFIG_NOT_FOUND);
208
211
  }
209
-
212
+
210
213
  var startTime = Time.realtimeSinceStartup;
211
214
  var sb = GDKPool.GetStringBuilder();
212
215
 
213
- InitModules();
214
-
216
+ await InitModules();
217
+ await UniTask.SwitchToMainThread();
215
218
  var moduleTime = Time.realtimeSinceStartup - startTime;
216
219
  sb.Append($"- InitModules() took (~ {moduleTime:#0.00}s)\n");
217
-
218
- yield return InitHook(); //Google CMP takes long at first time (~ 1.7s)
219
-
220
+
221
+ await InitHook(); //Google CMP takes long at first time (~ 1.7s)
222
+
220
223
  var hookTime = Time.realtimeSinceStartup - moduleTime - startTime;
221
224
  sb.Append($"- InitHook() took (~ {hookTime:#0.00}s)\n\n");
222
-
225
+
223
226
  _status = Status.Initialize;
224
227
  GDKUtils.SafeInvokeAndClear(ref _onGDKInit);
225
-
226
- if (!_allowInit) yield return WaitForManualInit();
227
- yield return InitAdapters(sb);
228
-
228
+
229
+ if (!_allowInit)
230
+ await WaitForManualInit();
231
+ await InitAdapters(sb);
232
+
229
233
  StartModules();
230
-
234
+
231
235
  ConfigGeoLocation();
232
236
  if (Config.enableServerTime)
233
237
  {
234
238
  ServerTime.UpdateTime();
235
239
  }
236
-
240
+
237
241
  ForceQuit.Init();
238
-
242
+
239
243
  _status = Status.Ready;
240
244
  GDKUtils.SafeInvokeAndClear(ref _onGDKReady);
241
245
 
242
246
  float initDuration = Time.realtimeSinceStartup - startTime;
243
247
 
244
- yield return LogEvent_GDKInitAsync(Mathf.RoundToInt(initDuration));
248
+ await LogEvent_GDKInitAsync(Mathf.RoundToInt(initDuration));
249
+
245
250
 
246
-
247
251
  sb.Append($"\nMapping UserId: {User.UserId}\n");
248
252
  ForceLog($"v{VERSION} | {READY} in {initDuration:#0.00}s\n\n{sb}");
249
253
  GDKPool.Return(sb);
250
-
254
+
251
255
  // also clear callbacks
252
256
  _onAdapterReady = null;
253
257
  }
@@ -272,7 +276,7 @@ namespace Amanotes.Core
272
276
  }
273
277
  }
274
278
 
275
- public static async Task<Dictionary<string, object>> ParseThirdPartyVersionsAsync()
279
+ public static async UniTask<Dictionary<string, object>> ParseThirdPartyVersionsAsync()
276
280
  {
277
281
  Dictionary<string, object> thirdPartyVersions = new Dictionary<string, object>();
278
282
  string fileContent = await GDKFileUtils.LoadFromStreamingAssets("SDKVersion.txt");
@@ -325,7 +329,7 @@ namespace Amanotes.Core
325
329
  }
326
330
  }
327
331
 
328
- private static async Task LogEvent_GDKInitAsync(int initDuration)
332
+ private static async UniTask LogEvent_GDKInitAsync(int initDuration)
329
333
  {
330
334
  var BToMB = 1.0 / (1024 * 1024);
331
335
  var reservedMemory = Math.Round(Profiler.GetTotalReservedMemoryLong() * BToMB, 2); // in MB
@@ -1,5 +1,6 @@
1
1
  using System;
2
2
  using Amanotes.Core.Internal;
3
+ using Cysharp.Threading.Tasks;
3
4
  using UnityEngine;
4
5
  using static Amanotes.Core.GDKDebug;
5
6
 
@@ -170,8 +171,7 @@ namespace Amanotes.Core
170
171
 
171
172
  public static partial class Consent //Internal
172
173
  {
173
- private static readonly Lazy<ConsentData> _data = new Lazy<ConsentData>(() => new ConsentData().LoadJsonFromFile());
174
- private static ConsentData data => _data.Value;
174
+ private static ConsentData data;
175
175
  private static Action _onConsentComplete;
176
176
 
177
177
  internal static bool checkedATT => data.att >= Status.Allowed;
@@ -185,13 +185,14 @@ namespace Amanotes.Core
185
185
  NotAllowed
186
186
  }
187
187
 
188
- internal static bool InitModule()
188
+ internal static async UniTask InitModule()
189
189
  {
190
+ await UniTask.SwitchToThreadPool();
190
191
  if (_config.autoGetConsent)
191
192
  {
192
193
  RequestAllConsents(null);
193
194
  }
194
- return true;
195
+ data = new ConsentData().LoadJsonFromFile();
195
196
  }
196
197
  }
197
198
  }
package/package.json CHANGED
@@ -1,20 +1,32 @@
1
1
  {
2
- "name": "com.amanotes.gdk",
3
- "version": "0.2.81-alpha.14",
4
- "displayName": "AmaGDK",
5
- "description": "Amanotes Game Development Kit",
6
- "unity": "2019.4",
7
- "keywords": [
8
- "Amanotes",
9
- "Amanotes GDK",
10
- "vh-name:AmaGDK"
11
- ],
12
- "author": {
13
- "name": "Amanotes",
14
- "email": "tech.support@amanotes.com",
15
- "url": "https://amanotes.com"
16
- },
17
- "changelogUrl": "https://amagdk.notion.site/Change-Log-6dfd4b67d64f496bbd9eb04ccb4ef95a",
18
- "documentationUrl": "https://amagdk.notion.site/amagdk/Ama-GDK-a73596617ab247b6a43c8f12a1581415",
19
- "license": "MIT"
2
+ "name": "com.amanotes.gdk",
3
+ "version": "0.2.81-alpha.17",
4
+ "displayName": "AmaGDK",
5
+ "description": "Amanotes Game Development Kit",
6
+ "unity": "2019.4",
7
+ "keywords": [
8
+ "Amanotes",
9
+ "Amanotes GDK",
10
+ "vh-name:AmaGDK"
11
+ ],
12
+ "author": {
13
+ "name": "Amanotes",
14
+ "email": "tech.support@amanotes.com",
15
+ "url": "https://amanotes.com"
16
+ },
17
+ "changelogUrl": "https://amagdk.notion.site/Change-Log-6dfd4b67d64f496bbd9eb04ccb4ef95a",
18
+ "documentationUrl": "https://amagdk.notion.site/amagdk/Ama-GDK-a73596617ab247b6a43c8f12a1581415",
19
+ "license": "MIT",
20
+ "dependencies": {
21
+ "com.cysharp.unitask": "2.5.10"
22
+ },
23
+ "scopedRegistries": [
24
+ {
25
+ "name": "OpenUPM",
26
+ "url": "https://package.openupm.com",
27
+ "scopes": [
28
+ "com.cysharp"
29
+ ]
30
+ }
31
+ ]
20
32
  }