com.amanotes.gdk 0.2.46 → 0.2.48

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 (78) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/Editor/AmaGDKEditor.cs +281 -104
  3. package/Editor/MatchSDKVersion.cs +3 -6
  4. package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs +5 -1
  5. package/Extra/AmaGDKInstaller.unitypackage +0 -0
  6. package/Extra/AmaGDKProject.unitypackage +0 -0
  7. package/Packages/AmaGDKConfig.unitypackage +0 -0
  8. package/Packages/AmaGDKExample.unitypackage +0 -0
  9. package/Packages/AmaGDKTest.unitypackage +0 -0
  10. package/Packages/AppsFlyerAdapter.unitypackage +0 -0
  11. package/Packages/{FirebaseRemoteConfigAdapter_v9.1.0.unitypackage.meta → AppsFlyerAdapter.unitypackage.meta} +1 -1
  12. package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
  13. package/Packages/{AppsFlyerAdapter_v6.5.4.unitypackage.meta → FirebaseAnalyticsAdapter.unitypackage.meta} +1 -1
  14. package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
  15. package/Packages/{IronSourceAdapter_v7.5.2.unitypackage.meta → FirebaseRemoteConfigAdapter.unitypackage.meta} +1 -1
  16. package/Packages/IronSourceAdapter.unitypackage +0 -0
  17. package/Packages/{FirebaseAnalyticsAdapter_v9.1.0.unitypackage.meta → IronSourceAdapter.unitypackage.meta} +1 -1
  18. package/Packages/RevenueCatAdapter.unitypackage +0 -0
  19. package/Packages/RevenueCatAdapter.unitypackage.meta +7 -0
  20. package/Runtime/AmaGDK.Adapters.cs +55 -77
  21. package/Runtime/AmaGDK.Ads.cs +160 -174
  22. package/Runtime/AmaGDK.Analytics.cs +245 -125
  23. package/Runtime/AmaGDK.Config.cs +2 -1
  24. package/Runtime/AmaGDK.IAP.cs +47 -48
  25. package/Runtime/AmaGDK.RemoteConfig.cs +38 -35
  26. package/Runtime/AmaGDK.UserProfile.cs +27 -19
  27. package/Runtime/AmaGDK.cs +158 -111
  28. package/Runtime/Internal/AmaGDK.Internal.AmaGUI.cs +8 -3
  29. package/Runtime/Internal/AmaGDK.Internal.SemVer.cs +21 -17
  30. package/Runtime/Internal/AmaGDK.Internal.cs +17 -6
  31. package/Runtime/Internal/AmaGDK.Utils.cs +78 -11
  32. package/Runtime/Klavar/Attributes/AccumulatedCountAttribute.cs +19 -0
  33. package/Runtime/Klavar/Attributes/AccumulatedCountAttribute.cs.meta +11 -0
  34. package/Runtime/Klavar/Attributes/ConnectionAttribute.cs +18 -0
  35. package/Runtime/Klavar/Attributes/ConnectionAttribute.cs.meta +11 -0
  36. package/Runtime/Klavar/Attributes/CountInSessionAttribute.cs +27 -0
  37. package/Runtime/Klavar/Attributes/CountInSessionAttribute.cs.meta +11 -0
  38. package/Runtime/Klavar/Attributes/DescriptionAttribute.cs +7 -0
  39. package/Runtime/Klavar/Attributes/DescriptionAttribute.cs.meta +11 -0
  40. package/Runtime/Klavar/Attributes/DynamicValidateAttribute.cs +30 -0
  41. package/Runtime/Klavar/Attributes/DynamicValidateAttribute.cs.meta +11 -0
  42. package/Runtime/Klavar/Attributes/IgnoreAttribute.cs +16 -0
  43. package/Runtime/Klavar/Attributes/IgnoreAttribute.cs.meta +11 -0
  44. package/Runtime/Klavar/Attributes/MinMaxAttribute.cs +130 -0
  45. package/Runtime/Klavar/Attributes/MinMaxAttribute.cs.meta +11 -0
  46. package/Runtime/Klavar/Attributes/MinMaxLengthAttribute.cs +88 -0
  47. package/Runtime/Klavar/Attributes/MinMaxLengthAttribute.cs.meta +11 -0
  48. package/Runtime/Klavar/Attributes/NameAttribute.cs +35 -0
  49. package/Runtime/Klavar/Attributes/NameAttribute.cs.meta +11 -0
  50. package/Runtime/Klavar/Attributes/NotNullAttribute.cs +16 -0
  51. package/Runtime/Klavar/Attributes/NotNullAttribute.cs.meta +11 -0
  52. package/Runtime/Klavar/Attributes/RegexPatternAttribute.cs +58 -0
  53. package/Runtime/Klavar/Attributes/RegexPatternAttribute.cs.meta +11 -0
  54. package/Runtime/Klavar/Attributes/TimeDiffLastFireAttribute.cs +28 -0
  55. package/Runtime/Klavar/Attributes/TimeDiffLastFireAttribute.cs.meta +11 -0
  56. package/Runtime/Klavar/Attributes/ToStringAttribute.cs +97 -0
  57. package/Runtime/Klavar/Attributes/ToStringAttribute.cs.meta +11 -0
  58. package/Runtime/Klavar/Attributes/ValueAttribute.cs +30 -0
  59. package/Runtime/Klavar/Attributes/ValueAttribute.cs.meta +11 -0
  60. package/Runtime/Klavar/Attributes.meta +12 -0
  61. package/Runtime/Klavar/KlavarEvent.cs +91 -0
  62. package/Runtime/Klavar/KlavarEvent.cs.meta +11 -0
  63. package/Runtime/Klavar/KlavarEventAttribute.cs +39 -0
  64. package/Runtime/Klavar/KlavarEventAttribute.cs.meta +11 -0
  65. package/Runtime/Klavar/KlavarEventTools.cs +92 -0
  66. package/Runtime/Klavar/KlavarEventTools.cs.meta +11 -0
  67. package/Runtime/Klavar/KlavarEventUtils.cs +58 -0
  68. package/Runtime/Klavar/KlavarEventUtils.cs.meta +11 -0
  69. package/Runtime/Klavar.meta +12 -0
  70. package/package.json +1 -1
  71. package/Packages/AppsFlyerAdapter_v6.5.4.unitypackage +0 -0
  72. package/Packages/FirebaseAnalyticsAdapter_v9.1.0.unitypackage +0 -0
  73. package/Packages/FirebaseRemoteConfigAdapter_v9.1.0.unitypackage +0 -0
  74. package/Packages/IronSourceAdapter_v7.5.2.unitypackage +0 -0
  75. package/Packages/IronsourceAdapter_v7.2.6.unitypackage +0 -0
  76. package/Packages/IronsourceAdapter_v7.2.6.unitypackage.meta +0 -7
  77. package/Packages/RevenueCatAdapter_v6.0.0.unitypackage +0 -0
  78. package/Packages/RevenueCatAdapter_v6.0.0.unitypackage.meta +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.48 - 2024-01-15]
