com.amanotes.gdk 0.2.12 → 0.2.13
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 +3 -0
- package/Editor/AmaGDKEditor.cs +21 -4
- package/Editor/AssemblyInfo.cs +5 -0
- package/Editor/AssemblyInfo.cs.meta +11 -0
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/Extra/AmaGDKProject.unitypackage +0 -0
- package/Packages/AdjustAdapter_v4.33.0.unitypackage +0 -0
- package/Packages/AmaGDKConfig.unitypackage +0 -0
- package/Packages/AmaGDKExample.unitypackage +0 -0
- package/Packages/AmaGDKTest.unitypackage +0 -0
- package/Packages/AmaPassport.ATTSupport.unitypackage +0 -0
- package/Packages/AmaPassportAdapter_v1.0.0.unitypackage +0 -0
- 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.2.6.unitypackage +0 -0
- package/Runtime/AmaGDK.Ads.cs +46 -14
- package/Runtime/AmaGDK.Analytics.cs +1 -1
- package/Runtime/AmaGDK.Internal.cs +0 -9
- package/Runtime/AmaGDK.RemoteConfig.cs +4 -4
- package/Runtime/AmaGDK.UserProfile.cs +2 -2
- package/Runtime/AmaGDK.Utils.cs +34 -6
- package/Runtime/AmaGDK.cs +50 -2
- package/Runtime/AssemblyInfo.cs +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/Editor/AmaGDKEditor.cs
CHANGED
|
@@ -3,6 +3,7 @@ using System.Text;
|
|
|
3
3
|
using Amanotes.Core;
|
|
4
4
|
using Amanotes.Core.Internal;
|
|
5
5
|
using System.Collections.Generic;
|
|
6
|
+
using System.IO;
|
|
6
7
|
using UnityEditor;
|
|
7
8
|
using UnityEngine;
|
|
8
9
|
using static Amanotes.Core.Internal.Logging;
|
|
@@ -23,6 +24,8 @@ namespace Amanotes.Editor
|
|
|
23
24
|
private static bool showConfigDetail;
|
|
24
25
|
private static bool showAdapterInstaller;
|
|
25
26
|
private static bool showExampleDetail;
|
|
27
|
+
private bool adapterScanned;
|
|
28
|
+
private readonly List<string> lstAdapter = new List<string>();
|
|
26
29
|
|
|
27
30
|
public static Color btnColor;
|
|
28
31
|
public static float btnLerp;
|
|
@@ -119,14 +122,28 @@ namespace Amanotes.Editor
|
|
|
119
122
|
EditorGUILayout.ObjectField(configAsset, configAsset.GetType(), false);
|
|
120
123
|
}
|
|
121
124
|
|
|
125
|
+
private void UpdateListAdapter()
|
|
126
|
+
{
|
|
127
|
+
if(adapterScanned)
|
|
128
|
+
return;
|
|
129
|
+
|
|
130
|
+
adapterScanned = true;
|
|
131
|
+
|
|
132
|
+
var adapterPath = Directory.GetFiles(Res.PACKAGE_PATH, "*Adapter*.unitypackage", SearchOption.AllDirectories);
|
|
133
|
+
|
|
134
|
+
for (int i = 0; i < adapterPath.Length; i++)
|
|
135
|
+
{
|
|
136
|
+
lstAdapter.Add(Path.GetFileName(adapterPath[i]));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
122
139
|
private void DrawGUI_AdapterList()
|
|
123
140
|
{
|
|
124
|
-
|
|
141
|
+
UpdateListAdapter();
|
|
142
|
+
foreach (var adapter in lstAdapter)
|
|
125
143
|
{
|
|
126
|
-
|
|
127
|
-
if (GUILayout.Button(ObjectNames.NicifyVariableName(adapterName)))
|
|
144
|
+
if (GUILayout.Button(ObjectNames.NicifyVariableName(adapter)))
|
|
128
145
|
{
|
|
129
|
-
var package = $"{Res.PACKAGE_PATH}{
|
|
146
|
+
var package = $"{Res.PACKAGE_PATH}{adapter}";
|
|
130
147
|
AssetDatabase.ImportPackage(package, false);
|
|
131
148
|
}
|
|
132
149
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/Runtime/AmaGDK.Ads.cs
CHANGED
|
@@ -85,7 +85,7 @@ namespace Amanotes.Core
|
|
|
85
85
|
public AdStat interstitial = new AdStat();
|
|
86
86
|
public AdStat reward = new AdStat();
|
|
87
87
|
|
|
88
|
-
internal int
|
|
88
|
+
internal int TimeSinceLastShow(AdType adType)
|
|
89
89
|
{
|
|
90
90
|
return (int)(Time.realtimeSinceStartup - (adType == AdType.Interstitial ? interstitial.lastSuccessTime : reward.lastSuccessTime));
|
|
91
91
|
}
|
|
@@ -138,11 +138,11 @@ namespace Amanotes.Core
|
|
|
138
138
|
_adapter?.rewardVideo.StartLoadAd();
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
public static bool
|
|
142
|
-
public static bool
|
|
143
|
-
public static bool
|
|
144
|
-
public static bool
|
|
145
|
-
|
|
141
|
+
public static bool HasInterstitial => _adapter.interstitial.hasAd;
|
|
142
|
+
public static bool HasRewardedVideo => _adapter.rewardVideo.hasAd;
|
|
143
|
+
public static bool IsBannerShowing => _isBannerShowing;
|
|
144
|
+
public static bool IsAdShowing => context != null;
|
|
145
|
+
|
|
146
146
|
private static bool ClearPrevContext()
|
|
147
147
|
{
|
|
148
148
|
if (context == null) return true;
|
|
@@ -176,6 +176,15 @@ namespace Amanotes.Core
|
|
|
176
176
|
return context;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
+
public static bool IsInterstitialShowing
|
|
180
|
+
{
|
|
181
|
+
get
|
|
182
|
+
{
|
|
183
|
+
if (context == null) return false;
|
|
184
|
+
return context.adType == AdType.Interstitial;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
179
188
|
public static IAdCallback ShowRewardedVideo(string placementName = null, Dictionary<string, object> userData = null)
|
|
180
189
|
{
|
|
181
190
|
if (!ClearPrevContext()) return null;
|
|
@@ -184,19 +193,36 @@ namespace Amanotes.Core
|
|
|
184
193
|
_adapter.rewardVideo.StartShowAd();
|
|
185
194
|
return context;
|
|
186
195
|
}
|
|
196
|
+
|
|
197
|
+
public static bool IsRewardedVideoShowing
|
|
198
|
+
{
|
|
199
|
+
get
|
|
200
|
+
{
|
|
201
|
+
if (context == null) return false;
|
|
202
|
+
return context.adType == AdType.VideoReward;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
187
205
|
|
|
188
|
-
private static bool
|
|
189
|
-
public static void ShowBanner()
|
|
206
|
+
private static bool _isBannerShowing;
|
|
207
|
+
public static void ShowBanner(BannerPosition? bannerPosition = null)
|
|
190
208
|
{
|
|
191
|
-
if (
|
|
192
|
-
|
|
193
|
-
|
|
209
|
+
if (_isBannerShowing) return;
|
|
210
|
+
_isBannerShowing = true;
|
|
211
|
+
|
|
212
|
+
if (bannerPosition.HasValue)
|
|
213
|
+
{
|
|
214
|
+
_adapter.ShowBanner(bannerPosition.Value);
|
|
215
|
+
}
|
|
216
|
+
else
|
|
217
|
+
{
|
|
218
|
+
_adapter.ShowBanner(_adConfig.bannerPosition);
|
|
219
|
+
}
|
|
194
220
|
}
|
|
195
221
|
|
|
196
222
|
public static void HideBanner()
|
|
197
223
|
{
|
|
198
|
-
if (!
|
|
199
|
-
|
|
224
|
+
if (!_isBannerShowing) return;
|
|
225
|
+
_isBannerShowing = false;
|
|
200
226
|
_adapter.HideBanner();
|
|
201
227
|
}
|
|
202
228
|
|
|
@@ -210,6 +236,12 @@ namespace Amanotes.Core
|
|
|
210
236
|
else
|
|
211
237
|
_adapter.rewardVideo.StopShowAd();
|
|
212
238
|
}
|
|
239
|
+
|
|
240
|
+
public static int TimeSinceLastInterstitial => localData.TimeSinceLastShow(AdType.Interstitial);
|
|
241
|
+
|
|
242
|
+
public static int TimeSinceLastVideoReward => localData.TimeSinceLastShow(AdType.VideoReward);
|
|
243
|
+
|
|
244
|
+
public static int TimeSinceLastAd => Math.Min(TimeSinceLastInterstitial, TimeSinceLastVideoReward) ;
|
|
213
245
|
}
|
|
214
246
|
}
|
|
215
247
|
}
|
|
@@ -287,7 +319,7 @@ namespace Amanotes.Core.Internal
|
|
|
287
319
|
// Stats
|
|
288
320
|
public float showCallAt;
|
|
289
321
|
public float showFinishAt;
|
|
290
|
-
|
|
322
|
+
|
|
291
323
|
public ShowAdContext(AdType adType, string placementName, Dictionary<string, object> userData)
|
|
292
324
|
{
|
|
293
325
|
this.adType = adType;
|
|
@@ -40,15 +40,6 @@ namespace Amanotes.Core.Internal
|
|
|
40
40
|
public const string AMAGDK_PREFAB = BASE_PATH + "Runtime/AmaGDK.prefab";
|
|
41
41
|
public const string AMAGDK_CONFIG_PACKAGE = PACKAGE_PATH + "AmaGDKConfig.unitypackage";
|
|
42
42
|
|
|
43
|
-
public static readonly string[] AMAGDK_ADAPTERS =
|
|
44
|
-
{
|
|
45
|
-
"FirebaseAnalyticsAdapter_v9.1.0",
|
|
46
|
-
"AppsFlyerAdapter_v6.5.4",
|
|
47
|
-
"AdjustAdapter_v4.33.0",
|
|
48
|
-
"IronsourceAdapter_v7.2.6",
|
|
49
|
-
"FirebaseRemoteConfigAdapter_v9.1.0"
|
|
50
|
-
};
|
|
51
|
-
|
|
52
43
|
#if UNITY_EDITOR
|
|
53
44
|
|
|
54
45
|
[MenuItem("GameObject/AmaGDK/Add AmaGDK Prefab", false, 10)]
|
|
@@ -34,7 +34,7 @@ namespace Amanotes.Core
|
|
|
34
34
|
get
|
|
35
35
|
{
|
|
36
36
|
if (_cacheExisted == null)
|
|
37
|
-
_cacheExisted =
|
|
37
|
+
_cacheExisted = GDKFileUtils.Exist(fileName);
|
|
38
38
|
return _cacheExisted.GetValueOrDefault();
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -199,8 +199,8 @@ namespace Amanotes.Core
|
|
|
199
199
|
}
|
|
200
200
|
#endif
|
|
201
201
|
|
|
202
|
-
string filePath =
|
|
203
|
-
|
|
202
|
+
string filePath = GDKFileUtils.GetPath(fileName);
|
|
203
|
+
GDKFileUtils.Save(filePath, sb.ToString());
|
|
204
204
|
Log($"[RemoteConfig] Saved remote config to {filePath}");
|
|
205
205
|
NextState();
|
|
206
206
|
}
|
|
@@ -218,7 +218,7 @@ namespace Amanotes.Core
|
|
|
218
218
|
try
|
|
219
219
|
{
|
|
220
220
|
dictConfig.Clear();
|
|
221
|
-
using (StreamReader sr = new StreamReader(
|
|
221
|
+
using (StreamReader sr = new StreamReader(GDKFileUtils.GetPath(fileName)))
|
|
222
222
|
{
|
|
223
223
|
string line;
|
|
224
224
|
int lineIdx = 0;
|
|
@@ -15,12 +15,12 @@ namespace Amanotes.Core
|
|
|
15
15
|
|
|
16
16
|
public void Save()
|
|
17
17
|
{
|
|
18
|
-
|
|
18
|
+
GDKFileUtils.Save(FILE_NAME, JsonUtility.ToJson(this));
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
public UserProfile Load()
|
|
22
22
|
{
|
|
23
|
-
string json =
|
|
23
|
+
string json = GDKFileUtils.Load(FILE_NAME);
|
|
24
24
|
if (string.IsNullOrEmpty(json)) return this;
|
|
25
25
|
JsonUtility.FromJsonOverwrite(json, this);
|
|
26
26
|
return this;
|
package/Runtime/AmaGDK.Utils.cs
CHANGED
|
@@ -3,12 +3,13 @@ using System.Collections;
|
|
|
3
3
|
using System.Collections.Generic;
|
|
4
4
|
using System.IO;
|
|
5
5
|
using System.Text;
|
|
6
|
+
using System.Text.RegularExpressions;
|
|
6
7
|
using UnityEngine;
|
|
7
8
|
using static Amanotes.Core.Internal.Logging;
|
|
8
9
|
|
|
9
10
|
namespace Amanotes.Core.Internal
|
|
10
11
|
{
|
|
11
|
-
public class
|
|
12
|
+
public class GDKUtils
|
|
12
13
|
{
|
|
13
14
|
public static void DelayCall(float seconds, Action action)
|
|
14
15
|
{
|
|
@@ -22,7 +23,7 @@ namespace Amanotes.Core.Internal
|
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
internal class
|
|
26
|
+
internal class GDKFileUtils
|
|
26
27
|
{
|
|
27
28
|
|
|
28
29
|
private static string _basePath;
|
|
@@ -39,6 +40,7 @@ namespace Amanotes.Core.Internal
|
|
|
39
40
|
return _basePath;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
43
|
+
|
|
42
44
|
internal static string GetPath(string fileName)
|
|
43
45
|
{
|
|
44
46
|
return Path.Combine(basePath, fileName);
|
|
@@ -161,6 +163,26 @@ namespace Amanotes.Core.Internal
|
|
|
161
163
|
LogWarningOnce(path + "\n" + ex);
|
|
162
164
|
}
|
|
163
165
|
}
|
|
166
|
+
|
|
167
|
+
internal static void ClearCacheData()
|
|
168
|
+
{
|
|
169
|
+
StringBuilder logBuilder = new StringBuilder();
|
|
170
|
+
logBuilder.AppendLine("[AmaGDK] All cached data & stats cleared");
|
|
171
|
+
|
|
172
|
+
if (!Directory.Exists(_basePath))
|
|
173
|
+
{
|
|
174
|
+
logBuilder.AppendLine("Cache path not exists: " + _basePath);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
string[] filePaths = Directory.GetFiles(_basePath);
|
|
179
|
+
foreach (string path in filePaths)
|
|
180
|
+
{
|
|
181
|
+
Delete(path);
|
|
182
|
+
logBuilder.AppendLine($"[deleted] - {path}");
|
|
183
|
+
}
|
|
184
|
+
Debug.Log(logBuilder);
|
|
185
|
+
}
|
|
164
186
|
}
|
|
165
187
|
|
|
166
188
|
public class ActionQueue
|
|
@@ -238,7 +260,7 @@ namespace Amanotes.Core.Internal
|
|
|
238
260
|
instance = result;
|
|
239
261
|
}
|
|
240
262
|
string fileName = instance.GetType().Name;
|
|
241
|
-
string json =
|
|
263
|
+
string json = GDKFileUtils.Load(fileName);
|
|
242
264
|
JsonUtility.FromJsonOverwrite(json, instance);
|
|
243
265
|
return instance;
|
|
244
266
|
}
|
|
@@ -247,7 +269,7 @@ namespace Amanotes.Core.Internal
|
|
|
247
269
|
{
|
|
248
270
|
string fileName = instance.GetType().Name;
|
|
249
271
|
string json = JsonUtility.ToJson(instance);
|
|
250
|
-
|
|
272
|
+
GDKFileUtils.Save(fileName, json);
|
|
251
273
|
}
|
|
252
274
|
}
|
|
253
275
|
|
|
@@ -342,8 +364,7 @@ namespace Amanotes.Core.Internal
|
|
|
342
364
|
return;
|
|
343
365
|
}
|
|
344
366
|
}
|
|
345
|
-
|
|
346
|
-
jsonSb.Append($"\"{value}\"");
|
|
367
|
+
jsonSb.Append($"\"{EscapeJsonString(s)}\"");
|
|
347
368
|
return;
|
|
348
369
|
}
|
|
349
370
|
|
|
@@ -374,6 +395,13 @@ namespace Amanotes.Core.Internal
|
|
|
374
395
|
jsonSb.Append($"{JsonUtility.ToJson(value, format)}");
|
|
375
396
|
}
|
|
376
397
|
|
|
398
|
+
private static string EscapeJsonString(string input)
|
|
399
|
+
{
|
|
400
|
+
//Match any occurrence of a backslash(\), single quotation('), or double quotation (")
|
|
401
|
+
string pattern = "[\\\'\"]";
|
|
402
|
+
return Regex.Replace(input, pattern, match => $"\\{match.Value}");
|
|
403
|
+
}
|
|
404
|
+
|
|
377
405
|
//public static T[] FromJsonToArray<T>(string json)
|
|
378
406
|
//{
|
|
379
407
|
// if (!json.StartsWith("{\"items\":"))
|
package/Runtime/AmaGDK.cs
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
using System;
|
|
2
2
|
using System.Collections;
|
|
3
|
+
using System.Diagnostics;
|
|
4
|
+
using System.IO;
|
|
3
5
|
using System.Text;
|
|
6
|
+
using System.Text.RegularExpressions;
|
|
4
7
|
using Amanotes.Core.Internal;
|
|
5
8
|
using UnityEngine;
|
|
6
9
|
using static Amanotes.Core.Internal.Logging;
|
|
7
10
|
using static Amanotes.Core.Internal.Messsage;
|
|
11
|
+
using Debug = System.Diagnostics.Debug;
|
|
8
12
|
|
|
9
13
|
namespace Amanotes.Core
|
|
10
14
|
{
|
|
11
15
|
public partial class AmaGDK : MonoBehaviour
|
|
12
16
|
{
|
|
13
|
-
public const string VERSION = "0.2.
|
|
17
|
+
public const string VERSION = "0.2.13";
|
|
14
18
|
|
|
15
19
|
internal static AmaGDK _instance;
|
|
16
20
|
internal static Status _status = Status.None;
|
|
@@ -109,7 +113,7 @@ namespace Amanotes.Core
|
|
|
109
113
|
_status = Status.Ready;
|
|
110
114
|
_onReadyCallback?.Invoke();
|
|
111
115
|
_onReadyCallback = null;
|
|
112
|
-
|
|
116
|
+
Log($"AmaGDK v{VERSION} | {READY} in {Time.realtimeSinceStartup - startTime}s\n\n{adapterInfo.ToString()}");
|
|
113
117
|
}
|
|
114
118
|
|
|
115
119
|
void RegisterUnityCallback(AdapterContext adapter)
|
|
@@ -231,4 +235,48 @@ namespace Amanotes.Core
|
|
|
231
235
|
applicationQuit?.Invoke();
|
|
232
236
|
}
|
|
233
237
|
}
|
|
238
|
+
|
|
239
|
+
public partial class AmaGDK // Switch dev mode
|
|
240
|
+
{
|
|
241
|
+
[ContextMenu("Change Dev Mode")]
|
|
242
|
+
public void ChangeDevMode()
|
|
243
|
+
{
|
|
244
|
+
string variableName = "GDK_HOME";
|
|
245
|
+
string output = RunShellCommand($"source ~/.zshrc && echo ${variableName}");
|
|
246
|
+
output = output.Trim();
|
|
247
|
+
|
|
248
|
+
if (string.IsNullOrEmpty(output))
|
|
249
|
+
{
|
|
250
|
+
LogWarning($"{variableName} environment variable is not set.");
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
UpdateManifest(output);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
private string RunShellCommand(string command)
|
|
258
|
+
{
|
|
259
|
+
Process process = new Process();
|
|
260
|
+
process.StartInfo.FileName = "/bin/zsh";
|
|
261
|
+
process.StartInfo.Arguments = $"-c \"{command}\"";
|
|
262
|
+
process.StartInfo.RedirectStandardOutput = true;
|
|
263
|
+
process.StartInfo.UseShellExecute = false;
|
|
264
|
+
process.StartInfo.CreateNoWindow = true;
|
|
265
|
+
process.Start();
|
|
266
|
+
|
|
267
|
+
string output = process.StandardOutput.ReadToEnd();
|
|
268
|
+
process.WaitForExit();
|
|
269
|
+
|
|
270
|
+
return output;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
private void UpdateManifest(string strDesired)
|
|
274
|
+
{
|
|
275
|
+
const string manifestPath = "Packages/manifest.json";
|
|
276
|
+
string manifestJson = File.ReadAllText(manifestPath);
|
|
277
|
+
|
|
278
|
+
manifestJson = Regex.Replace(manifestJson, "\"com\\.amanotes\\.gdk\"\\s*:\\s*\"\\d+\\.\\d+\\.\\d+\"", $"\"com.amanotes.gdk\": \"{strDesired}\"");
|
|
279
|
+
File.WriteAllText(manifestPath, manifestJson);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
234
282
|
}
|
package/Runtime/AssemblyInfo.cs
CHANGED