com.amanotes.gdk 0.2.48 → 0.2.50

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 (40) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/Editor/AmaGDKEditor.cs +149 -63
  3. package/Editor/AmaGDKExtra.cs +31 -0
  4. package/Editor/AmaGDKExtra.cs.meta +11 -0
  5. package/Editor/Extra/GDKAutoBuild.cs +891 -0
  6. package/Editor/Extra/GDKAutoBuild.cs.meta +3 -0
  7. package/Editor/Extra/GDKProjectCP.cs +158 -0
  8. package/Editor/Extra/GDKProjectCP.cs.meta +11 -0
  9. package/Editor/Extra.meta +8 -0
  10. package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs +1 -1
  11. package/Extra/AmaGDKInstaller.unitypackage +0 -0
  12. package/Extra/AndroidPostProcessor.unitypackage +0 -0
  13. package/Extra/{AmaGDKProject.unitypackage.meta → AndroidPostProcessor.unitypackage.meta} +1 -1
  14. package/Extra/CheckDiskSpace.unitypackage +0 -0
  15. package/Extra/CheckDiskSpace.unitypackage.meta +7 -0
  16. package/Extra/SDKVersionTracking.unitypackage +0 -0
  17. package/Extra/SDKVersionTracking.unitypackage.meta +7 -0
  18. package/Packages/AmaGDKConfig.unitypackage +0 -0
  19. package/Packages/AmaGDKExample.unitypackage +0 -0
  20. package/Packages/AmaGDKTest.unitypackage +0 -0
  21. package/Packages/AppsFlyerAdapter.unitypackage +0 -0
  22. package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
  23. package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
  24. package/Packages/IronSourceAdapter.unitypackage +0 -0
  25. package/Packages/RevenueCatAdapter.unitypackage +0 -0
  26. package/Runtime/AmaGDK.Adapters.cs +0 -4
  27. package/Runtime/AmaGDK.Ads.cs +92 -31
  28. package/Runtime/AmaGDK.Analytics.cs +97 -64
  29. package/Runtime/AmaGDK.IAP.cs +39 -45
  30. package/Runtime/AmaGDK.RemoteConfig.cs +76 -52
  31. package/Runtime/AmaGDK.UserProfile.cs +106 -124
  32. package/Runtime/AmaGDK.cs +46 -35
  33. package/Runtime/Internal/AmaGDK.Event.cs +185 -0
  34. package/Runtime/Internal/AmaGDK.Event.cs.meta +3 -0
  35. package/Runtime/Internal/AmaGDK.Internal.cs +4 -0
  36. package/Runtime/Internal/AmaGDK.Utils.cs +85 -24
  37. package/Runtime/Klavar/Attributes.meta +0 -4
  38. package/Runtime/Klavar.meta +0 -4
  39. package/package.json +1 -1
  40. package/Extra/AmaGDKProject.unitypackage +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.50 - 2024-02-20]
4
+ - New feature: Modify Android post processor
5
+ - [Fix] remove installer should be skipped in DEV mode
6
+ - New feature: Check Disk Space
7
+ - Update version tracking: Add SkAdnetwork count
8
+ - Add check internet option for Ad module
9
+
10
+ ## [0.2.49 - 2024-01-29]
11
+ - New feature: SDK version tracking
12
+ - New feature: Google Consent Management (CMP)
13
+ - New feature: Force update pop-up
14
+ - Add event dispatcher, unit tests
15
+ - Update user profile and map_user_id event
16
+ - Fix accumulated_count logic
17
+ - Fix IAP editor
18
+ - Improve generated code for Klavar
19
+
3
20
  ## [0.2.48 - 2024-01-15]
4
21
  - Add GDKTest project for Unity versions 2020.3, 2021.3 and 2022.3
5
22
  - Integrate Klavar library & toolset
@@ -7,9 +7,11 @@ using System.Linq;
7
7
  using System.Reflection;
8
8
  using UnityEditor;
9
9
  using UnityEngine;
10
+ using UnityEngine.Profiling;
10
11
  using static Amanotes.Core.Internal.Logging;
11
12
  using static Amanotes.Core.AmaGDK.AdapterID;
12
13
  using UnityObject = UnityEngine.Object;
14
+ using UnityEvent = UnityEngine.Event;
13
15
 
14
16
  namespace Amanotes.Editor
15
17
  {
@@ -18,7 +20,7 @@ namespace Amanotes.Editor
18
20
  {
19
21
  private static readonly Color BLUE = new Color32(0x34, 0xFF, 0xF7, 0xFF);
20
22
  private static readonly Color ORANGE = new Color32(0xFF, 0xC0, 0x00, 0xFF);
21
-
23
+
22
24
  [NonSerialized] private static AmaGDK sdk;
23
25
  [NonSerialized] private static ConfigAsset configAsset;
24
26
  [NonSerialized] private static UnityObject invalidConfigAsset;
@@ -29,13 +31,15 @@ namespace Amanotes.Editor
29
31
  private static bool showConfigDetail;
30
32
  private static bool showAdapterInstaller;
31
33
  private static bool showExampleDetail;
32
-
33
-
34
-
34
+ private static bool showExtra;
35
+
35
36
  // DO NOT PUT [NonSerialized]
36
37
  private static bool adapterScanned = false;
37
38
  private static bool searchedForConfig = false;
38
39
 
40
+ private static bool extraScanned = false;
41
+ private static readonly List<string> extraPackages = new List<string>();
42
+
39
43
  private static readonly List<string> adapterPackages = new List<string>();
40
44
 
41
45
  public static Color btnColor;
@@ -49,12 +53,12 @@ namespace Amanotes.Editor
49
53
  IRONSOURCE,
50
54
  REVENUECAT
51
55
  };
52
-
56
+
53
57
  public void OnEnable()
54
58
  {
55
59
  sdk = (AmaGDK)target;
56
60
  if (sdk != null) sdk.transform.hideFlags = HideFlags.HideInInspector;
57
-
61
+
58
62
  SDKStatus.ClearCache();
59
63
  TryLoadConfigAsset();
60
64
  RefreshListAdapters();
@@ -65,18 +69,18 @@ namespace Amanotes.Editor
65
69
  if (configAsset != null) return;
66
70
  if (EditorApplication.isCompiling) return;
67
71
  if (EditorApplication.isUpdating) return;
68
-
72
+
69
73
  searchedForConfig = true;
70
74
  Resources.UnloadUnusedAssets();
71
-
75
+
72
76
  configAsset = Resources.Load<ConfigAsset>("AmaGDKConfig");
73
77
  invalidConfigAsset = configAsset == null ? Resources.Load("AmaGDKConfig") : null;
74
-
78
+
75
79
  RefreshListAdapters();
76
80
  SDKStatus.ClearCache();
77
81
  Repaint();
78
82
  }
79
-
83
+
80
84
  private void DrawGUI_ConfigMissing()
81
85
  {
82
86
  EditorGUI.indentLevel--;
@@ -98,7 +102,7 @@ namespace Amanotes.Editor
98
102
  AssetDatabase.ImportPackage(Res.AMAGDK_CONFIG_PACKAGE, false);
99
103
  adapterScanned = false;
100
104
  }
101
-
105
+
102
106
  if (GUILayout.Button(EditorGUIUtility.IconContent("d_Refresh@2x"), GUILayout.Width(40f), GUILayout.Height(40f)))
103
107
  {
104
108
  TryLoadConfigAsset();
@@ -145,6 +149,17 @@ namespace Amanotes.Editor
145
149
  }
146
150
  }
147
151
 
152
+ private void ScanForExtraPackages()
153
+ {
154
+ extraScanned = true;
155
+ extraPackages.Clear();
156
+ string[] extraPath = Directory.GetFiles(Res.EXTRA_PATH, "*.unitypackage", SearchOption.AllDirectories);
157
+ for (var i = 0; i < extraPath.Length; i++)
158
+ {
159
+ extraPackages.Add(Path.GetFileName(extraPath[i]));
160
+ }
161
+ }
162
+
148
163
  private void DrawGUI_AdapterList()
149
164
  {
150
165
  if (!adapterScanned) ScanForAdapterPackages();
@@ -157,6 +172,19 @@ namespace Amanotes.Editor
157
172
  }
158
173
  }
159
174
  }
175
+
176
+ private void DrawGUI_ExtraList()
177
+ {
178
+ if (!extraScanned) ScanForExtraPackages();
179
+ foreach (string extra in extraPackages)
180
+ {
181
+ if (GUILayout.Button(ObjectNames.NicifyVariableName(extra)))
182
+ {
183
+ var package = $"{Res.PACKAGE_PATH}{extra}";
184
+ AssetDatabase.ImportPackage(package, false);
185
+ }
186
+ }
187
+ }
160
188
 
161
189
  private void DrawGUI_ExampleScene()
162
190
  {
@@ -167,7 +195,7 @@ namespace Amanotes.Editor
167
195
  AssetDatabase.ImportPackage(package, false);
168
196
  }
169
197
  }
170
-
198
+
171
199
  private void DrawGUI_ColorPicker()
172
200
  {
173
201
  GUILayout.BeginHorizontal();
@@ -177,7 +205,7 @@ namespace Amanotes.Editor
177
205
  }
178
206
  GUILayout.EndHorizontal();
179
207
  }
180
-
208
+
181
209
  // public void CopyVersion()
182
210
  // {
183
211
  // var sb = new StringBuilder();
@@ -206,7 +234,7 @@ namespace Amanotes.Editor
206
234
  {
207
235
  AmaGUI.SectionLabel($"<b>AmaGDK</b> <size=12><color=gray>v{AmaGDK.VERSION}</color></size>");
208
236
  var rect = GUILayoutUtility.GetLastRect();
209
- if (Event.current.isMouse && Event.current.button == 1 && rect.Contains(Event.current.mousePosition))
237
+ if (UnityEvent.current.isMouse && UnityEvent.current.button == 1 && rect.Contains(UnityEvent.current.mousePosition))
210
238
  {
211
239
  var menu = new GenericMenu();
212
240
  menu.AddDisabledItem(new GUIContent("AmaGDK"));
@@ -218,30 +246,35 @@ namespace Amanotes.Editor
218
246
  });
219
247
  menu.AddItem(new GUIContent("Clear Cache"), false, () =>
220
248
  {
221
- GDKFileUtils.ClearCacheData();
249
+ GDKFileUtils.ClearCacheData();
222
250
  });
223
251
  menu.ShowAsContext();
224
- Event.current.Use();
252
+ UnityEvent.current.Use();
225
253
  }
226
254
  }
227
-
255
+
228
256
  public override void OnInspectorGUI()
229
257
  {
258
+ Profiler.BeginSample("GDKEditor.OnInspectorGUI()");
259
+
230
260
  if (target == null)
231
261
  {
232
262
  EditorGUILayout.HelpBox("Target is null!", MessageType.Warning);
233
263
  Repaint();
264
+ Profiler.EndSample();
234
265
  return;
235
266
  }
236
-
267
+
237
268
  sdk = (AmaGDK)target;
238
269
  if (sdk == null)
239
270
  {
240
271
  EditorGUILayout.HelpBox("AmaGDK is null!", MessageType.Warning);
241
272
  Repaint();
273
+ Profiler.EndSample();
242
274
  return;
243
275
  }
244
276
 
277
+
245
278
  // DrawGUI_ColorPicker();
246
279
  DrawGUI_AmaGDKBanner();
247
280
  EditorGUILayout.Space();
@@ -250,22 +283,25 @@ namespace Amanotes.Editor
250
283
  if (EditorApplication.isCompiling || EditorApplication.isUpdating)
251
284
  {
252
285
  EditorGUILayout.HelpBox("Please wait for UnityEditor to finish compiling or importing", MessageType.Warning);
286
+ Profiler.EndSample();
253
287
  return;
254
288
  }
255
-
289
+
256
290
  if (!searchedForConfig) TryLoadConfigAsset();
257
291
  if (!adapterScanned) ScanForAdapterPackages();
258
-
292
+ if (!extraScanned) ScanForAdapterPackages();
293
+
259
294
  if (configAsset == null)
260
295
  {
261
296
  DrawGUI_ConfigMissing();
262
297
  Repaint();
298
+ Profiler.EndSample();
263
299
  return;
264
300
  }
265
-
301
+
266
302
  configSO = new SerializedObject(configAsset);
267
303
  configSO.Update();
268
-
304
+
269
305
  DrawProperty(configSO, "common");
270
306
  GUILayout.Space(8f);
271
307
  for (var i = 0; i < allAdapters.Count; i++)
@@ -273,15 +309,26 @@ namespace Amanotes.Editor
273
309
  var item = allAdapters[i];
274
310
  DrawAdapterDetail(item.id, item.adapter);
275
311
  }