4
+ - Add GDKTest project for Unity versions 2020.3, 2021.3 and 2022.3
5
+ - Integrate Klavar library & toolset
6
+
7
+ ## [0.2.47 - 2024-01-09]
8
+ - Some clean up, null checks & improvements for AmaGDK Editor
9
+ - Add GDKTest project for Unity versions 2020.3, 2021.3 and 2022.3
10
+
3
11
  ## [0.2.46 - 2023-12-19]
4
12
  - Cleaner UI interface for AmaGDK Inspector
5
13
  - Add AmaGUI to centralize all GUI handles
@@ -257,4 +265,4 @@ Update Ads module:
257
265
  ## [0.1.2] - 2023-02-08
258
266
  - Release AmaGDK 0.1.2
259
267
  - FirebaseAnalytics adapter compatible with FirebaseAnalytics SDK v9
260
- - AppsFlyer adapter compatible with AppsFlyer SDK v6
268
+ - AppsFlyer adapter compatible with AppsFlyer SDK v6
@@ -1,13 +1,15 @@
1
1
  using System;
2
- using System.Text;
3
2
  using Amanotes.Core;
4
3
  using Amanotes.Core.Internal;
5
4
  using System.Collections.Generic;
6
5
  using System.IO;
6
+ using System.Linq;
7
+ using System.Reflection;
7
8
  using UnityEditor;
8
9
  using UnityEngine;
9
10
  using static Amanotes.Core.Internal.Logging;
10
11
  using static Amanotes.Core.AmaGDK.AdapterID;
