com.amanotes.gdk 0.2.21 → 0.2.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.22 - 2023-10-11]
4
+ - Get adapter info
5
+
3
6
  ## [0.2.21 - 2023-10-11]
4
7
  - RevenueCat adapter v6.0.0
5
8
  - Handle early Firebase call
Binary file
Binary file
Binary file
Binary file
Binary file
package/Runtime/AmaGDK.cs CHANGED
@@ -1,5 +1,6 @@
1
1
  using System;
2
2
  using System.Collections;
3
+ using System.Collections.Generic;
3
4
  using System.Diagnostics;
4
5
  using System.IO;
5
6
  using System.Text;
@@ -8,21 +9,23 @@ using Amanotes.Core.Internal;
8
9
  using UnityEngine;
9
10
  using static Amanotes.Core.Internal.Logging;
10
11
  using static Amanotes.Core.Internal.Messsage;
11
- using Debug = System.Diagnostics.Debug;
12
12
 
13
13
  namespace Amanotes.Core
14
14
  {
15
15
  public partial class AmaGDK : MonoBehaviour
16
16
  {
17
- public const string VERSION = "0.2.21";
17
+ public const string VERSION = "0.2.22";
18
18
 
19
19
  internal static AmaGDK _instance;
20
20
  internal static Status _status = Status.None;
21
21
  internal static Action _onReadyCallback;
22
+ internal static Action<AdapterInfo> _onAdapterReadyCallback;
22
23
  internal static bool _allowInit = false;
23
24
  public bool autoInit = true;
24
25
 
25
26
  private static ConfigAsset _config = null;
27
+ private static readonly Dictionary<string, AdapterInfo> _adapters = new Dictionary<string, AdapterInfo>();
28
+
26
29
  internal static ConfigAsset Config
27
30
  {
28
31
  get
@@ -53,7 +56,7 @@ namespace Amanotes.Core
53
56
  _allowInit = _allowInit || autoInit;
54
57
  StartCoroutine(InitRoutine());
55
58
  }
56
-
59
+
57
60
  IEnumerator InitRoutine()
58
61
  {
59
62
  if (Config == null)
@@ -83,7 +86,7 @@ namespace Amanotes.Core
83
86
 
84
87
  _status = Status.Initialize;
85
88
  float startTime = Time.realtimeSinceStartup;
86
- StringBuilder adapterInfo = new StringBuilder();
89
+ StringBuilder adapterAnnounce = new StringBuilder();
87
90
 
88
91
  // sort on priority
89
92
  Adapter.listAdapters.Sort((a1, a2) => a1.initOrder.CompareTo(a2.initOrder));
@@ -92,7 +95,7 @@ namespace Amanotes.Core
92
95
  Log($"Initiating {adapter.adapterId} --> initOrder: {adapter.initOrder}");
93
96
  adapter.Init();
94
97
  RegisterUnityCallback(adapter);
95
-
98
+
96
99
  time = 0;
97
100
 
98
101
  while (!adapter.IsReady)
@@ -103,9 +106,14 @@ namespace Amanotes.Core
103
106
  LogWarning($"{adapter.adapterId} init time out: {timeout}");
104
107
  break;
105
108
  }
106
-
107
- adapterInfo.AppendLine(string.Format("[{0}] {1} (adapter v{2})", adapter.IsReady ? "OK" : "FAIL", adapter.adapterId, adapter.adapterVersion));
109
+
110
+ var adapterInfo = new AdapterInfo(adapter.adapterId, adapter.adapterVersion, adapter.IsReady);
111
+ _adapters.Add(adapter.adapterId, adapterInfo);
112
+ _onAdapterReadyCallback?.Invoke(adapterInfo);
113
+ adapterAnnounce.AppendLine(string.Format("[{0}] {1} (adapter v{2})", adapter.IsReady ? "OK" : "FAIL",
114
+ adapter.adapterId, adapter.adapterVersion));
108
115
  }
116
+ _onAdapterReadyCallback = null;
109
117
 
110
118
  // Init modules (Adapter managers)
111
119
  Analytics.Init();
@@ -115,20 +123,22 @@ namespace Amanotes.Core
115
123
  _status = Status.Ready;
116
124
  _onReadyCallback?.Invoke();
117
125
  _onReadyCallback = null;
118
- Log($"AmaGDK v{VERSION} | {READY} in {Time.realtimeSinceStartup - startTime}s\n\n{adapterInfo.ToString()}");
126
+ Log($"AmaGDK v{VERSION} | {READY} in {Time.realtimeSinceStartup - startTime}s\n\n{adapterAnnounce.ToString()}");
119
127
  }
120
128
 
121
129
  void RegisterUnityCallback(AdapterContext adapter)
122
130
  {
123
131
  switch (adapter)
124
132
  {
125
- case IOnFrameUpdate a: {
133
+ case IOnFrameUpdate a:
134
+ {
126
135
  onFrameUpdate -= a.OnFrameUpdate;
127
136
  onFrameUpdate += a.OnFrameUpdate;
128
137
  break;
129
138
  }
130
139
 
131
- case IOnApplicationPause a: {
140
+ case IOnApplicationPause a:
141
+ {
132
142
  onApplicationPause -= a.OnApplicationPause;
133
143
  onApplicationPause += a.OnApplicationPause;
134
144
  break;
@@ -140,16 +150,16 @@ namespace Amanotes.Core
140
150
  applicationFocus += a.OnApplicationFocus;
141
151
  break;
142
152
  }
143
-
153
+
144
154
  case IOnApplicationQuit a:
145
155
  {
146
156
  applicationQuit -= a.OnApplicationQuit;
147
157
  applicationQuit += a.OnApplicationQuit;
148
- break;
158
+ break;
149
159
  }
150
160
  }
151
161
  }
152
-
162
+
153
163
  }
154
164
 
155
165
  public partial class AmaGDK // PUBLIC APIS
@@ -188,12 +198,40 @@ namespace Amanotes.Core
188
198
  {
189
199
  if (onReady == null)
190
200
  {
191
- LogWarning("Can not add a null callback!");
201
+ LogWarning("Cannot add a null callback!");
192
202
  return;
193
203
  }
194
204
  _onReadyCallback -= onReady;
195
205
  _onReadyCallback += onReady;
196
206
  }
207
+
208
+ public static void SetAdapterReadyCallback(Action<AdapterInfo> onAdapterReady)
209
+ {
210
+ if (onAdapterReady == null)
211
+ {
212
+ LogWarning("Cannot add a null callback!");
213
+ return;
214
+ }
215
+ _onAdapterReadyCallback -= onAdapterReady;
216
+ _onAdapterReadyCallback += onAdapterReady;
217
+ }
218
+
219
+ public static AdapterInfo GetAdapterInfo(string id)
220
+ {
221
+ if (string.IsNullOrWhiteSpace(id))
222
+ {
223
+ LogWarning("Please provide Adapter ID to get the info.");
224
+ return default;
225
+ }
226
+
227
+ if (!_adapters.ContainsKey(id))
228
+ {
229
+ LogWarning($"Adapter {id} is not found.");
230
+ return default;
231
+ }
232
+
233
+ return _adapters[id];
234
+ }
197
235
  }
198
236
 
199
237
  public partial class AmaGDK
@@ -238,7 +276,7 @@ namespace Amanotes.Core
238
276
  }
239
277
  }
240
278
 
241
- public partial class AmaGDK // Switch dev mode
279
+ public partial class AmaGDK // Switch dev mode
242
280
  {
243
281
  [ContextMenu("Change Dev Mode")]
244
282
  public void ChangeDevMode()
@@ -281,4 +319,18 @@ namespace Amanotes.Core
281
319
  File.WriteAllText(manifestPath, manifestJson);
282
320
  }
283
321
  }
322
+
323
+ public struct AdapterInfo
324
+ {
325
+ public string id;
326
+ public string version;
327
+ public bool isReady;
328
+
329
+ public AdapterInfo(string id, string version, bool isReady)
330
+ {
331
+ this.id = id;
332
+ this.version = version;
333
+ this.isReady = isReady;
334
+ }
335
+ }
284
336
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.amanotes.gdk",
3
- "version": "0.2.21",
3
+ "version": "0.2.22",
4
4
  "displayName": "AmaGDK",
5
5
  "description": "Amanotes Game Development Kit",
6
6
  "unity": "2019.4",