276
-
312
+
277
313
  EditorGUILayout.Space();
278
314
  AmaGUI.Foldout("Config", ref showConfigDetail, DrawGUI_ConfigDetail, DrawGUI_ConfigAsset);
279
315
  AmaGUI.Foldout("Adapters", ref showAdapterInstaller, DrawGUI_AdapterList);
316
+ AmaGUI.Foldout("Extras", ref showExtra, DrawGUI_ExtraList);
317
+ Profiler.EndSample();
280
318
  }
281
319
 
282
320
  private static List<(string id, Adapter2 adapter)> allAdapters = new List<(string, Adapter2)>();
283
321
  private static readonly Dictionary<string, bool> configOpen = new Dictionary<string, bool>();
322
+ private static readonly Dictionary<string, GUIContent> cacheGUIContent = new Dictionary<string, GUIContent>();
323
+ private static GUIContent GetGUIContent(string str)
324
+ {
325
+ if (cacheGUIContent.TryGetValue(str, out var result)) return result;
326
+ result = new GUIContent(str);
327
+ cacheGUIContent.Add(str, result);
328
+ return result;
329
+ }
284
330
 
331
+
285
332
  private static List<Type> FindSubClassesOf(Type baseType)
286
333
  {
287
334
  List<Type> result = new List<Type>();
@@ -296,57 +343,96 @@ namespace Amanotes.Editor
296
343
 
297
344
  return result;
298
345
  }
299
-
346
+
300
347
  private static void RefreshListAdapters()
