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.
- package/CHANGELOG.md +17 -0
- package/Editor/AmaGDKEditor.cs +149 -63
- package/Editor/AmaGDKExtra.cs +31 -0
- package/Editor/AmaGDKExtra.cs.meta +11 -0
- package/Editor/Extra/GDKAutoBuild.cs +891 -0
- package/Editor/Extra/GDKAutoBuild.cs.meta +3 -0
- package/Editor/Extra/GDKProjectCP.cs +158 -0
- package/Editor/Extra/GDKProjectCP.cs.meta +11 -0
- package/Editor/Extra.meta +8 -0
- package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs +1 -1
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/Extra/AndroidPostProcessor.unitypackage +0 -0
- package/Extra/{AmaGDKProject.unitypackage.meta → AndroidPostProcessor.unitypackage.meta} +1 -1
- package/Extra/CheckDiskSpace.unitypackage +0 -0
- package/Extra/CheckDiskSpace.unitypackage.meta +7 -0
- package/Extra/SDKVersionTracking.unitypackage +0 -0
- package/Extra/SDKVersionTracking.unitypackage.meta +7 -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.unitypackage +0 -0
- package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
- package/Packages/IronSourceAdapter.unitypackage +0 -0
- package/Packages/RevenueCatAdapter.unitypackage +0 -0
- package/Runtime/AmaGDK.Adapters.cs +0 -4
- package/Runtime/AmaGDK.Ads.cs +92 -31
- package/Runtime/AmaGDK.Analytics.cs +97 -64
- package/Runtime/AmaGDK.IAP.cs +39 -45
- package/Runtime/AmaGDK.RemoteConfig.cs +76 -52
- package/Runtime/AmaGDK.UserProfile.cs +106 -124
- package/Runtime/AmaGDK.cs +46 -35
- package/Runtime/Internal/AmaGDK.Event.cs +185 -0
- package/Runtime/Internal/AmaGDK.Event.cs.meta +3 -0
- package/Runtime/Internal/AmaGDK.Internal.cs +4 -0
- package/Runtime/Internal/AmaGDK.Utils.cs +85 -24
- package/Runtime/Klavar/Attributes.meta +0 -4
- package/Runtime/Klavar.meta +0 -4
- package/package.json +1 -1
- package/Extra/AmaGDKProject.unitypackage +0 -0
package/Runtime/AmaGDK.cs
CHANGED
|
@@ -17,18 +17,27 @@ namespace Amanotes.Core
|
|
|
17
17
|
{
|
|
18
18
|
public partial class AmaGDK : MonoBehaviour
|
|
19
19
|
{
|
|
20
|
-
public const string VERSION = "0.2.
|
|
20
|
+
public const string VERSION = "0.2.50";
|
|
21
21
|
|
|
22
22
|
internal static AmaGDK _instance;
|
|
23
23
|
internal static Status _status = Status.None;
|
|
24
|
-
internal static Action _onReadyCallback;
|
|
25
|
-
internal static Action<string> _onAdapterReadyCallback;
|
|
26
24
|
internal static bool _allowInit = false;
|
|
27
25
|
public bool autoInit = true;
|
|
28
26
|
|
|
29
27
|
private static ConfigAsset _config = null;
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
|
|
29
|
+
public static partial class Event
|
|
30
|
+
{
|
|
31
|
+
public const string GDK_HOOK_START = nameof(GDK_HOOK_START);
|
|
32
|
+
public const string GDK_HOOK_END = nameof(GDK_HOOK_END);
|
|
33
|
+
|
|
34
|
+
public const string GDK_INIT_START = nameof(GDK_INIT_START);
|
|
35
|
+
public const string GDK_INIT_END = nameof(GDK_INIT_END);
|
|
36
|
+
|
|
37
|
+
public const string GDK_READY = nameof(GDK_READY);
|
|
38
|
+
public const string ADAPTER_READY = nameof(ADAPTER_READY);
|
|
39
|
+
}
|
|
40
|
+
|
|
32
41
|
public static ConfigAsset Config
|
|
33
42
|
{
|
|
34
43
|
get
|
|
@@ -42,15 +51,17 @@ namespace Amanotes.Core
|
|
|
42
51
|
|
|
43
52
|
private void Awake()
|
|
44
53
|
{
|
|
45
|
-
if (_instance != null
|
|
54
|
+
if (_instance != null)
|
|
46
55
|
{
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
if (_instance != this)
|
|
57
|
+
{
|
|
58
|
+
LogWarning(MULTIPLE_INSTANCE);
|
|
59
|
+
Destroy(this);
|
|
60
|
+
}
|
|
61
|
+
LogWarning("Should never be here!");
|
|
49
62
|
return;
|
|
50
63
|
}
|
|
51
|
-
|
|
52
|
-
if (_instance != null) LogWarning("Should never be here!");
|
|
53
|
-
|
|
64
|
+
|
|
54
65
|
_instance = this;
|
|
55
66
|
DontDestroyOnLoad(this);
|
|
56
67
|
|
|
@@ -60,10 +71,12 @@ namespace Amanotes.Core
|
|
|
60
71
|
|
|
61
72
|
IEnumerator InitHook()
|
|
62
73
|
{
|
|
74
|
+
dispatcher.Dispatch(Event.GDK_HOOK_START);
|
|
63
75
|
int nHooks = Hook.hooks.Count;
|
|
64
76
|
if (nHooks == 0)
|
|
65
77
|
{
|
|
66
78
|
Log($"[Hook] No hook registered!");
|
|
79
|
+
dispatcher.Dispatch(Event.GDK_HOOK_END);
|
|
67
80
|
yield break;
|
|
68
81
|
}
|
|
69
82
|
|
|
@@ -71,7 +84,6 @@ namespace Amanotes.Core
|
|
|
71
84
|
var hookCompleted = false;
|
|
72
85
|
|
|
73
86
|
float stTime = Time.realtimeSinceStartup;
|
|
74
|
-
|
|
75
87
|
Hook.TriggerHooks(() =>
|
|
76
88
|
{
|
|
77
89
|
hookCompleted = true;
|
|
@@ -79,6 +91,7 @@ namespace Amanotes.Core
|
|
|
79
91
|
yield return new WaitUntil(() => hookCompleted);
|
|
80
92
|
float elapsed = Time.realtimeSinceStartup - stTime;
|
|
81
93
|
Log($"[Hook] {nHooks} hooks complete after " + elapsed);
|
|
94
|
+
dispatcher.Dispatch(Event.GDK_HOOK_END);
|
|
82
95
|
}
|
|
83
96
|
|
|
84
97
|
IEnumerator WaitForManualInit()
|
|
@@ -106,7 +119,8 @@ namespace Amanotes.Core
|
|
|
106
119
|
User.InitModule();
|
|
107
120
|
Analytics.InitModule();
|
|
108
121
|
Ads.InitModule();
|
|
109
|
-
IAP.InitModule();
|
|
122
|
+
IAP.InitModule();
|
|
123
|
+
RemoteConfig.InitModule();
|
|
110
124
|
}
|
|
111
125
|
Profiler.EndSample();
|
|
112
126
|
}
|
|
@@ -119,6 +133,7 @@ namespace Amanotes.Core
|
|
|
119
133
|
Analytics.StartModule();
|
|
120
134
|
Ads.StartModule();
|
|
121
135
|
IAP.StartModule();
|
|
136
|
+
RemoteConfig.StartModule();
|
|
122
137
|
}
|
|
123
138
|
Profiler.EndSample();
|
|
124
139
|
}
|
|
@@ -137,9 +152,9 @@ namespace Amanotes.Core
|
|
|
137
152
|
{
|
|
138
153
|
// Log($"Initiating {adapter.adapterId} --> initOrder: {adapter.initOrder} | {adapter.status}");
|
|
139
154
|
float startTime = Time.realtimeSinceStartup;
|
|
140
|
-
Profiler.BeginSample("AmaGDK.adapter.InitSDK
|
|
155
|
+
Profiler.BeginSample($"AmaGDK.adapter.InitSDK-{adapter.adapterId}");
|
|
141
156
|
{
|
|
142
|
-
adapter.InitSDK();
|
|
157
|
+
adapter.InitSDK();
|
|
143
158
|
}
|
|
144
159
|
Profiler.EndSample();
|
|
145
160
|
|
|
@@ -150,13 +165,12 @@ namespace Amanotes.Core
|
|
|
150
165
|
LogWarning($"{adapter.adapterId} init time out: {TIMEOUT}");
|
|
151
166
|
}
|
|
152
167
|
|
|
153
|
-
|
|
168
|
+
dispatcher.Dispatch(Event.ADAPTER_READY, adapter.adapterId);
|
|
154
169
|
sb.AppendLine($"[{(adapter.IsReady ? " OK " : "FAIL")}] {adapter.adapterId} (~ {Time.realtimeSinceStartup - startTime:#0.00}s)");
|
|
155
170
|
|
|
156
171
|
// Wait for postprocessing of each adapter
|
|
157
172
|
yield return null;
|
|
158
173
|
}
|
|
159
|
-
_onAdapterReadyCallback = null;
|
|
160
174
|
}
|
|
161
175
|
|
|
162
176
|
|
|
@@ -170,6 +184,7 @@ namespace Amanotes.Core
|
|
|
170
184
|
float startTime = Time.realtimeSinceStartup;
|
|
171
185
|
yield return InitHook();
|
|
172
186
|
|
|
187
|
+
dispatcher.Dispatch(Event.GDK_INIT_START);
|
|
173
188
|
var sb = new StringBuilder();
|
|
174
189
|
InitModules();
|
|
175
190
|
|
|
@@ -177,10 +192,10 @@ namespace Amanotes.Core
|
|
|
177
192
|
yield return InitAdapters(sb);
|
|
178
193
|
|
|
179
194
|
StartModules();
|
|
195
|
+
dispatcher.Dispatch(Event.GDK_INIT_END);
|
|
180
196
|
|
|
181
197
|
_status = Status.Ready;
|
|
182
|
-
|
|
183
|
-
_onReadyCallback = null;
|
|
198
|
+
dispatcher.Dispatch(Event.GDK_READY);
|
|
184
199
|
Debug.Log($"AmaGDK v{VERSION} | {READY} in {Time.realtimeSinceStartup - startTime:#0.00}s\n\n{sb}");
|
|
185
200
|
}
|
|
186
201
|
}
|
|
@@ -200,8 +215,7 @@ namespace Amanotes.Core
|
|
|
200
215
|
|
|
201
216
|
if (onReady != null)
|
|
202
217
|
{
|
|
203
|
-
|
|
204
|
-
_onReadyCallback += onReady;
|
|
218
|
+
dispatcher.AddListener(Event.GDK_READY, onReady, true);
|
|
205
219
|
}
|
|
206
220
|
|
|
207
221
|
if (_allowInit)
|
|
@@ -211,28 +225,21 @@ namespace Amanotes.Core
|
|
|
211
225
|
}
|
|
212
226
|
|
|
213
227
|
_allowInit = true;
|
|
214
|
-
|
|
215
228
|
if (_instance != null) return;
|
|
229
|
+
|
|
216
230
|
var sdk = new GameObject("AmaGDK");
|
|
217
231
|
_instance = sdk.AddComponent<AmaGDK>();
|
|
218
232
|
}
|
|
219
233
|
|
|
220
234
|
public static void SetOnReadyCallback(Action onReady)
|
|
221
235
|
{
|
|
222
|
-
if (onReady == null)
|
|
223
|
-
{
|
|
224
|
-
LogWarning("Cannot add a null callback!");
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
236
|
if (isReady)
|
|
229
237
|
{
|
|
230
238
|
onReady.Invoke();
|
|
231
239
|
return;
|
|
232
240
|
}
|
|
233
241
|
|
|
234
|
-
|
|
235
|
-
_onReadyCallback += onReady;
|
|
242
|
+
dispatcher.AddListener(Event.GDK_READY, onReady, true);
|
|
236
243
|
}
|
|
237
244
|
|
|
238
245
|
public static void SetAdapterReadyCallback(Action<string> onAdapterReady)
|
|
@@ -242,11 +249,15 @@ namespace Amanotes.Core
|
|
|
242
249
|
LogWarning("Cannot add a null callback!");
|
|
243
250
|
return;
|
|
244
251
|
}
|
|
252
|
+
|
|
253
|
+
if (AmaGDK.isReady)
|
|
254
|
+
{
|
|
255
|
+
LogWarning("All adapters has been init / ready!");
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
245
258
|
|
|
246
|
-
|
|
247
|
-
_onAdapterReadyCallback += onAdapterReady;
|
|
259
|
+
dispatcher.AddListener(Event.ADAPTER_READY, onAdapterReady, false);
|
|
248
260
|
}
|
|
249
|
-
|
|
250
261
|
}
|
|
251
262
|
|
|
252
263
|
public partial class AmaGDK
|
|
@@ -316,7 +327,7 @@ namespace Amanotes.Core
|
|
|
316
327
|
return;
|
|
317
328
|
}
|
|
318
329
|
|
|
319
|
-
int startIndex = zshrcContent.IndexOf($"export {variableName}=");
|
|
330
|
+
int startIndex = zshrcContent.IndexOf($"export {variableName}=", StringComparison.Ordinal);
|
|
320
331
|
if (startIndex >= 0)
|
|
321
332
|
{
|
|
322
333
|
startIndex += $"export {variableName}=".Length;
|
|
@@ -366,7 +377,7 @@ namespace Amanotes.Core
|
|
|
366
377
|
#endif
|
|
367
378
|
}
|
|
368
379
|
|
|
369
|
-
public partial class AmaGDK
|
|
380
|
+
public partial class AmaGDK
|
|
370
381
|
{
|
|
371
382
|
public static class Hook
|
|
372
383
|
{
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Linq;
|
|
4
|
+
using System.Reflection;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
namespace Amanotes.Core
|
|
8
|
+
{
|
|
9
|
+
public partial class AmaGDK
|
|
10
|
+
{
|
|
11
|
+
internal static readonly Dispatcher dispatcher = new Dispatcher();
|
|
12
|
+
|
|
13
|
+
internal static void ThrowExceptionInEditor<T>(string message, Func<string, T> exceptionCreator) where T: Exception
|
|
14
|
+
{
|
|
15
|
+
#if UNITY_EDITOR
|
|
16
|
+
throw exceptionCreator(message);
|
|
17
|
+
#else
|
|
18
|
+
Debug.LogWarning(message);
|
|
19
|
+
#endif
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
[Serializable] internal class EventEntry
|
|
23
|
+
{
|
|
24
|
+
public int nParams;
|
|
25
|
+
internal bool _dispatching;
|
|
26
|
+
public Delegate callbacks;
|
|
27
|
+
public Delegate callbackOnce;
|
|
28
|
+
|
|
29
|
+
public bool hasCallback => callbacks != null || callbackOnce != null;
|
|
30
|
+
|
|
31
|
+
internal void Add(Delegate d, bool once)
|
|
32
|
+
{
|
|
33
|
+
callbackOnce = Delegate.Remove(callbackOnce, d);
|
|
34
|
+
callbacks = Delegate.Remove(callbacks, d);
|
|
35
|
+
if (once)
|
|
36
|
+
{
|
|
37
|
+
callbackOnce = Delegate.Combine(callbackOnce, d);
|
|
38
|
+
}
|
|
39
|
+
else
|
|
40
|
+
{
|
|
41
|
+
callbacks = Delegate.Combine(callbacks, d);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
internal void Remove(Delegate d)
|
|
46
|
+
{
|
|
47
|
+
callbackOnce = Delegate.Remove(callbackOnce, d);
|
|
48
|
+
callbacks = Delegate.Remove(callbacks, d);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
internal bool Dispatch(string eventName, object[] args)
|
|
54
|
+
{
|
|
55
|
+
if (_dispatching)
|
|
56
|
+
{
|
|
57
|
+
ThrowExceptionInEditor($"Nested dispatching is not supported, eventName: <{eventName}>",
|
|
58
|
+
(m) => new InvalidOperationException(m));
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (args.Length != nParams)
|
|
63
|
+
{
|
|
64
|
+
ThrowExceptionInEditor($"Dispatch <{eventName}> with incorrect number of params, expecting {nParams}, got {args.Length}!",
|
|
65
|
+
(m) => new TargetParameterCountException(m));
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_dispatching = true;
|
|
70
|
+
callbacks?.DynamicInvoke(args);
|
|
71
|
+
callbackOnce?.DynamicInvoke(args);
|
|
72
|
+
callbackOnce = null;
|
|
73
|
+
_dispatching = false;
|
|
74
|
+
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
internal class Dispatcher
|
|
80
|
+
{
|
|
81
|
+
internal readonly Dictionary<string, EventEntry> _eventMap = new Dictionary<string, EventEntry>();
|
|
82
|
+
internal void ClearAndReset()
|
|
83
|
+
{
|
|
84
|
+
_eventMap.Clear();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
internal EventEntry Get(string eventName)
|
|
88
|
+
{
|
|
89
|
+
if (string.IsNullOrEmpty(eventName)) return null;
|
|
90
|
+
_eventMap.TryGetValue(eventName, out EventEntry entry);
|
|
91
|
+
return entry;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
internal void AddListener(string eventName, Delegate d, bool once)
|
|
95
|
+
{
|
|
96
|
+
if (d == null)
|
|
97
|
+
{
|
|
98
|
+
Debug.LogWarning("Dispatcher.Add() error: d == null");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
int nParams = d.Method.GetParameters().Length;
|
|
103
|
+
EventEntry entry = Get(eventName);
|
|
104
|
+
|
|
105
|
+
if (entry == null)
|
|
106
|
+
{
|
|
107
|
+
entry = new EventEntry { nParams = nParams };
|
|
108
|
+
_eventMap.Add(eventName, entry);
|
|
109
|
+
}
|
|
110
|
+
else if (nParams != entry.nParams)
|
|
111
|
+
{
|
|
112
|
+
ThrowExceptionInEditor(string.Format(Internal.Messsage.DISPATCHER_WRONG_NUMBER_OF_PARAMS, eventName, entry.nParams, nParams),
|
|
113
|
+
(m) => new TargetParameterCountException(m));
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Debug.Log("Add: " + eventName + " --> " + d + " | " + once);
|
|
118
|
+
entry.Add(d, once);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
internal void RemoveListener(string eventName, Delegate d)
|
|
122
|
+
{
|
|
123
|
+
if (d == null)
|
|
124
|
+
{
|
|
125
|
+
Debug.LogWarning("Dispatcher.Remove() error: d == null");
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
EventEntry entry = Get(eventName);
|
|
130
|
+
entry?.Remove(d);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
internal void ClearListeners(string eventName)
|
|
134
|
+
{
|
|
135
|
+
if (_eventMap.ContainsKey(eventName)) _eventMap.Remove(eventName);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
internal void Dispatch(string eventName, params object[] data)
|
|
139
|
+
{
|
|
140
|
+
if (string.IsNullOrEmpty(eventName))
|
|
141
|
+
{
|
|
142
|
+
ThrowExceptionInEditor(
|
|
143
|
+
$"Invalid eventName: <{eventName}> (should not be null or empty)",
|
|
144
|
+
(m)=> new ArgumentException(m));
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
EventEntry entry = Get(eventName);
|
|
149
|
+
if (entry == null) return;
|
|
150
|
+
|
|
151
|
+
if (!entry.hasCallback)
|
|
152
|
+
{
|
|
153
|
+
// string[] result = _eventMap
|
|
154
|
+
// .Select(kvp => kvp.Key + ":" + kvp.Value + "\n")
|
|
155
|
+
// .ToArray();
|
|
156
|
+
//
|
|
157
|
+
// Debug.LogWarning("AmaGDK [Event] No listener of type <" + eventName + ">\n\nRegistered events:\n\n" + string.Join("", result));
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
TryCatchWrapper(() =>
|
|
162
|
+
{
|
|
163
|
+
entry.Dispatch(eventName, data);
|
|
164
|
+
}, !Application.isEditor);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
internal static void TryCatchWrapper(Action action, bool useTryCatch)
|
|
168
|
+
{
|
|
169
|
+
if (!useTryCatch)
|
|
170
|
+
{
|
|
171
|
+
action();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
try
|
|
176
|
+
{
|
|
177
|
+
action();
|
|
178
|
+
} catch (Exception e)
|
|
179
|
+
{
|
|
180
|
+
Debug.LogWarning(e);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -26,6 +26,8 @@ namespace Amanotes.Core.Internal
|
|
|
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!";
|
|
29
|
+
public const string DISPATCHER_WRONG_NUMBER_OF_PARAMS = "AddListener for eventName <{0}> expect {1} params but got {2}";
|
|
30
|
+
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
public static class Res
|
|
@@ -37,6 +39,7 @@ namespace Amanotes.Core.Internal
|
|
|
37
39
|
#endif
|
|
38
40
|
|
|
39
41
|
public const string PACKAGE_PATH = BASE_PATH + "Packages/";
|
|
42
|
+
public const string EXTRA_PATH = BASE_PATH + "Extra/";
|
|
40
43
|
public const string AMAGDK_PREFAB = BASE_PATH + "Runtime/AmaGDK.prefab";
|
|
41
44
|
public const string AMAGDK_CONFIG_PACKAGE = PACKAGE_PATH + "AmaGDKConfig.unitypackage";
|
|
42
45
|
|
|
@@ -124,6 +127,7 @@ namespace Amanotes.Core.Internal
|
|
|
124
127
|
// Reset all modules
|
|
125
128
|
Ads.context = null;
|
|
126
129
|
Ads._adapter = null;
|
|
130
|
+
dispatcher.ClearAndReset();
|
|
127
131
|
|
|
128
132
|
_status = Status.None;
|
|
129
133
|
_allowInit = false;
|
|
@@ -66,6 +66,56 @@ namespace Amanotes.Core.Internal
|
|
|
66
66
|
if (Time.realtimeSinceStartup - time > timeoutInSecs) yield break;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
public static bool IsFromTemplate(string formattedString, string template)
|
|
72
|
+
{
|
|
73
|
+
// Split the original template into segments based on the positions of placeholders
|
|
74
|
+
string[] segments = SplitTemplate(template);
|
|
75
|
+
|
|
76
|
+
// Check if each segment exists in the output string in the correct order
|
|
77
|
+
return AreSegmentsPresentInOrder(segments, formattedString);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static bool AreSegmentsPresentInOrder(string[] segments, string outputString)
|
|
81
|
+
{
|
|
82
|
+
var lastIndex = 0;
|
|
83
|
+
|
|
84
|
+
// Check if each segment exists in the output string in the correct order
|
|
85
|
+
foreach (string segment in segments)
|
|
86
|
+
{
|
|
87
|
+
int index = outputString.IndexOf(segment, lastIndex, StringComparison.Ordinal);
|
|
88
|
+
|
|
89
|
+
if (index == -1) return false;
|
|
90
|
+
lastIndex = index + segment.Length;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static string[] SplitTemplate(string template)
|
|
97
|
+
{
|
|
98
|
+
// Create a regex pattern to match placeholders like {0}, {1}, {2}, etc.
|
|
99
|
+
var pattern = @"\{(\d+)\}";
|
|
100
|
+
|
|
101
|
+
// Extract the indexes of placeholders from the original template
|
|
102
|
+
MatchCollection matches = Regex.Matches(template, pattern);
|
|
103
|
+
|
|
104
|
+
// Split the original template into segments based on the matched indexes
|
|
105
|
+
var segments = new string[matches.Count + 1];
|
|
106
|
+
var lastIndex = 0;
|
|
107
|
+
|
|
108
|
+
foreach (Match match in matches)
|
|
109
|
+
{
|
|
110
|
+
int index = int.Parse(match.Groups[1].Value);
|
|
111
|
+
segments[index] = template.Substring(lastIndex, match.Index - lastIndex);
|
|
112
|
+
lastIndex = match.Index + match.Length;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// The last segment corresponds to the content after the last placeholder
|
|
116
|
+
segments[matches.Count] = template.Substring(lastIndex);
|
|
117
|
+
return segments;
|
|
118
|
+
}
|
|
69
119
|
}
|
|
70
120
|
|
|
71
121
|
public static class GDKReflection
|
|
@@ -87,8 +137,8 @@ namespace Amanotes.Core.Internal
|
|
|
87
137
|
}
|
|
88
138
|
|
|
89
139
|
}
|
|
90
|
-
|
|
91
|
-
|
|
140
|
+
|
|
141
|
+
public static class GDKFileUtils
|
|
92
142
|
{
|
|
93
143
|
private static string _basePath;
|
|
94
144
|
private static string basePath
|
|
@@ -115,7 +165,7 @@ namespace Amanotes.Core.Internal
|
|
|
115
165
|
return File.Exists(GetPath(fileName));
|
|
116
166
|
}
|
|
117
167
|
|
|
118
|
-
|
|
168
|
+
public static void Save(string fileName, string content)
|
|
119
169
|
{
|
|
120
170
|
if (string.IsNullOrWhiteSpace(fileName))
|
|
121
171
|
{
|
|
@@ -188,7 +238,7 @@ namespace Amanotes.Core.Internal
|
|
|
188
238
|
}
|
|
189
239
|
}
|
|
190
240
|
|
|
191
|
-
|
|
241
|
+
public static string Load(string fileName)
|
|
192
242
|
{
|
|
193
243
|
var content = "";
|
|
194
244
|
|
|
@@ -247,6 +297,33 @@ namespace Amanotes.Core.Internal
|
|
|
247
297
|
}
|
|
248
298
|
Debug.Log(sb);
|
|
249
299
|
}
|
|
300
|
+
|
|
301
|
+
public static T LoadJsonFromFile<T>(T instance) where T: new()
|
|
302
|
+
{
|
|
303
|
+
instance ??= new T();
|
|
304
|
+
|
|
305
|
+
string fileName = instance.GetType().Name;
|
|
306
|
+
string json = Load(fileName);
|
|
307
|
+
if (!string.IsNullOrEmpty(json))
|
|
308
|
+
{
|
|
309
|
+
try
|
|
310
|
+
{
|
|
311
|
+
JsonUtility.FromJsonOverwrite(json, instance);
|
|
312
|
+
} catch (Exception e)
|
|
313
|
+
{
|
|
314
|
+
LogWarning("LoadJsonFromFile error: " + fileName + "\n" + e);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return instance;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
public static void SaveJsonToFile<T>(T instance)
|
|
322
|
+
{
|
|
323
|
+
string fileName = instance.GetType().Name;
|
|
324
|
+
string json = JsonUtility.ToJson(instance);
|
|
325
|
+
Save(fileName, json);
|
|
326
|
+
}
|
|
250
327
|
}
|
|
251
328
|
|
|
252
329
|
public class ActionQueue
|
|
@@ -313,34 +390,18 @@ namespace Amanotes.Core.Internal
|
|
|
313
390
|
}
|
|
314
391
|
|
|
315
392
|
internal interface IJsonFile { }
|
|
393
|
+
|
|
316
394
|
|
|
317
395
|
internal static class JsonFileExtension
|
|
318
396
|
{
|
|
319
397
|
public static T LoadJsonFromFile<T>(this T instance) where T : IJsonFile, new()
|
|
320
398
|
{
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
string fileName = instance.GetType().Name;
|
|
324
|
-
string json = GDKFileUtils.Load(fileName);
|
|
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
|
-
|
|
336
|
-
return instance;
|
|
399
|
+
return GDKFileUtils.LoadJsonFromFile(instance);
|
|
337
400
|
}
|
|
338
401
|
|
|
339
|
-
public static void SaveJsonToFile<T>(this T instance) where T
|
|
402
|
+
public static void SaveJsonToFile<T>(this T instance) where T: IJsonFile
|
|
340
403
|
{
|
|
341
|
-
|
|
342
|
-
string json = JsonUtility.ToJson(instance);
|
|
343
|
-
GDKFileUtils.Save(fileName, json);
|
|
404
|
+
GDKFileUtils.SaveJsonToFile(instance);
|
|
344
405
|
}
|
|
345
406
|
}
|
|
346
407
|
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
fileFormatVersion: 2
|
|
2
|
-
<<<<<<<< HEAD:GDK/AmaGDKCore/Runtime/Klavar/Attributes.meta
|
|
3
2
|
guid: 74f302749097e44ff889ed117ec82dd3
|
|
4
|
-
========
|
|
5
|
-
guid: 2fdae68db26424f679091198f471cf00
|
|
6
|
-
>>>>>>>> fafdc57 ([Release] 0.2.47):GDKTest/GDK-Unity2020.3/Assets/AmaGDKTest.meta
|
|
7
3
|
folderAsset: yes
|
|
8
4
|
DefaultImporter:
|
|
9
5
|
externalObjects: {}
|
package/Runtime/Klavar.meta
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
fileFormatVersion: 2
|
|
2
|
-
<<<<<<<< HEAD:GDK/AmaGDKCore/Runtime/Klavar.meta
|
|
3
2
|
guid: 5b981038cfa6f4ec2a7dd96f58fde6cd
|
|
4
|
-
========
|
|
5
|
-
guid: 74f302749097e44ff889ed117ec82dd3
|
|
6
|
-
>>>>>>>> fafdc57 ([Release] 0.2.47):GDK/AmaGDKCore/Runtime/Klavar/Attributes.meta
|
|
7
3
|
folderAsset: yes
|
|
8
4
|
DefaultImporter:
|
|
9
5
|
externalObjects: {}
|
package/package.json
CHANGED
|
Binary file
|