12
+ using UnityObject = UnityEngine.Object;
11
13
 
12
14
  namespace Amanotes.Editor
13
15
  {
@@ -15,16 +17,26 @@ namespace Amanotes.Editor
15
17
  internal class AmaGDKEditor : UnityEditor.Editor
16
18
  {
17
19
  private static readonly Color BLUE = new Color32(0x34, 0xFF, 0xF7, 0xFF);
20
+ private static readonly Color ORANGE = new Color32(0xFF, 0xC0, 0x00, 0xFF);
21
+
22
+ [NonSerialized] private static AmaGDK sdk;
23
+ [NonSerialized] private static ConfigAsset configAsset;
24
+ [NonSerialized] private static UnityObject invalidConfigAsset;
25
+ [NonSerialized] private static SerializedObject configSO;
26
+ [NonSerialized] private static UnityEditor.Editor editor;
18
27
 
19
- private static AmaGDK sdk;
20
- private static ConfigAsset configAsset;
21
- private static UnityEditor.Editor editor;
22
-
28
+ private static bool showIRSAdapter;
23
29
  private static bool showConfigDetail;
24
30
  private static bool showAdapterInstaller;
25
31
  private static bool showExampleDetail;
26
- private bool adapterScanned;
27
- private readonly List<string> lstAdapter = new List<string>();
32
+
33
+
34
+
35
+ // DO NOT PUT [NonSerialized]
36
+ private static bool adapterScanned = false;
37
+ private static bool searchedForConfig = false;
38
+
39
+ private static readonly List<string> adapterPackages = new List<string>();
28
40
 
29
41
  public static Color btnColor;
30
42
  public static float btnLerp;
@@ -37,67 +49,69 @@ namespace Amanotes.Editor
37
49
  IRONSOURCE,
38
50
  REVENUECAT
39
51
  };
40
-
52
+
41
53
  public void OnEnable()
42
54
  {
43
55
  sdk = (AmaGDK)target;
44
56
  if (sdk != null) sdk.transform.hideFlags = HideFlags.HideInInspector;
45
- if (configAsset == null) SearchForConfigAsset();
57
+
58
+ SDKStatus.ClearCache();
59
+ TryLoadConfigAsset();
60
+ RefreshListAdapters();
46
61
  }
47
62
 
48
- private void SearchForConfigAsset()
63
+ private void TryLoadConfigAsset()
49
64
  {
65
+ if (configAsset != null) return;
66
+ if (EditorApplication.isCompiling) return;
67
+ if (EditorApplication.isUpdating) return;
68
+
69
+ searchedForConfig = true;
50
70
  Resources.UnloadUnusedAssets();
71
+
51
72
  configAsset = Resources.Load<ConfigAsset>("AmaGDKConfig");
73
+ invalidConfigAsset = configAsset == null ? Resources.Load("AmaGDKConfig") : null;
74
+
75
+ RefreshListAdapters();
76
+ SDKStatus.ClearCache();
77
+ Repaint();
52
78
  }
53
-
54
- private void KeepSearchingForConfig()
55
- {
56
- if (EditorApplication.isUpdating || EditorApplication.isCompiling) return;
57
- SearchForConfigAsset();
58
-
59
- if (configAsset == null) return;
60
- EditorApplication.update -= KeepSearchingForConfig;
61
- }
62
-
79
+
63
80
  private void DrawGUI_ConfigMissing()
64
81
  {
65
- EditorGUILayout.HelpBox("[Warning] AmaGDK ConfigAsset NOT FOUND!\nYou need to create one to control all the adapter's configurations!", MessageType.Warning);
66
-
67
- GUILayout.BeginHorizontal();
82
+ EditorGUI.indentLevel--;
83
+ if (invalidConfigAsset != null)
84
+ {
85
+ EditorGUILayout.HelpBox($" INVALID <Resources/AmaGDKConfig.asset> found!", MessageType.Warning);
86
+ if (AmaGUI.BigButton("RE-IMPORT GDK Config", 40f, ORANGE))
87
+ {
88
+ AssetDatabase.ImportPackage(Res.AMAGDK_CONFIG_PACKAGE, false);
89
+ searchedForConfig = false;
90
+ }
91
+ } else
68
92
  {
69
- if (AmaGUI.BigButton("CREATE", 40f, BLUE))
93
+ EditorGUILayout.HelpBox("[Warning] <Resources/AmaGDKConfig.asset> NOT FOUND!\nYou need to create one to control all the adapter's configurations!", MessageType.Warning);
94
+ GUILayout.BeginHorizontal();
70
95
  {
71
- try
96
+ if (AmaGUI.BigButton("CREATE", 40f, BLUE))
72
97
  {
73
98
  AssetDatabase.ImportPackage(Res.AMAGDK_CONFIG_PACKAGE, false);
74
- EditorApplication.update -= KeepSearchingForConfig;
75
- EditorApplication.update += KeepSearchingForConfig;
99
+ adapterScanned = false;
76
100
  }
77
- catch (Exception e)
101
+
102
+ if (GUILayout.Button(EditorGUIUtility.IconContent("d_Refresh@2x"), GUILayout.Width(40f), GUILayout.Height(40f)))
78
103
  {
79
- LogError(Res.AMAGDK_CONFIG_PACKAGE + "\n" + e);
104
+ TryLoadConfigAsset();
80
105
  }
81
106
  }
82
-
83
- if (GUILayout.Button(EditorGUIUtility.IconContent("d_Refresh@2x"), GUILayout.Width(40f), GUILayout.Height(40f)))
84
- {
85
- SearchForConfigAsset();
86
- }
107
+ GUILayout.EndHorizontal();
87
108
  }
88
-
89
- GUILayout.EndHorizontal();
109
+ EditorGUI.indentLevel++;
90
110
  }
91
111
 
92
- private void DrawGUI_AutoInit()
112
+ private void DrawGUI_AutoInitDisabled()
93
113
  {
94
- if (sdk.autoInit)
95
- {
96
- AmaGUI.Toggle("Auto Init", ref sdk.autoInit);
97
- EditorUtility.SetDirty(sdk);
98
- return;
99
- }
100
-
114
+ if (sdk.autoInit) return;
101
115
  EditorGUILayout.HelpBox("You disabled AmaGDK AutoInit\nMake sure to call AmaGDK.Init() manually!", MessageType.Warning);
102
116
  if (AmaGUI.BigButton("Enable AutoInit", 40f, BLUE))
103
117
  {
@@ -120,25 +134,21 @@ namespace Amanotes.Editor
120
134
  EditorGUILayout.ObjectField(configAsset, configAsset.GetType(), false, GUILayout.Width(EditorGUIUtility.currentViewWidth - 414), GUILayout.ExpandWidth(true));
121
135
  }
122
136
 
123
- private void UpdateListAdapter()
137
+ private void ScanForAdapterPackages()
124
138
  {
125
- if(adapterScanned)
126
- return;
127
-
128
139
  adapterScanned = true;
129
-
140
+ adapterPackages.Clear();
130
141
  string[] adapterPath = Directory.GetFiles(Res.PACKAGE_PATH, "*Adapter*.unitypackage", SearchOption.AllDirectories);
131
-
132
142
  for (var i = 0; i < adapterPath.Length; i++)
133
143
  {
134
- lstAdapter.Add(Path.GetFileName(adapterPath[i]));
144
+ adapterPackages.Add(Path.GetFileName(adapterPath[i]));
135
145
  }
136
146
  }
137
147
 
138
148
  private void DrawGUI_AdapterList()
139
149
  {
140
- UpdateListAdapter();
141
- foreach (string adapter in lstAdapter)
150
+ if (!adapterScanned) ScanForAdapterPackages();
151
+ foreach (string adapter in adapterPackages)
142
152
  {
143
153
  if (GUILayout.Button(ObjectNames.NicifyVariableName(adapter)))
144
154
  {
@@ -168,85 +178,193 @@ namespace Amanotes.Editor
168
178
  GUILayout.EndHorizontal();
169
179
  }
170
180
 
171
- public void CopyVersion()
181
+ // public void CopyVersion()
182
+ // {
183
+ // var sb = new StringBuilder();
184
+ // sb.AppendLine("ID\tSDK VERSION\tADAPTER VERSION");
185
+ // for (var i = 0; i < SDK_IDS.Length; i++)
186
+ // {
187
+ // SDKStatus status = SDKStatus.Get(SDK_IDS[i]);
188
+ // sb.AppendLine(status.ToTSVString());
189
+ // if (status.sdkId != IRONSOURCE) continue;
190
+ // if (!status.sdkInstalled || !status.adapterInstalled) continue;
191
+ //
192
+ // List<IronSourceSDKAdapter> list = ExtractVersion.IronSourceAdapter();
193
+ // for (var j = 0; j < list.Count; j++)
194
+ // {
195
+ // IronSourceSDKAdapter item = list[j];
196
+ // sb.AppendLine($"IS{item.name}Adapter\t{item.version}");
197
+ // }
198
+ // }
199
+ //
200
+ // var tsv = sb.ToString();
201
+ // EditorGUIUtility.systemCopyBuffer = tsv;
202
+ // Debug.Log($"Content of version_info.tsv copied to clipboard!\n\n{tsv}\n\n");
203
+ // }
204
+
205
+ void DrawGUI_AmaGDKBanner()
172
206
  {
173
- var sb = new StringBuilder();
174
- sb.AppendLine("ID\tSDK VERSION\tADAPTER VERSION");
175
- for (var i = 0; i < SDK_IDS.Length; i++)
207
+ AmaGUI.SectionLabel($"<b>AmaGDK</b> <size=12><color=gray>v{AmaGDK.VERSION}</color></size>");
208
+ var rect = GUILayoutUtility.GetLastRect();
209
+ if (Event.current.isMouse && Event.current.button == 1 && rect.Contains(Event.current.mousePosition))
176
210
  {
177
- var status = SDKStatus.Get(SDK_IDS[i]);
178
- sb.AppendLine(status.ToTSVString());
179
- if (status.sdkId != IRONSOURCE) continue;
180
- if (!status.sdkInstalled || !status.adapterInstalled) continue;
181
-
182
- List<IronSourceSDKAdapter> list = ExtractVersion.IronSourceAdapter();
183
- for (var j = 0; j < list.Count; j++)
211
+ var menu = new GenericMenu();
212
+ menu.AddDisabledItem(new GUIContent("AmaGDK"));
213
+ menu.AddSeparator("");
214
+ menu.AddItem(new GUIContent("Auto Init"), sdk.autoInit, () =>
184
215
  {
185
- IronSourceSDKAdapter item = list[j];
186
- sb.AppendLine($"IS{item.name}Adapter\t{item.version}");
187
- }
216
+ sdk.autoInit = !sdk.autoInit;
217
+ EditorUtility.SetDirty(sdk);
218
+ });
219
+ menu.AddItem(new GUIContent("Clear Cache"), false, () =>
220
+ {
221
+ GDKFileUtils.ClearCacheData();
222
+ });
223
+ menu.ShowAsContext();
224
+ Event.current.Use();
188
225
  }
189
-
190
- var tsv = sb.ToString();
191
- EditorGUIUtility.systemCopyBuffer = tsv;
192
- Debug.Log($"Content of version_info.tsv copied to clipboard!\n\n{tsv}\n\n");
193
226
  }
194
227
 
195
228
  public override void OnInspectorGUI()
196
229
  {
197
- if (sdk == null) return;
198
-
199
- // DrawGUI_ColorPicker();
200
- AmaGUI.SectionLabel($"<b>AmaGDK</b> <size=12><color=gray>v{AmaGDK.VERSION}</color></size>");
201
- EditorGUILayout.Space();
230
+ if (target == null)
231
+ {
232
+ EditorGUILayout.HelpBox("Target is null!", MessageType.Warning);
233
+ Repaint();
234
+ return;
235
+ }
202
236
 
203
- for (var i = 0; i < SDK_IDS.Length; i++)
237
+ sdk = (AmaGDK)target;
238
+ if (sdk == null)
204
239
  {
205
- string id = SDK_IDS[i];
206
- DrawAdapterDetail(id);
240
+ EditorGUILayout.HelpBox("AmaGDK is null!", MessageType.Warning);
241
+ Repaint();
242
+ return;
207
243
  }
244
+
245
+ // DrawGUI_ColorPicker();
246
+ DrawGUI_AmaGDKBanner();
208
247
  EditorGUILayout.Space();
248
+ DrawGUI_AutoInitDisabled();
249
+
250
+ if (EditorApplication.isCompiling || EditorApplication.isUpdating)
251
+ {
252
+ EditorGUILayout.HelpBox("Please wait for UnityEditor to finish compiling or importing", MessageType.Warning);
253
+ return;
254
+ }
255
+
256
+ if (!searchedForConfig) TryLoadConfigAsset();
257
+ if (!adapterScanned) ScanForAdapterPackages();
209
258
 
210
259
  if (configAsset == null)
211
260
  {
212
261
  DrawGUI_ConfigMissing();
262
+ Repaint();
213
263
  return;
214
264
  }
215
265
 
216
- DrawGUI_AutoInit();
266
+ configSO = new SerializedObject(configAsset);
267
+ configSO.Update();
268
+
269
+ DrawProperty(configSO, "common");
270
+ GUILayout.Space(8f);
271
+ for (var i = 0; i < allAdapters.Count; i++)
272
+ {
273
+ var item = allAdapters[i];
274
+ DrawAdapterDetail(item.id, item.adapter);
275
+ }
276
+
277
+ EditorGUILayout.Space();
217
278
  AmaGUI.Foldout("Config", ref showConfigDetail, DrawGUI_ConfigDetail, DrawGUI_ConfigAsset);
218
279
  AmaGUI.Foldout("Adapters", ref showAdapterInstaller, DrawGUI_AdapterList);
280
+ }
219
281
 
220
- //("Example", ref showExampleDetail, DrawGUI_ExampleScene);
282
+ private static List<(string id, Adapter2 adapter)> allAdapters = new List<(string, Adapter2)>();
283
+ private static readonly Dictionary<string, bool> configOpen = new Dictionary<string, bool>();
284
+
285
+ private static List<Type> FindSubClassesOf(Type baseType)
286
+ {
287
+ List<Type> result = new List<Type>();
221
288
 
222
- if (GUILayout.Button("Clear All Data"))
289
+ Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
290
+ foreach (Assembly assembly in assemblies)
223
291
  {
224
- GDKFileUtils.ClearCacheData();
292
+ if (!assembly.FullName.Contains("Assembly-CSharp")) continue;
293
+ if (!assembly.FullName.Contains("Editor")) continue;
294
+ Debug.Log(assembly.FullName);
225
295
  }
226
- }
227
296
 
228
- private static readonly Dictionary<string, bool> configOpen = new Dictionary<string, bool>();
229
- private static void DrawAdapterDetail(string adapterId)
297
+ return result;
298
+ }
299
+
300
+ private static void RefreshListAdapters()
301
+ {
302
+ allAdapters = SDK_IDS
303
+ .Select(id => (id: id, adapter: GetAdapter(id)))
304
+ .OrderBy(x=>
305
+ x.adapter == null ? 2:
306
+ x.adapter.enabled == false ? 1 :
307
+ -x.adapter.initOrder)
308
+ .ToList();
309
+ }
310
+
311
+ private static void DrawAdapterDetail(string adapterId, Adapter2 adapter)
230
312
  {
231
313
  if (!configOpen.TryGetValue(adapterId, out bool isOpen))
232
314
  {
233
315
  configOpen.Add(adapterId, isOpen = false);
234
316
  }
235
317
 
318
+ if (adapter == null)
319
+ {
320
+ EditorGUILayout.HelpBox("Adapter<" + adapterId + "> not imported!", MessageType.Info);
321
+ return;
322
+ }
323
+
236
324
  SDKStatus status = SDKStatus.Get(adapterId);
237
325
  bool changed = AmaGUI.Foldout(ObjectNames.NicifyVariableName(adapterId), ref isOpen, () =>
238
326
  {
239
- DrawSDKConfig(adapterId, status);
327
+ DrawSDKConfig(adapter, adapterId, status);
240
328
  }, () =>
241
329
  {
242
330
  GUILayout.FlexibleSpace();
243
- AmaGUI.DrawVersionTag(status.sdkVersion, status.adapterInstalled);
331
+ if (!adapter.enabled)
332
+ {
333
+ Color c = GUI.color;
334
+ GUI.color = Color.yellow;
335
+ GUILayout.Label("disabled", GUILayout.Width(60f));
336
+ GUI.color = c;
337
+ }
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)
342
+ {
343
+ Event.current.Use();
344
+ CreateGenericMenu(adapter, adapterId);
345
+ }
244
346
  });
245
347
 
348
+
349
+
246
350
  if (changed) configOpen[adapterId] = isOpen;
247
351
  }
352
+
353
+ private static void CreateGenericMenu(Adapter2 adapter, string adapterId)
354
+ {
355
+ var menu = new GenericMenu();
356
+ menu.AddDisabledItem(new GUIContent(adapterId));
357
+ menu.AddSeparator("");
358
+ menu.AddItem(new GUIContent("enable"), adapter.enabled, () =>
359
+ {
360
+ adapter.enabled = !adapter.enabled;
361
+ EditorUtility.SetDirty(configAsset);
362
+ });
363
+
364
+ menu.ShowAsContext();
365
+ }
248
366
 
249
- private static void DrawSDKConfig(string adapterId, SDKStatus status)
367
+ private static void DrawSDKConfig(Adapter2 adapter, string adapterId, SDKStatus status)
250
368
  {
251
369
  if (!status.sdkInstalled)
252
370
  {
@@ -258,28 +376,87 @@ namespace Amanotes.Editor
258
376
  EditorGUILayout.HelpBox($"{adapterId}-GDKAdapter not installed", MessageType.Warning);
259
377
  return;
260
378
  }
261
-
262
- if (adapterId == IRONSOURCE)
263
- {
264
- DrawIRSAdapterVersions();
265
- } else
379
+
380
+ if (!status.adapterInstalled)
266
381
  {
267
- EditorGUILayout.HelpBox("Config for <" + adapterId + "> should be shown here!", MessageType.Info);
382
+ EditorGUILayout.HelpBox($"{adapterId}-GDKAdapter not installed", MessageType.Warning);
383
+ return;
268
384
  }
385
+
386
+ DrawModuleConfig(adapter, adapterId);
269
387
  }
270
388
 
271
- // private static void DrawVersion(string label, string version)
272
- // {
273
- // EditorGUI.BeginDisabledGroup(true);
274
- // {
275
- // GUILayout.Label($"{label} v{version}", EditorStyles.largeLabel);
276
- // }
277
- // EditorGUI.EndDisabledGroup();
278
- // }
389
+ private static void DrawModuleConfig(Adapter2 adapter, string adapterId)
390
+ {
391
+ EditorGUI.BeginDisabledGroup(!adapter.enabled);
392
+ EditorGUIUtility.labelWidth += 70;
393
+ {
394
+ DrawProperty(configSO, adapterId);
395
+ GUILayout.Space(8f);
279
396
 
280
- public static void DrawInitOrder()
397
+ if (adapterId == IRONSOURCE)
398
+ {
399
+ AmaGUI.Foldout("Enabled AdNetworks", ref showIRSAdapter, () =>
400
+ {
401
+ DrawIRSAdapterVersions();
402
+ GUILayout.Space(8f);
403
+ });
404
+ }
405
+
406
+ if (adapter.enabled)
407
+ {
408
+ Color c = GUI.contentColor;
409
+ GUI.contentColor = BLUE;
410
+ if (adapter is AdAdapter) EditorGUILayout.PropertyField(configSO.FindProperty("ad"), new GUIContent("Shared settings for Ad Modules"));
411
+ if (adapter is IAPAdapter) EditorGUILayout.PropertyField(configSO.FindProperty("iap"), new GUIContent("Shared settings for In App Purchase Modules"));
412
+ if (adapter is AnalyticsAdapter) EditorGUILayout.PropertyField(configSO.FindProperty("analytics"), new GUIContent("Shared settings for Analytics Modules"));
413
+ if (adapter is RemoteConfigAdapter) EditorGUILayout.PropertyField(configSO.FindProperty("remoteConfig"), new GUIContent("Shared settings for Remote Config Modules"));
414
+ GUI.contentColor = c;
415
+ }
416
+ configSO.ApplyModifiedProperties();
417
+ }
418
+ EditorGUIUtility.labelWidth -= 70;
419
+ EditorGUI.EndDisabledGroup();
420
+ }
421
+
422
+ private static void DrawProperty(SerializedObject so, string propertyField)
423
+ {
424
+ SerializedProperty property = so.FindProperty(propertyField);
425
+ if (property == null) return;
426
+
427
+ string basePath = property.propertyPath;
428
+ var first = true;
429
+ while (property.NextVisible(first))
430
+ {
431
+ first = false;
432
+ if (!property.propertyPath.Contains(basePath)) break;
433
+ EditorGUILayout.PropertyField(property);
434
+ }
435
+
436
+ so.ApplyModifiedProperties();
437
+ }
438
+
439
+ private static Adapter2 GetAdapter(string id)
281
440
  {
441
+ if (configAsset == null) return null;
442
+ Type configType = configAsset.GetType();
443
+
444
+ FieldInfo field = configType
445
+ .GetField(id, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
446
+
447
+ if (field == null)
448
+ {
449
+ #if AMAGDK_DEV
450
+ LogWarningOnce($"[GDKDev] Adapter <{id}> not declared in ConfigAsset?");
451
+ #endif
452
+ return null;
453
+ }
454
+
455
+ var adapter = (Adapter2) field.GetValue(AmaGDK.Config);
456
+ if (adapter != null) return adapter;
282
457
 
458
+ LogWarning($"Adapter <{id}> == null in ConfigAsset? (non-serialized?)");
459
+ return null;
283
460
  }
284
461
 
285
462
  public static void DrawIRSAdapterVersions()
@@ -109,12 +109,9 @@ namespace Amanotes.Core
109
109
  if (files == null)
110
110
  {
111
111
  string dataPath = Path.Combine(Application.dataPath, "AmaGDK/Adapters");
112
- if (!Directory.Exists(dataPath))
113
- {
114
- Debug.Log($"{dataPath} is not found");
115
- return;
116
- }
117
- DirectoryInfo directory = new DirectoryInfo(dataPath);
112
+ if (!Directory.Exists(dataPath)) return;
113
+
114
+ var directory = new DirectoryInfo(dataPath);
118
115
  files = directory.GetFiles("*Adapter.cs", SearchOption.AllDirectories);
119
116
  }
120
117
 
@@ -28,6 +28,8 @@ namespace Amanotes.Editor
28
28
  {
29
29
  //
30
30
  private static readonly Dictionary<string, SDKStatus> _cache = new Dictionary<string, SDKStatus>();
31
+ internal static void ClearCache(){ _cache.Clear(); }
32
+
31
33
  public string sdkId;
32
34
  public SemVer adapterVersion;
33
35
  public SemVer sdkVersion;
@@ -42,7 +44,7 @@ namespace Amanotes.Editor
42
44
  public static SDKStatus Get(string sdkId, bool force = false)
43
45
  {
44
46
  if (!force && _cache.TryGetValue(sdkId, out var result)) return result;
45
-
47
+
46
48
  result = new SDKStatus
47
49
  {
48
50
  sdkId = sdkId,
@@ -50,6 +52,8 @@ namespace Amanotes.Editor
50
52
  sdkVersion = new SemVer(ExtractVersion.ThirdParty(sdkId))
51
53
  };
52
54
 
55
+ // Debug.LogWarning($"Get <{sdkId} --> " + result.adapterVersion + " | " + result.sdkVersion);
56
+
53
57
  if (_cache.ContainsKey(sdkId))
54
58
  {
55
59
  _cache[sdkId] = result;
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  fileFormatVersion: 2
2
- guid: e92fc676e2bc74d8ab6e0e0fb24d713a
2
+ guid: 222ccc536a164489b9395deda6febb72
3
3
  DefaultImporter:
4
4
  externalObjects: {}
5
5
  userData:
@@ -1,5 +1,5 @@
1
1
  fileFormatVersion: 2
2
- guid: ab7f4809a233742778d8686d6d64cc7f
2
+ guid: f1a83eaf0edbc4289a4edbce5fe129d5
3
3
  DefaultImporter:
4
4
  externalObjects: {}
5
5
  userData:
@@ -1,5 +1,5 @@
1
1
  fileFormatVersion: 2
2
- guid: 5948ef7c71830412a9f4e7b554b9918e
2
+ guid: 38be6e654db3b46d08f89c929c529466
3
3
  DefaultImporter:
4
4
  externalObjects: {}
5
5
  userData:
@@ -1,5 +1,5 @@
1
1
  fileFormatVersion: 2
2
- guid: b3dd18b0e63564bd4965d76fb69d1e16
2
+ guid: 66ca84d194de142f99878b42c6cda958
3
3
  DefaultImporter:
4
4
  externalObjects: {}
5
5
  userData:
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: e82b05dd6713649cc94fb3036d21beab
3
+ DefaultImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant: