com.amanotes.gdk 0.2.68 → 0.2.70-1

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 (55) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/Editor/AmaGDKEditor.cs +78 -23
  3. package/Editor/AmaGDKExtra.cs +14 -13
  4. package/Editor/Extra/GDKAutoUpdateAdapter.cs +14 -1
  5. package/Editor/Extra/GDKCIBuildCommand.cs +2 -16
  6. package/Editor/Extra/GDKSymbolDefine.cs +372 -0
  7. package/Editor/{AmaGDKManager.cs.meta → Extra/GDKSymbolDefine.cs.meta} +1 -1
  8. package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs +41 -3
  9. package/Extra/AmaGDKInstaller.unitypackage +0 -0
  10. package/Extra/CheckDiskSpace.unitypackage +0 -0
  11. package/Extra/Consent.unitypackage +0 -0
  12. package/Extra/{GoogleCMP.unitypackage.meta → Consent.unitypackage.meta} +1 -1
  13. package/Extra/ForceUpdate.unitypackage +0 -0
  14. package/Extra/LegacyGDKUpdateHelper.unitypackage +0 -0
  15. package/Extra/PostProcessor.unitypackage +0 -0
  16. package/Packages/AmaGDKConfig.unitypackage +0 -0
  17. package/Packages/AmaGDKExample.unitypackage +0 -0
  18. package/Packages/AmaGDKTest.unitypackage +0 -0
  19. package/Packages/AppsFlyerAdapter.PurchaseConnector.unitypackage +0 -0
  20. package/Packages/AppsFlyerAdapter.unitypackage +0 -0
  21. package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
  22. package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
  23. package/Packages/IronSourceAdapter.unitypackage +0 -0
  24. package/Packages/MaxAdNetworkAdapter.unitypackage +0 -0
  25. package/{Editor/Resources.meta → Packages/MaxAdNetworkAdapter.unitypackage.meta} +1 -2
  26. package/Packages/RevenueCatAdapter.unitypackage +0 -0
  27. package/Packages/SqliteAnalyticsAdapter.unitypackage +0 -0
  28. package/Runtime/Ad/AdExtension.cs +2 -0
  29. package/Runtime/Ad/AdLogic.cs +83 -70
  30. package/Runtime/Ad/AdShowContext.cs +1 -0
  31. package/Runtime/Ad/AmaGDK.Ads.cs +17 -3
  32. package/Runtime/AmaGDK.Adapters.cs +12 -5
  33. package/Runtime/AmaGDK.Analytics.cs +45 -38
  34. package/Runtime/AmaGDK.Consent.cs +259 -0
  35. package/Runtime/AmaGDK.Consent.cs.meta +11 -0
  36. package/Runtime/AmaGDK.Device.cs +4 -4
  37. package/Runtime/AmaGDK.RemoteConfig.cs +3 -1
  38. package/Runtime/AmaGDK.cs +28 -19
  39. package/Runtime/AnalyticQualityAsset.cs +16 -9
  40. package/Runtime/AudioToolkit/AmaGDK.Audio.Latency.cs +1 -3
  41. package/Runtime/AudioToolkit/AmaGDK.Audio.cs +41 -25
  42. package/Runtime/AudioToolkit/Plugins/AudioDeviceDetector.cs +13 -12
  43. package/Runtime/Core/GDKPool.cs +83 -17
  44. package/Runtime/Fps/AmaFPS.cs +0 -1
  45. package/Runtime/Fps/AmaFPSVisualizer.cs +7 -7
  46. package/Runtime/Internal/AmaGDK.Internal.AmaGUI.cs +1 -1
  47. package/Runtime/Internal/AmaGDK.Internal.cs +2 -5
  48. package/Runtime/Internal/AmaGDK.Utils.cs +32 -81
  49. package/Runtime/Internal/GDKGeoLocationcs.cs +3 -1
  50. package/Runtime/Internal/GDKServerTime.cs +13 -10
  51. package/package.json +1 -1
  52. package/Editor/AmaGDKManager.cs +0 -235
  53. package/Editor/Resources/amasdk-modules.json +0 -31
  54. package/Editor/Resources/amasdk-modules.json.meta +0 -7
  55. package/Extra/GoogleCMP.unitypackage +0 -0
@@ -0,0 +1,372 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.IO;
4
+ using System.Linq;
5
+ using UnityEngine;
6
+ using UnityEditor;
7
+ using UnityEngine.Serialization;
8
+ using UnityObject = UnityEngine.Object;
9
+
10
+ namespace Amanotes.Core
11
+ {
12
+ [CreateAssetMenu(fileName = "GDKSymbolDefine", menuName = "Ama GDK/GDK Symbol Define", order = 100)]
13
+ internal partial class GDKSymbolDefine : ScriptableObject
14
+ {
15
+ private static readonly string cscRspFilePath = "Assets/csc.rsp";
16
+ public List<SymbolInfo> symbols = new List<SymbolInfo>();
17
+ public LoggerConfig loggerConfig = new LoggerConfig();
18
+
19
+
20
+ [ContextMenu("Read")]
21
+ public void Read()
22
+ {
23
+ if (!File.Exists(cscRspFilePath)) return;
24
+
25
+ var enabledSymbols = new HashSet<string>(ReadCSC());
26
+ AddSymbol(enabledSymbols, true);
27
+ SetEnableSymbols(enabledSymbols, true);
28
+ }
29
+
30
+ private void Write()
31
+ {
32
+ var list = symbols
33
+ .Union(this.loggerConfig.tags)
34
+ .Where(item=>item.enabled)
35
+ .Select(item => item.name)
36
+ .Distinct()
37
+ .ToArray();
38
+
39
+ string content = list.Length > 0 ? $"-define:{string.Join(";", list)}" : string.Empty;
40
+ File.WriteAllText(cscRspFilePath, content);
41
+ AssetDatabase.Refresh();
42
+ }
43
+
44
+ [ContextMenu("Apply")]
45
+ public void Apply()
46
+ {
47
+ Write();
48
+ loggerConfig.GenerateLogger();
49
+
50
+ #if UNITY_EDITOR
51
+ EditorUtility.SetDirty((this));
52
+ AssetDatabase.Refresh();
53
+ #endif
54
+ }
55
+
56
+ private void SetEnableSymbols(HashSet<string> enabledSymbols, bool enabled)
57
+ {
58
+ for (var i = 0; i < symbols.Count; i++)
59
+ {
60
+ symbols[i].enabled = enabledSymbols.Contains(symbols[i].name);
61
+ }
62
+
63
+ for (var i = 0; i < loggerConfig.tags.Count; i++)
64
+ {
65
+ loggerConfig.tags[i].enabled = enabledSymbols.Contains(loggerConfig.tags[i].name);
66
+ }
67
+ }
68
+
69
+ private void AddSymbol(IEnumerable<string> newSymbols, bool enabled)
70
+ {
71
+ var dict = symbols
72
+ .Union(loggerConfig.tags)
73
+ .Distinct()
74
+ .ToDictionary(item => item.name);
75
+
76
+ foreach (string symbol in newSymbols)
77
+ {
78
+ if (dict.TryGetValue(symbol, out var info)) continue;
79
+ info = new SymbolInfo() { name = symbol, enabled = enabled };
80
+ symbols.Add(info);
81
+ }
82
+
83
+ #if UNITY_EDITOR
84
+ EditorUtility.SetDirty(this);
85
+ #endif
86
+ }
87
+
88
+ private List<string> ReadCSC()
89
+ {
90
+ var result = new List<string>();
91
+ if (!File.Exists(cscRspFilePath)) return result;
92
+ string[] rspLines = File.ReadAllLines(cscRspFilePath);
93
+
94
+ foreach (string line in rspLines)
95
+ {
96
+ string line2 = line.Trim();
97
+ if (!line2.StartsWith("-define:")) continue;
98
+
99
+ // Extract existing symbols from -define:
100
+ result.AddRange(line2.Substring(8).Split(';'));
101
+ }
102
+
103
+ return result;
104
+ }
105
+ }
106
+
107
+ internal partial class GDKSymbolDefine
108
+ {
109
+ [Serializable] internal class SymbolInfo
110
+ {
111
+ [FormerlySerializedAs("symbol")] public string name;
112
+ public bool enabled;
113
+ }
114
+
115
+ [Serializable] internal class LoggerConfig
116
+ {
117
+ public bool enabled;
118
+ public bool forceCleanUp;
119
+ public UnityObject codeGenerateFolder;
120
+ public string codeGeneratePath
121
+ {
122
+ get
123
+ {
124
+ string path = AssetDatabase.GetAssetPath(codeGenerateFolder);
125
+ if (AssetDatabase.IsValidFolder(path)) return path;
126
+
127
+ var defaultPath = "Assets/AmaGDK/LogV2";
128
+ var asset = AssetDatabase.LoadAssetAtPath<UnityObject>(defaultPath);
129
+ if (asset != null) codeGenerateFolder = asset;
130
+ return defaultPath;
131
+ }
132
+ }
133
+ public string className = "LogV2";
134
+
135
+ [HideInInspector][SerializeField] private string classTemplate = $@"using Debug = UnityEngine.Debug;
136
+ using UnityObject = UnityEngine.Object;
137
+
138
+ public partial class $$CLASS_NAME$$
139
+ {{
140
+ private static void Log(string tag, string message, UnityObject context)
141
+ {{
142
+ Debug.Log($""[{{tag}}] {{message}}"", context);
143
+ }}
144
+
145
+ private static void LogWarning(string tag, string message, UnityObject context)
146
+ {{
147
+ Debug.LogWarning($""[{{tag}}] {{message}}"", context);
148
+ }}
149
+
150
+ private static void LogError(string tag, string message, UnityObject context)
151
+ {{
152
+ Debug.LogError($""[{{tag}}] {{message}}"", context);
153
+ }}
154
+ }}";
155
+
156
+ public List<SymbolInfo> tags = new List<SymbolInfo>();
157
+
158
+ public void GenerateLogger()
159
+ {
160
+ if (!enabled) return;
161
+
162
+ bool hasFolder = Directory.Exists(codeGeneratePath);
163
+ if (hasFolder)
164
+ {
165
+ if (forceCleanUp)
166
+ {
167
+ Directory.Delete(codeGeneratePath, true);
168
+ hasFolder = false;
169
+ }
170
+ }
171
+
172
+ if (!hasFolder) Directory.CreateDirectory(codeGeneratePath);
173
+
174
+ // Generate main logger class
175
+ string filePath = Path.Combine(codeGeneratePath, $"{className}.cs");
176
+ string classContent;
177
+
178
+ if (!File.Exists(filePath))
179
+ {
180
+ classContent = classTemplate.Replace("$$CLASS_NAME$$", className);
181
+ File.WriteAllText(filePath, classContent);
182
+ AssetDatabase.ImportAsset(filePath);
183
+ }
184
+
185
+ // Generate derived logger classes
186
+ for (var i = 0; i < tags.Count; i++)
187
+ {
188
+ string tag = tags[i].name;
189
+ classContent = GenerateTagClassContent(tag);
190
+ filePath = Path.Combine(codeGeneratePath, $"{className}.{tag}.cs");
191
+ File.WriteAllText(filePath, classContent);
192
+ AssetDatabase.ImportAsset(filePath);
193
+ }
194
+ }
195
+
196
+ private string GenerateTagClassContent(string tag)
197
+ {
198
+ return $@"using System.Diagnostics;
199
+ using UnityObject = UnityEngine.Object;
200
+
201
+ public partial class {className}
202
+ {{
203
+ public static class {tag}
204
+ {{
205
+ [Conditional(nameof({tag}))]
206
+ public static void Log(string message, UnityObject context = null) => {className}.Log(nameof({tag}), message, context);
207
+
208
+ [Conditional(nameof({tag}))]
209
+ public static void LogWarning(string message, UnityObject context = null) => {className}.LogWarning(nameof({tag}),message, context);
210
+
211
+ [Conditional(nameof({tag}))]
212
+ public static void LogError(string message, UnityObject context = null) => {className}.LogError(nameof({tag}), message, context);
213
+ }}
214
+ }}";
215
+ }
216
+ }
217
+ }
218
+
219
+
220
+ // INSPECTOR
221
+
222
+ [CustomPropertyDrawer(typeof(GDKSymbolDefine.SymbolInfo))]
223
+ internal class SymbolInfoDrawer : PropertyDrawer
224
+ {
225
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
226
+ {
227
+ // Begin property drawing
228
+ EditorGUI.BeginProperty(position, label, property);
229
+
230
+ // Calculate rects
231
+ var toggleRect = new Rect(position.x, position.y, 20, position.height);
232
+ var labelRect = new Rect(position.x + 25, position.y, position.width - 25, position.height);
233
+
234
+ // Draw fields
235
+ SerializedProperty symbolProperty = property.FindPropertyRelative("name");
236
+ SerializedProperty enabledProperty = property.FindPropertyRelative("enabled");
237
+
238
+ // Draw the enabled toggle
239
+ enabledProperty.boolValue = EditorGUI.Toggle(toggleRect, enabledProperty.boolValue);
240
+
241
+ // Draw the symbol name field
242
+ symbolProperty.stringValue = EditorGUI.TextField(labelRect, symbolProperty.stringValue, EditorStyles.label);
243
+
244
+ // End property drawing
245
+ EditorGUI.EndProperty();
246
+ }
247
+ }
248
+
249
+ [CustomEditor(typeof(GDKSymbolDefine))]
250
+ public class GDKSymbolDefineEditor : UnityEditor.Editor
251
+ {
252
+ private SerializedProperty symbolsProp;
253
+ private SerializedProperty loggerConfigProp;
254
+ private int selectedTab = 0;
255
+ private GDKSymbolDefine define;
256
+
257
+
258
+ private readonly GUIContent[] tabTitles = new GUIContent[]
259
+ {
260
+ new GUIContent("Symbols"),
261
+ new GUIContent("Logger Config")
262
+ };
263
+
264
+ private void OnEnable()
265
+ {
266
+ define = (GDKSymbolDefine)target;
267
+ symbolsProp = serializedObject.FindProperty("symbols");
268
+ loggerConfigProp = serializedObject.FindProperty("loggerConfig");
269
+ }
270
+
271
+ public override void OnInspectorGUI()
272
+ {
273
+ if (Application.isPlaying || EditorApplication.isPlayingOrWillChangePlaymode)
274
+ {
275
+ EditorGUILayout.HelpBox("Disabled in play mode!", MessageType.Info);
276
+ Repaint();
277
+ return;
278
+ }
279
+
280
+ if (EditorApplication.isUpdating)
281
+ {
282
+ EditorGUILayout.HelpBox("Please wait for Unity Editor to finish importing!", MessageType.Info);
283
+ Repaint();
284
+ return;
285
+ }
286
+
287
+ if (EditorApplication.isCompiling)
288
+ {
289
+ EditorGUILayout.HelpBox("Please wait for Unity Editor to finish compiling!", MessageType.Info);
290
+ Repaint();
291
+ return;
292
+ }
293
+
294
+ if (define == null) return;
295
+
296
+ serializedObject.Update();
297
+ selectedTab = GUILayout.Toolbar(selectedTab, tabTitles, GUILayout.Height(32f));
298
+
299
+ switch (selectedTab)
300
+ {
301
+ case 0:
302
+ DrawSymbolsTab();
303
+ break;
304
+ case 1:
305
+ DrawLoggerConfigTab();
306
+ break;
307
+ default:
308
+ DrawSymbolsTab();
309
+ break;
310
+ }
311
+
312
+ GUILayout.Space(24f);
313
+ if (GUILayout.Button("Apply", GUILayout.Height(30f)))
314
+ {
315
+ define.Apply();
316
+ Repaint();
317
+ }
318
+
319
+ serializedObject.ApplyModifiedProperties();
320
+ }
321
+
322
+ private void DrawSymbolsTab()
323
+ {
324
+ EditorGUILayout.PropertyField(symbolsProp, new GUIContent("DEFINE SYMBOLS"), true);
325
+ if (define.loggerConfig.enabled)
326
+ {
327
+ EditorGUILayout.PropertyField(loggerConfigProp.FindPropertyRelative("tags"), new GUIContent("LOGGER TAGS"), true);
328
+ }
329
+ }
330
+
331
+ private static bool showTemplate = false;
332
+ private void DrawLoggerConfigTab()
333
+ {
334
+ // EditorGUILayout.PropertyField(loggerConfigProp, GUIContent.none, true);
335
+ DrawProperty(serializedObject, "loggerConfig", true);
336
+ showTemplate = GUILayout.Toggle(showTemplate, "Logger class template", EditorStyles.foldout);
337
+ if (showTemplate)
338
+ {
339
+ var prop = serializedObject
340
+ .FindProperty("loggerConfig")
341
+ .FindPropertyRelative("classTemplate");
342
+ EditorGUILayout.PropertyField(prop, GUIContent.none, false, GUILayout.Height(16 * 20));
343
+ }
344
+ }
345
+
346
+ private static void DrawProperty(SerializedObject so, string propertyField, bool childrenOnly)
347
+ {
348
+ SerializedProperty property = so.FindProperty(propertyField);
349
+ if (property == null)
350
+ {
351
+ EditorGUILayout.HelpBox($"Property not found <{propertyField}>!", MessageType.Warning);
352
+ return;
353
+ }
354
+
355
+ if (!childrenOnly)
356
+ {
357
+ EditorGUILayout.PropertyField(property);
358
+ }
359
+
360
+ string basePath = property.propertyPath;
361
+ var first = true;
362
+ while (property.NextVisible(first))
363
+ {
364
+ first = false;
365
+ if (!property.propertyPath.Contains(basePath)) break;
366
+ EditorGUILayout.PropertyField(property);
367
+ }
368
+
369
+ so.ApplyModifiedProperties();
370
+ }
371
+ }
372
+ }
@@ -1,5 +1,5 @@
1
1
  fileFormatVersion: 2
2
- guid: 44c77ba58d5d742d68829b3d5b04a3bf
2
+ guid: ac69671f3a58f434a83023380f963e8b
3
3
  MonoImporter:
4
4
  externalObjects: {}
5
5
  serializedVersion: 2
@@ -5,11 +5,14 @@ using System.Linq;
5
5
  using System.Reflection;
6
6
  using System.Xml;
7
7
  using Amanotes.Core.Internal;
8
+ using System.Text.RegularExpressions;
9
+
8
10
  #if !UNITY_2021_1_OR_NEWER
9
- using UnityEditor;
10
11
  using UnityEditor.PackageManager;
11
12
  using UnityEditor.PackageManager.Requests;
12
13
  #endif
14
+
15
+ using UnityEditor;
13
16
  using UnityEngine;
14
17
  using static Amanotes.Core.AmaGDK.AdapterID;
15
18
 
@@ -179,8 +182,10 @@ namespace Amanotes.Editor
179
182
  case FIREBASE_ANALYTICS: return FirebaseAnalytics();
180
183
  case FIREBASE_REMOTE_CONFIG: return FirebaseRemoteConfig();
181
184
  case APPSFLYER: return AppsFlyer();
182
- case IRONSOURCE: return Ironsource();
185
+ case IRONSOURCE: return IronSource();
186
+ case MAX: return Max();
183
187
  case REVENUECAT: return RevenueCat();
188
+ case SQLITE_ANALYTICS: return SqliteAnalytics();
184
189
  default:
185
190
  Debug.LogWarning($"Unsupported sdkID <{sdkId}>");
186
191
  break;
@@ -261,7 +266,35 @@ namespace Amanotes.Editor
261
266
  return version.Trim();
262
267
  }
263
268
 
264
- internal static string Ironsource()
269
+ internal static string Max()
270
+ {
271
+ string[] guids = AssetDatabase.FindAssets("t:monoscript MaxSdk");
272
+ if (guids.Length == 0) return string.Empty;
273
+
274
+ foreach (string guid in guids)
275
+ {
276
+ string path = AssetDatabase.GUIDToAssetPath(guid);
277
+ if (!path.EndsWith("MaxSdk.cs")) continue;
278
+
279
+ try
280
+ {
281
+ string fileContent = File.ReadAllText(path);
282
+ const string pattern = @"private const string _version = ""(?<version>[\d\.]+)"";";
283
+ var regex = new Regex(pattern);
284
+ Match match = regex.Match(fileContent);
285
+ return match.Success ? match.Groups["version"].Value : string.Empty;
286
+ }
287
+ catch (IOException ex)
288
+ {
289
+ Debug.LogWarning($"Can not get Max Version : {ex}");
290
+ return string.Empty;
291
+ }
292
+ }
293
+
294
+ return string.Empty;
295
+ }
296
+
297
+ internal static string IronSource()
265
298
  {
266
299
  var version = "";
267
300
  string[] issdk = Directory.GetFiles("Assets", "IronSourceSDKDependencies.xml", SearchOption.AllDirectories);
@@ -297,6 +330,11 @@ namespace Amanotes.Editor
297
330
  return version?.Trim();
298
331
  }
299
332
 
333
+ internal static string SqliteAnalytics()
334
+ {
335
+ return "1.0.0";
336
+ }
337
+
300
338
  internal static string RevenueCat()
301
339
  {
302
340
  string[] files = Directory.GetFiles("Assets", "PurchasesWrapper.java", SearchOption.AllDirectories);
Binary file
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  fileFormatVersion: 2
2
- guid: 4e220bd58ce0646bcbbb209dc8451d25
2
+ guid: c76a726b63046449ab0d11191aa3980b
3
3
  DefaultImporter:
4
4
  externalObjects: {}
5
5
  userData:
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,6 +1,5 @@
1
1
  fileFormatVersion: 2
2
- guid: aa56aa5c6656f415ebac7089cf7cf7dc
3
- folderAsset: yes
2
+ guid: 4d9f3e2a9be574df390eff5ef9f11fa9
4
3
  DefaultImporter:
5
4
  externalObjects: {}
6
5
  userData:
@@ -76,10 +76,12 @@ namespace Amanotes.Core
76
76
  AmaGDK.Ads.context.onAdShowReadyStatus += callback;
77
77
  return ad;
78
78
  }
79
+
79
80
  /// <summary>
80
81
  /// The finalize callback that will always trigger to mark an end for the AdShowRoutine
81
82
  ///
82
83
  /// </summary>
84
+ [Obsolete("OnAdResult is obsolete. Please use the onAdResult callback in AmaGDK.Ads.ShowInterstitial(Action<bool> onAdResult) or AmaGDK.Ads.ShowRewardedVideo(Action<bool> onAdResult) instead.")]
83
85
  public static IAdCallback OnAdResult(this IAdCallback ad, Action<bool> callback)
84
86
  {
85
87
  if (!MakeSureAdNotNull(ad)) return null;