301
348
  {
302
349
  allAdapters = SDK_IDS
303
350
  .Select(id => (id: id, adapter: GetAdapter(id)))
304
- .OrderBy(x=>
305
- x.adapter == null ? 2:
351
+ .OrderBy(x =>
352
+ x.adapter == null ? 2 :
306
353
  x.adapter.enabled == false ? 1 :
307
354
  -x.adapter.initOrder)
308
355
  .ToList();
309
356
  }
310
-
357
+
358
+ private static string FindBestAdapterFor(string adapterId)
359
+ {
360
+ var matched = adapterPackages
361
+ .Where(item => item.ToLower().Contains(adapterId.ToLower()));
362
+
363
+ return matched.First();
364
+ }
365
+
311
366
  private static void DrawAdapterDetail(string adapterId, Adapter2 adapter)
312
367
  {
313
368
  if (!configOpen.TryGetValue(adapterId, out bool isOpen))
314
369
  {
315
370
  configOpen.Add(adapterId, isOpen = false);
316
371
  }
317
-
318
- if (adapter == null)
319
- {
320
- EditorGUILayout.HelpBox("Adapter<" + adapterId + "> not imported!", MessageType.Info);
321
- return;
322
- }
323
-
372
+
373
+ // if (adapter == null)
374
+ // {
375
+ // // EditorGUILayout.HelpBox("Adapter<" + adapterId + "> not imported!", MessageType.Info);
376
+ // string adapterName = FindBestAdapterFor(adapterId);
377
+ // var package = $"{Res.PACKAGE_PATH}{adapterName}";
378
+ //
379
+ // if (GUILayout.Button(adapterName))
380
+ // {
381
+ // AssetDatabase.ImportPackage(package, false);
382
+ // }
383
+ // return;
384
+ // }
385
+
324
386
  SDKStatus status = SDKStatus.Get(adapterId);
325
387
  bool changed = AmaGUI.Foldout(ObjectNames.NicifyVariableName(adapterId), ref isOpen, () =>
326
388
  {
327
- DrawSDKConfig(adapter, adapterId, status);
389
+ if (adapter != null)
390
+ {
391
+ DrawSDKConfig(adapter, adapterId, status);
392
+ } else
393
+ {
394
+ string adapterName = FindBestAdapterFor(adapterId);
395
+ var package = $"{Res.PACKAGE_PATH}{adapterName}";
396
+ if (GUILayout.Button(GetGUIContent($"Import {adapterId} Adapter"), GUILayout.Height(24f)))
397
+ {
398
+ AssetDatabase.ImportPackage(package, false);
399
+ }
400
+ }
401
+
328
402
  }, () =>
329
403
  {
330
404
  GUILayout.FlexibleSpace();
331
- if (!adapter.enabled)
405
+
406
+ bool installed = status.adapterInstalled;
407
+ bool adapterActive = installed && adapter.enabled;
408
+
409
+ if (!adapterActive)
332
410
  {
411
+ GUIContent label = GetGUIContent(installed ? "disabled" : "unavailable");
333
412
  Color c = GUI.color;
334
413
  GUI.color = Color.yellow;
335
- GUILayout.Label("disabled", GUILayout.Width(60f));
414
+
415
+ float w = EditorStyles.label.CalcSize(label).x;
416
+ GUILayout.Label(label, GUILayout.Width(w));
336
417
  GUI.color = c;
337
418
  }
338
- AmaGUI.DrawVersionTag(status.sdkVersion, status.adapterInstalled && adapter.enabled);
339
- Rect titleRect = GUILayoutUtility.GetLastRect();
340
- bool hit = Event.current.isMouse && titleRect.Contains(Event.current.mousePosition);
341
- if (hit && Event.current.button == 1)
419
+
420
+ AmaGUI.DrawVersionTag(status.sdkVersion, adapterActive);
421
+
422
+ if (installed)
342
423
  {
343
- Event.current.Use();
344
- CreateGenericMenu(adapter, adapterId);
424
+ Rect titleRect = GUILayoutUtility.GetLastRect();
425
+ bool hit = UnityEvent.current.isMouse && titleRect.Contains(UnityEvent.current.mousePosition);
426
+ if (hit && UnityEvent.current.button == 1)
427
+ {
428
+ UnityEvent.current.Use();
429
+ CreateGenericMenu(adapter, adapterId);
430
+ }
345
431
  }
346
432
  });
347
-
348
-
349
-
433
+
434
+
435
+
350
436
  if (changed) configOpen[adapterId] = isOpen;
351
437
  }
352
438
 
@@ -360,10 +446,10 @@ namespace Amanotes.Editor
360
446
  adapter.enabled = !adapter.enabled;
361
447
  EditorUtility.SetDirty(configAsset);
362
448
  });
363
-
449
+
364
450
  menu.ShowAsContext();
365
451
  }
366
-
452
+
367
453
  private static void DrawSDKConfig(Adapter2 adapter, string adapterId, SDKStatus status)
368
454
  {
369
455
  if (!status.sdkInstalled)
@@ -376,13 +462,13 @@ namespace Amanotes.Editor
376
462
  EditorGUILayout.HelpBox($"{adapterId}-GDKAdapter not installed", MessageType.Warning);
377
463
  return;
378
464
  }
379
-
465
+
380
466
  if (!status.adapterInstalled)
381
467
  {
382
468
  EditorGUILayout.HelpBox($"{adapterId}-GDKAdapter not installed", MessageType.Warning);
383
469
  return;
384
470
  }
385
-
471
+
386
472
  DrawModuleConfig(adapter, adapterId);
387
473
  }
388
474
 
@@ -402,7 +488,7 @@ namespace Amanotes.Editor
402
488
  GUILayout.Space(8f);
403
489
  });
404
490
  }
405
-
491
+
406
492
  if (adapter.enabled)
407
493
  {
408
494
  Color c = GUI.contentColor;
@@ -411,9 +497,9 @@ namespace Amanotes.Editor
411
497
  if (adapter is IAPAdapter) EditorGUILayout.PropertyField(configSO.FindProperty("iap"), new GUIContent("Shared settings for In App Purchase Modules"));
412
498
  if (adapter is AnalyticsAdapter) EditorGUILayout.PropertyField(configSO.FindProperty("analytics"), new GUIContent("Shared settings for Analytics Modules"));
413
499
  if (adapter is RemoteConfigAdapter) EditorGUILayout.PropertyField(configSO.FindProperty("remoteConfig"), new GUIContent("Shared settings for Remote Config Modules"));
414
- GUI.contentColor = c;
500
+ GUI.contentColor = c;
415
501
  }
416
- configSO.ApplyModifiedProperties();
502
+ configSO.ApplyModifiedProperties();
417
503
  }
418
504
  EditorGUIUtility.labelWidth -= 70;
419
505
  EditorGUI.EndDisabledGroup();
@@ -423,27 +509,27 @@ namespace Amanotes.Editor
423
509
  {
424
510
  SerializedProperty property = so.FindProperty(propertyField);
425
511
  if (property == null) return;
426
-
512
+
427
513
  string basePath = property.propertyPath;
428
514
  var first = true;
429
515
  while (property.NextVisible(first))
430
516
  {
431
517
  first = false;
432
518
  if (!property.propertyPath.Contains(basePath)) break;
433
- EditorGUILayout.PropertyField(property);
519
+ EditorGUILayout.PropertyField(property);
434
520
  }
435
-
521
+
436
522
  so.ApplyModifiedProperties();
437
523
  }
438
-
524
+
439
525
  private static Adapter2 GetAdapter(string id)
440
526
  {
441
527
  if (configAsset == null) return null;
442
528
  Type configType = configAsset.GetType();
443
-
529
+
444
530
  FieldInfo field = configType
445
531
  .GetField(id, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
446
-
532
+
447
533
  if (field == null)
448
534
  {
449
535
  #if AMAGDK_DEV
@@ -451,14 +537,14 @@ namespace Amanotes.Editor
451
537
  #endif
452
538
  return null;
453
539
  }
454
-
455
- var adapter = (Adapter2) field.GetValue(AmaGDK.Config);
540
+
541
+ var adapter = (Adapter2)field.GetValue(AmaGDK.Config);
456
542
  if (adapter != null) return adapter;
457
-
543
+
458
544
  LogWarning($"Adapter <{id}> == null in ConfigAsset? (non-serialized?)");
459
545
  return null;
460
546
  }
461
-
547
+
462
548
  public static void DrawIRSAdapterVersions()
463
549
  {
464
550
  List<IronSourceSDKAdapter> list = ExtractVersion.IronSourceAdapter();
@@ -0,0 +1,31 @@
1
+ using System.Collections.Generic;
2
+
3
+ namespace Amanotes.Editor
4
+ {
5
+ public class AmaGDKExtra : UnityEditor.Editor
6
+ {
7
+ public static Dictionary<string, object> GetThirdPartyVersions()
8
+ {
9
+ Dictionary<string, object> dicThirdParty = new Dictionary<string, object>();
10
+ List<GDKModule> listModule = VersionHelper.LoadLocalModuleInfo();
11
+ foreach (var module in listModule)
12
+ {
13
+ VersionHelper.UpdateListVersions(module);
14
+ dicThirdParty.Add(module.id, ExtractVersion.ThirdParty(module.id));
15
+ }
16
+
17
+ foreach (IronSourceSDKAdapter adapter in ExtractVersion.IronSourceAdapter())
18
+ {
19
+ dicThirdParty.Add(adapter.name, adapter.version);
20
+ }
21
+
22
+ return dicThirdParty;
23
+ }
24
+
25
+ public static string FirebaseVersion()
26
+ {
27
+ string version = ExtractVersion.FirebaseAnalytics();
28
+ return !string.IsNullOrEmpty(version) ? version : ExtractVersion.FirebaseRemoteConfig();
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 85db6a6a8ddad403ea586f9388c02be6
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: