com.amanotes.gdk 0.2.45 → 0.2.47
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 +10 -0
- package/Editor/AmaGDKEditor.cs +325 -120
- package/Editor/MatchSDKVersion.cs +3 -6
- package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs +6 -4
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/Extra/AmaGDKProject.unitypackage +0 -0
- package/Packages/AmaGDKConfig.unitypackage +0 -0
- package/Packages/AmaGDKExample.unitypackage +0 -0
- package/Packages/AmaGDKTest.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter.unitypackage +0 -0
- package/Packages/{FirebaseAnalyticsAdapter_v9.1.0.unitypackage.meta → AppsFlyerAdapter.unitypackage.meta} +1 -1
- package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
- package/Packages/{IronSourceAdapter_v7.5.2.unitypackage.meta → FirebaseAnalyticsAdapter.unitypackage.meta} +1 -1
- package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
- package/Packages/{FirebaseRemoteConfigAdapter_v9.1.0.unitypackage.meta → FirebaseRemoteConfigAdapter.unitypackage.meta} +1 -1
- package/Packages/IronSourceAdapter.unitypackage +0 -0
- package/Packages/{AppsFlyerAdapter_v6.5.4.unitypackage.meta → IronSourceAdapter.unitypackage.meta} +1 -1
- package/Packages/RevenueCatAdapter.unitypackage +0 -0
- package/Packages/RevenueCatAdapter.unitypackage.meta +7 -0
- package/Runtime/AmaGDK.Adapters.cs +55 -77
- package/Runtime/AmaGDK.Ads.cs +155 -163
- package/Runtime/AmaGDK.Analytics.cs +245 -125
- package/Runtime/AmaGDK.Config.cs +2 -1
- package/Runtime/AmaGDK.IAP.cs +47 -48
- package/Runtime/AmaGDK.RemoteConfig.cs +38 -35
- package/Runtime/AmaGDK.UserProfile.cs +27 -19
- package/Runtime/AmaGDK.cs +158 -111
- package/Runtime/Core.meta +8 -0
- package/{Editor/Utils/AmaGDKEditor.GUI.cs → Runtime/Internal/AmaGDK.Internal.AmaGUI.cs} +110 -85
- package/{Editor/Utils/AmaGDKEditor.GUI.cs.meta → Runtime/Internal/AmaGDK.Internal.AmaGUI.cs.meta} +1 -1
- package/Runtime/{AmaGDK.Internal.SemVer.cs → Internal/AmaGDK.Internal.SemVer.cs} +21 -17
- package/Runtime/{AmaGDK.Internal.cs → Internal/AmaGDK.Internal.cs} +17 -6
- package/Runtime/{AmaGDK.Utils.cs → Internal/AmaGDK.Utils.cs} +91 -17
- package/Runtime/Internal.meta +8 -0
- package/package.json +1 -1
- package/Packages/AppsFlyerAdapter_v6.5.4.unitypackage +0 -0
- package/Packages/FirebaseAnalyticsAdapter_v9.1.0.unitypackage +0 -0
- package/Packages/FirebaseRemoteConfigAdapter_v9.1.0.unitypackage +0 -0
- package/Packages/IronSourceAdapter_v7.5.2.unitypackage +0 -0
- package/Packages/IronsourceAdapter_v7.2.6.unitypackage +0 -0
- package/Packages/IronsourceAdapter_v7.2.6.unitypackage.meta +0 -7
- package/Packages/RevenueCatAdapter_v6.0.0.unitypackage +0 -0
- package/Packages/RevenueCatAdapter_v6.0.0.unitypackage.meta +0 -7
- /package/Runtime/{AmaGDK.Internal.SemVer.cs.meta → Internal/AmaGDK.Internal.SemVer.cs.meta} +0 -0
- /package/Runtime/{AmaGDK.Internal.cs.meta → Internal/AmaGDK.Internal.cs.meta} +0 -0
- /package/Runtime/{AmaGDK.Utils.cs.meta → Internal/AmaGDK.Utils.cs.meta} +0 -0
- /package/Runtime/{AmaGDK.WebUtils.cs → Internal/AmaGDK.WebUtils.cs} +0 -0
- /package/Runtime/{AmaGDK.WebUtils.cs.meta → Internal/AmaGDK.WebUtils.cs.meta} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
using System;
|
|
2
2
|
using System.Collections.Generic;
|
|
3
3
|
using System.Text.RegularExpressions;
|
|
4
|
+
using UnityEngine.Profiling;
|
|
4
5
|
using static Amanotes.Core.Internal.Logging;
|
|
5
6
|
|
|
6
7
|
namespace Amanotes.Core.Internal
|
|
@@ -8,6 +9,7 @@ namespace Amanotes.Core.Internal
|
|
|
8
9
|
public struct SemVer : IComparable<SemVer>, IComparer<SemVer>
|
|
9
10
|
{
|
|
10
11
|
public static readonly SemVer ZERO = new SemVer(0, 0, 0);
|
|
12
|
+
private static readonly Regex VERSION_PATTERN = new Regex(@"^(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?$");
|
|
11
13
|
|
|
12
14
|
public int major;
|
|
13
15
|
public int minor;
|
|
@@ -30,25 +32,27 @@ namespace Amanotes.Core.Internal
|
|
|
30
32
|
extra = -1;
|
|
31
33
|
|
|
32
34
|
if (string.IsNullOrEmpty(version)) return;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var regex = new Regex(@"^(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?$");
|
|
37
|
-
Match match = regex.Match(version);
|
|
38
|
-
if (!match.Success)
|
|
35
|
+
|
|
36
|
+
Profiler.BeginSample("AmaGDK.SemVer()");
|
|
39
37
|
{
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
version = version.Trim();
|
|
39
|
+
Match match = VERSION_PATTERN.Match(version);
|
|
40
|
+
if (!match.Success)
|
|
41
|
+
{
|
|
42
|
+
LogWarning($"Invalid SemVer string: [{version}]");
|
|
43
|
+
Profiler.EndSample();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
major = int.Parse(match.Groups[1].Value);
|
|
47
|
+
minor = int.Parse(match.Groups[2].Value);
|
|
48
|
+
patch = int.Parse(match.Groups[3].Value);
|
|
49
|
+
if (match.Groups.Count > 3)
|
|
50
|
+
{
|
|
51
|
+
if (!int.TryParse(match.Groups[4].Value, out extra))
|
|
52
|
+
extra = -1;
|
|
53
|
+
}
|
|
42
54
|
}
|
|
43
|
-
|
|
44
|
-
minor = int.Parse(match.Groups[2].Value);
|
|
45
|
-
patch = int.Parse(match.Groups[3].Value);
|
|
46
|
-
if (match.Groups.Count > 3)
|
|
47
|
-
{
|
|
48
|
-
if (!int.TryParse(match.Groups[4].Value, out extra))
|
|
49
|
-
extra = -1;
|
|
50
|
-
}
|
|
51
|
-
|
|
55
|
+
Profiler.EndSample();
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
public bool isValid => this != ZERO;
|
|
@@ -22,7 +22,7 @@ namespace Amanotes.Core.Internal
|
|
|
22
22
|
|
|
23
23
|
public static class Messsage
|
|
24
24
|
{
|
|
25
|
-
public const string READY = "
|
|
25
|
+
public const string READY = "Init success";
|
|
26
26
|
public const string SDK_INIT_CALLED = "init has been called!";
|
|
27
27
|
public const string MULTIPLE_INSTANCE = "multiple instance found!";
|
|
28
28
|
public const string CONFIG_NOT_FOUND = "AmaGDKConfig not found in Resources!";
|
|
@@ -52,11 +52,11 @@ namespace Amanotes.Core.Internal
|
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
GameObject go = UnityObject.Instantiate(prefab);
|
|
56
|
+
go.name = "AmaGDK";
|
|
57
|
+
go.transform.SetAsLastSibling();
|
|
58
58
|
Selection.activeObject = null;
|
|
59
|
-
Selection.activeObject =
|
|
59
|
+
Selection.activeObject = go;
|
|
60
60
|
}
|
|
61
61
|
#endif
|
|
62
62
|
}
|
|
@@ -113,7 +113,18 @@ namespace Amanotes.Core.Internal
|
|
|
113
113
|
// Logging.LogWarning("Something wrong: another AmaGDK instance found!");
|
|
114
114
|
UnityObject.Destroy(result[i].gameObject);
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
|
|
117
|
+
// Reset all adapter status
|
|
118
|
+
var allAdapters = Adapter2.GetAllAdapter<Adapter2>();
|
|
119
|
+
foreach (var adapter in allAdapters)
|
|
120
|
+
{
|
|
121
|
+
adapter.status = Status.None;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Reset all modules
|
|
125
|
+
Ads.context = null;
|
|
126
|
+
Ads._adapter = null;
|
|
127
|
+
|
|
117
128
|
_status = Status.None;
|
|
118
129
|
_allowInit = false;
|
|
119
130
|
|
|
@@ -2,9 +2,11 @@ using System;
|
|
|
2
2
|
using System.Collections;
|
|
3
3
|
using System.Collections.Generic;
|
|
4
4
|
using System.IO;
|
|
5
|
+
using System.Reflection;
|
|
5
6
|
using System.Text;
|
|
6
7
|
using System.Text.RegularExpressions;
|
|
7
8
|
using UnityEngine;
|
|
9
|
+
using UnityEngine.Profiling;
|
|
8
10
|
using static Amanotes.Core.Internal.Logging;
|
|
9
11
|
|
|
10
12
|
namespace Amanotes.Core.Internal
|
|
@@ -15,12 +17,75 @@ namespace Amanotes.Core.Internal
|
|
|
15
17
|
{
|
|
16
18
|
AmaGDK._instance.StartCoroutine(DelayCallRoutine(seconds, action));
|
|
17
19
|
}
|
|
20
|
+
|
|
21
|
+
public static void RegisterUnityCallbacks<T>(T target)
|
|
22
|
+
{
|
|
23
|
+
if (target == null)
|
|
24
|
+
{
|
|
25
|
+
LogWarning("RegisterUnityCallbacks: Target is null!");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (target is IOnFrameUpdate u)
|
|
30
|
+
{
|
|
31
|
+
AmaGDK.onFrameUpdate -= u.OnFrameUpdate;
|
|
32
|
+
AmaGDK.onFrameUpdate += u.OnFrameUpdate;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (target is IOnApplicationPause p)
|
|
36
|
+
{
|
|
37
|
+
AmaGDK.onApplicationPause -= p.OnApplicationPause;
|
|
38
|
+
AmaGDK.onApplicationPause += p.OnApplicationPause;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (target is IOnApplicationFocus f)
|
|
42
|
+
{
|
|
43
|
+
AmaGDK.applicationFocus -= f.OnApplicationFocus;
|
|
44
|
+
AmaGDK.applicationFocus += f.OnApplicationFocus;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (target is IOnApplicationQuit q)
|
|
48
|
+
{
|
|
49
|
+
AmaGDK.applicationQuit -= q.OnApplicationQuit;
|
|
50
|
+
AmaGDK.applicationQuit += q.OnApplicationQuit;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
18
53
|
|
|
19
54
|
private static IEnumerator DelayCallRoutine(float seconds, Action callback)
|
|
20
55
|
{
|
|
21
56
|
yield return new WaitForSecondsRealtime(seconds);
|
|
22
57
|
callback();
|
|
23
58
|
}
|
|
59
|
+
|
|
60
|
+
public static IEnumerator Timeout(float timeoutInSecs, Func<bool> completeCheckFunc)
|
|
61
|
+
{
|
|
62
|
+
float time = Time.realtimeSinceStartup;
|
|
63
|
+
while (completeCheckFunc() == false)
|
|
64
|
+
{
|
|
65
|
+
yield return null;
|
|
66
|
+
if (Time.realtimeSinceStartup - time > timeoutInSecs) yield break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public static class GDKReflection
|
|
72
|
+
{
|
|
73
|
+
internal static readonly BindingFlags FLAGS = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
|
|
74
|
+
public static T GetFieldValue<T>(this object source, string fieldName, BindingFlags? flags = null)
|
|
75
|
+
{
|
|
76
|
+
if (source == null) return default(T);
|
|
77
|
+
Type sourceType = source.GetType();
|
|
78
|
+
FieldInfo field = sourceType.GetField(fieldName, flags ?? FLAGS);
|
|
79
|
+
|
|
80
|
+
if (field == null)
|
|
81
|
+
{
|
|
82
|
+
LogWarning($"fieldName <{fieldName}> not found in {sourceType}?");
|
|
83
|
+
return default(T);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return (T)field.GetValue(source);
|
|
87
|
+
}
|
|
88
|
+
|
|
24
89
|
}
|
|
25
90
|
|
|
26
91
|
internal static class GDKFileUtils
|
|
@@ -165,12 +230,12 @@ namespace Amanotes.Core.Internal
|
|
|
165
230
|
|
|
166
231
|
internal static void ClearCacheData()
|
|
167
232
|
{
|
|
168
|
-
|
|
169
|
-
|
|
233
|
+
var sb = new StringBuilder();
|
|
234
|
+
sb.AppendLine("[AmaGDK] All cached data & stats cleared");
|
|
170
235
|
|
|
171
236
|
if (!Directory.Exists(basePath))
|
|
172
237
|
{
|
|
173
|
-
|
|
238
|
+
sb.AppendLine("Cache path not exists: " + basePath);
|
|
174
239
|
return;
|
|
175
240
|
}
|
|
176
241
|
|
|
@@ -178,9 +243,9 @@ namespace Amanotes.Core.Internal
|
|
|
178
243
|
foreach (string path in filePaths)
|
|
179
244
|
{
|
|
180
245
|
Delete(path);
|
|
181
|
-
|
|
246
|
+
sb.AppendLine($"[deleted] - {path}");
|
|
182
247
|
}
|
|
183
|
-
Debug.Log(
|
|
248
|
+
Debug.Log(sb);
|
|
184
249
|
}
|
|
185
250
|
}
|
|
186
251
|
|
|
@@ -253,14 +318,21 @@ namespace Amanotes.Core.Internal
|
|
|
253
318
|
{
|
|
254
319
|
public static T LoadJsonFromFile<T>(this T instance) where T : IJsonFile, new()
|
|
255
320
|
{
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
var result = new T();
|
|
259
|
-
instance = result;
|
|
260
|
-
}
|
|
321
|
+
instance ??= new T();
|
|
322
|
+
|
|
261
323
|
string fileName = instance.GetType().Name;
|
|
262
324
|
string json = GDKFileUtils.Load(fileName);
|
|
263
|
-
|
|
325
|
+
if (!string.IsNullOrEmpty(json))
|
|
326
|
+
{
|
|
327
|
+
try
|
|
328
|
+
{
|
|
329
|
+
JsonUtility.FromJsonOverwrite(json, instance);
|
|
330
|
+
} catch (Exception e)
|
|
331
|
+
{
|
|
332
|
+
LogWarning("LoadJsonFromFile error: " + fileName + "\n" + e);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
264
336
|
return instance;
|
|
265
337
|
}
|
|
266
338
|
|
|
@@ -293,7 +365,8 @@ namespace Amanotes.Core.Internal
|
|
|
293
365
|
public static string DictionaryToJson(IDictionary inputDict, bool format = false, bool checkJsonInString = true)
|
|
294
366
|
{
|
|
295
367
|
if (inputDict == null) return "{}";
|
|
296
|
-
|
|
368
|
+
|
|
369
|
+
Profiler.BeginSample("AmaGDK.JsonUtils.DictionaryToJson()");
|
|
297
370
|
var jsonSb = new StringBuilder();
|
|
298
371
|
jsonSb.Append("{");
|
|
299
372
|
var isFirstElement = true;
|
|
@@ -311,12 +384,13 @@ namespace Amanotes.Core.Internal
|
|
|
311
384
|
|
|
312
385
|
jsonSb.AppendFormat("{0}\"{1}\":", format ? "\n" : "", key);
|
|
313
386
|
AppendJsonValue(ref jsonSb, key, value, format, checkJsonInString);
|
|
314
|
-
|
|
315
387
|
}
|
|
316
388
|
|
|
317
389
|
jsonSb.AppendFormat("{0}{1}", format ? "\n" : "", "}");
|
|
318
|
-
|
|
319
|
-
|
|
390
|
+
var result = jsonSb.ToString();
|
|
391
|
+
Profiler.EndSample();
|
|
392
|
+
|
|
393
|
+
return result;
|
|
320
394
|
}
|
|
321
395
|
|
|
322
396
|
private static void GetJsonIListValue(ref StringBuilder jsonSb, string key, IList list, bool format)
|
|
@@ -396,8 +470,8 @@ namespace Amanotes.Core.Internal
|
|
|
396
470
|
|
|
397
471
|
private static string EscapeJsonString(string input)
|
|
398
472
|
{
|
|
399
|
-
//Match any occurrence of a backslash(\)
|
|
400
|
-
string pattern = "[\\\
|
|
473
|
+
//Match any occurrence of a backslash(\) and double quotation (")
|
|
474
|
+
string pattern = "[\\\"]";
|
|
401
475
|
return Regex.Replace(input, pattern, match => $"\\{match.Value}");
|
|
402
476
|
}
|
|
403
477
|
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|