com.amanotes.gdk 0.2.52 → 0.2.53

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,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.53 - 2024-03-14]
4
+ - Add FirebaseCrashlyticsHook
5
+ - Fix Change to dev mode
6
+ - Public analytics config
7
+ - Update SDK version tracking
8
+ - Update GDKLocalBuild
9
+
3
10
  ## [0.2.52 - 2024-02-27]
4
11
  - Change post processing order
5
12
  - Remove GDKInstaller after installed
@@ -180,7 +180,7 @@ namespace Amanotes.Editor
180
180
  {
181
181
  if (GUILayout.Button(ObjectNames.NicifyVariableName(extra)))
182
182
  {
183
- var package = $"{Res.PACKAGE_PATH}{extra}";
183
+ var package = $"{Res.EXTRA_PATH}{extra}";
184
184
  AssetDatabase.ImportPackage(package, false);
185
185
  }
186
186
  }
@@ -393,10 +393,14 @@ namespace Amanotes.Editor
393
393
  {
394
394
  string adapterName = FindBestAdapterFor(adapterId);
395
395
  var package = $"{Res.PACKAGE_PATH}{adapterName}";
396
- if (GUILayout.Button(GetGUIContent($"Import {adapterId} Adapter"), GUILayout.Height(24f)))
396
+ EditorGUI.BeginDisabledGroup(!status.sdkInstalled);
397
397
  {
398
- AssetDatabase.ImportPackage(package, false);
398
+ if (GUILayout.Button(GetGUIContent($"Import {adapterId} Adapter"), GUILayout.Height(24f)))
399
+ {
400
+ AssetDatabase.ImportPackage(package, false);
401
+ }
399
402
  }
403
+ EditorGUI.EndDisabledGroup();
400
404
  }
401
405
 
402
406
  }, () =>
@@ -412,7 +416,7 @@ namespace Amanotes.Editor
412
416
  Color c = GUI.color;
413
417
  GUI.color = Color.yellow;
414
418
 
415
- float w = EditorStyles.label.CalcSize(label).x;
419
+ float w = EditorStyles.label.CalcSize(label).x+5f;
416
420
  GUILayout.Label(label, GUILayout.Width(w));
417
421
  GUI.color = c;
418
422
  }
@@ -2,6 +2,9 @@ using UnityEditor;
2
2
  using System.Linq;
3
3
  using System;
4
4
  using System.IO;
5
+ using UnityEditor.Build;
6
+ using UnityEditor.Build.Reporting;
7
+ using UnityEngine;
5
8
 
6
9
  namespace Amanotes.Core
7
10
  {
@@ -148,7 +151,7 @@ namespace Amanotes.Core
148
151
  return true;
149
152
  }
150
153
 
151
- static bool TryGetEnv(string key, out string value)
154
+ internal static bool TryGetEnv(string key, out string value)
152
155
  {
153
156
  value = Environment.GetEnvironmentVariable(key);
154
157
  return !string.IsNullOrEmpty(value);
@@ -309,4 +312,43 @@ namespace Amanotes.Core
309
312
  PlayerSettings.Android.keyaliasPass = keystoreAliasPass;
310
313
  }
311
314
  }
315
+
316
+ public class GDKPreProcessBuild: IPreprocessBuildWithReport
317
+ {
318
+ #if UNITY_2022_1_OR_NEWER
319
+ private static readonly string GRADLE_VERSION = "7.6.1";
320
+ #else
321
+ private static readonly string GRADLE_VERSION = "6.7.1";
322
+ #endif
323
+ private static readonly string GRADLE_ROOT = "/usr/local/gradle";
324
+
325
+ public int callbackOrder
326
+ {
327
+ get { return 0; }
328
+ }
329
+ public void OnPreprocessBuild(BuildReport report)
330
+ {
331
+ if (report.summary.platform == BuildTarget.Android)
332
+ {
333
+ // Change Gradle path when running in headless mode (CI Machine)
334
+ if (Application.isBatchMode)
335
+ {
336
+ EditorPrefs.SetBool("GradleUseEmbedded", false);
337
+
338
+ if (GDKCIBuildCommand.TryGetEnv("GRADLE_PATH", out string envGradlePath))
339
+ {
340
+ EditorPrefs.SetString("GradlePath", envGradlePath);
341
+ Debug.Log("Update gradle path to: " + envGradlePath);
342
+ }
343
+ else
344
+ {
345
+ string gradlePath = GRADLE_ROOT + "/gradle-" + GRADLE_VERSION;
346
+ EditorPrefs.SetString("GradlePath", gradlePath);
347
+ Debug.Log("Update gradle path to: " + gradlePath);
348
+ }
349
+ }
350
+ }
351
+
352
+ }
353
+ }
312
354
  }
@@ -350,8 +350,8 @@ namespace Amanotes.Editor
350
350
  {
351
351
  PlayerSettings.Android.bundleVersionCode = buildNumber;
352
352
  PlayerSettings.Android.buildApkPerCpuArchitecture = splitAPK;
353
- PlayerSettings.Android.targetArchitectures = AndroidArchitecture.All;
354
-
353
+ PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARM64 | AndroidArchitecture.ARMv7;
354
+
355
355
  EditorUserBuildSettings.buildAppBundle = isAAB;
356
356
  EditorUserBuildSettings.exportAsGoogleAndroidProject = false;
357
357
 
@@ -817,6 +817,7 @@ namespace Amanotes.Editor
817
817
  {
818
818
  ab.buildRQ = GDKLocalBuild.BuildRequestTS.Generate(); //ab.runGitPostBuild
819
819
  ab.ProcessBuild();
820
+ GUIUtility.ExitGUI();
820
821
  }
821
822
 
822
823
  if (GUILayout.Button("Stop")) ab.StopBuild();
@@ -1,3 +1,4 @@
1
+ using Amanotes.Core.Internal;
1
2
  using System.Collections.Generic;
2
3
  using UnityEditor;
3
4
  using UnityEngine;
@@ -149,10 +150,67 @@ namespace Amanotes
149
150
  if (productNameStyle == null) Init();
150
151
 
151
152
  DrawProjectInfo();
153
+
154
+ if (EditorApplication.isPlayingOrWillChangePlaymode)
155
+ {
156
+ // EditorGUILayout.HelpBox("Application is Playing!", MessageType.Info);
157
+ DrawRuntimeGUI();
158
+ return;
159
+ }
160
+
152
161
  EditorGUILayout.Space();
153
162
  DrawBigPlayButton();
154
163
  EditorGUILayout.Space();
155
164
  DrawListScenes();
156
165
  }
166
+
167
+
168
+ private readonly List<float> FPS = new List<float>()
169
+ {
170
+ 0, 1, 5, 10, 15, 20, 30, 45, 50, 60, 75, 90, 120, 240, 360, 480, 720, 960, 1000, 1200
171
+ };
172
+
173
+ private readonly List<float> TIMESCALES = new List<float>()
174
+ {
175
+ 0f, 0.1f, 0.2f, 0.5f, 1f, 2f, 5f, 10f
176
+ };
177
+
178
+ void DrawRuntimeGUI()
179
+ {
180
+ float fps = Application.targetFrameRate;
181
+ if (DrawSlider2("Target FPS", ref fps, FPS))
182
+ {
183
+ Application.targetFrameRate = (int)fps;
184
+ }
185
+
186
+ float ts = Time.timeScale;
187
+ if (DrawSlider2("Time Scale", ref ts, TIMESCALES))
188
+ {
189
+ Time.timeScale = ts;
190
+ }
191
+ }
192
+
193
+ bool DrawSlider2(string label, ref float v, List<float> values)
194
+ {
195
+ int idx1 = values.IndexOf(v);
196
+ if (idx1 == -1)
197
+ {
198
+ values.Add(v);
199
+ values.Sort();
200
+ idx1 = values.IndexOf(v);
201
+ }
202
+
203
+ int idx2;
204
+ GUILayout.BeginHorizontal();
205
+ {
206
+ GUILayout.Label(label, GUILayout.Width(100f));
207
+ idx2 = Mathf.RoundToInt(GUILayout.HorizontalSlider(idx1, 0, values.Count - 1));
208
+ GUILayout.Label($"{v}", GUILayout.Width(50f));
209
+ }
210
+ GUILayout.EndHorizontal();
211
+ if (idx2 == idx1) return false;
212
+ v = values[idx2];
213
+ return true;
214
+ }
157
215
  }
158
216
  }
@@ -5,6 +5,11 @@ using System.Linq;
5
5
  using System.Reflection;
6
6
  using System.Xml;
7
7
  using Amanotes.Core.Internal;
8
+ #if !UNITY_2021_1_OR_NEWER
9
+ using UnityEditor;
10
+ using UnityEditor.PackageManager;
11
+ using UnityEditor.PackageManager.Requests;
12
+ #endif
8
13
  using UnityEngine;
9
14
  using static Amanotes.Core.AmaGDK.AdapterID;
10
15
 
@@ -66,9 +71,38 @@ namespace Amanotes.Editor
66
71
  return result;
67
72
  }
68
73
  }
69
-
74
+
70
75
  internal static class ExtractVersion
71
76
  {
77
+ #if !UNITY_2021_1_OR_NEWER
78
+ static ListRequest listRequest;
79
+ const string LIST_REQUEST_KEY = "ListRequestData";
80
+
81
+ [InitializeOnLoadMethod]
82
+ static void Initialize()
83
+ {
84
+ Events.registeredPackages += RegisteredPackages;
85
+ GetRequestList();
86
+ }
87
+
88
+ private static void RegisteredPackages(PackageRegistrationEventArgs obj)
89
+ {
90
+ PlayerPrefs.DeleteKey(LIST_REQUEST_KEY);
91
+ GetRequestList();
92
+ }
93
+
94
+ static void GetRequestList()
95
+ {
96
+ if (PlayerPrefs.HasKey(LIST_REQUEST_KEY))
97
+ {
98
+ listRequest = JsonUtility.FromJson<ListRequest>(PlayerPrefs.GetString(LIST_REQUEST_KEY));
99
+ return;
100
+ }
101
+
102
+ listRequest = Client.List();
103
+ }
104
+ #endif
105
+
72
106
  public static string GDKAdapter(string sdkId)
73
107
  {
74
108
  var version = "";
@@ -94,20 +128,54 @@ namespace Amanotes.Editor
94
128
  }
95
129
  return version.Trim();
96
130
  }
131
+
132
+ static string GetPackageVersion(string packageName)
133
+ {
134
+ #if UNITY_2021_1_OR_NEWER
135
+ foreach (var package in UnityEditor.PackageManager.PackageInfo.GetAllRegisteredPackages())
136
+ {
137
+ if(package.name != packageName) continue;
138
+ return package.version;
139
+ }
140
+
141
+ #else
142
+ if (listRequest == null || !listRequest.IsCompleted) return "";
143
+
144
+ if (listRequest.Status != StatusCode.Success)
145
+ {
146
+ Debug.LogWarning($"Failed to list packages: {listRequest.Error.message}");
147
+ return "";
148
+ }
149
+
150
+ if (!PlayerPrefs.HasKey(LIST_REQUEST_KEY))
151
+ {
152
+ PlayerPrefs.SetString(LIST_REQUEST_KEY, JsonUtility.ToJson(listRequest));
153
+ PlayerPrefs.Save();
154
+ }
155
+
156
+ foreach (var package in listRequest.Result)
157
+ {
158
+ if(package.name != packageName) continue;
159
+
160
+ return package.version;
161
+ }
162
+ #endif
163
+ return "";
164
+ }
97
165
 
98
166
  public static string ThirdParty(string sdkId)
99
167
  {
100
168
  var version = "";
101
169
  switch (sdkId)
102
170
  {
103
- case FIREBASE_ANALYTICS: return FirebaseAnalytics();
104
- case FIREBASE_REMOTE_CONFIG: return FirebaseRemoteConfig();
105
- case APPSFLYER: return AppsFlyer();
106
- case IRONSOURCE: return Ironsource();
107
- case REVENUECAT: return RevenueCat();
108
- default:
109
- Debug.LogWarning($"Unsupported sdkID <{sdkId}>");
110
- break;
171
+ case FIREBASE_ANALYTICS: return FirebaseAnalytics();
172
+ case FIREBASE_REMOTE_CONFIG: return FirebaseRemoteConfig();
173
+ case APPSFLYER: return AppsFlyer();
174
+ case IRONSOURCE: return Ironsource();
175
+ case REVENUECAT: return RevenueCat();
176
+ default:
177
+ Debug.LogWarning($"Unsupported sdkID <{sdkId}>");
178
+ break;
111
179
  }
112
180
  return version;
113
181
  }
@@ -116,7 +184,7 @@ namespace Amanotes.Editor
116
184
  {
117
185
  var version = "";
118
186
  string[] filesFirebase = Directory.GetFiles("Assets", "maven-metadata.xml", SearchOption.AllDirectories);
119
- if (filesFirebase.Length <= 0) return version.Trim();
187
+ if (filesFirebase.Length <= 0) return GetPackageVersion("com.google.firebase.analytics").Trim();
120
188
 
121
189
  for (var i = 0; i < filesFirebase.Length; i++)
122
190
  {
@@ -140,7 +208,7 @@ namespace Amanotes.Editor
140
208
  {
141
209
  var version = "";
142
210
  string[] filesFirebase = Directory.GetFiles("Assets", "maven-metadata.xml", SearchOption.AllDirectories);
143
- if (filesFirebase.Length <= 0) return version.Trim();
211
+ if (filesFirebase.Length <= 0) return GetPackageVersion("com.google.firebase.remote-config").Trim();
144
212
 
145
213
  for (var i = 0; i < filesFirebase.Length; i++)
146
214
  {
@@ -190,7 +258,6 @@ namespace Amanotes.Editor
190
258
  }
191
259
  }
192
260
  }
193
-
194
261
  return version.Trim();
195
262
  }
196
263
 
@@ -213,10 +280,7 @@ namespace Amanotes.Editor
213
280
  string[] files = Directory.GetFiles("Assets", "PurchasesWrapper.java", SearchOption.AllDirectories);
214
281
  var searchString = "PLUGIN_VERSION";
215
282
  var version = "";
216
- if (files.Length < 1)
217
- {
218
- return version;
219
- }
283
+ if (files.Length < 1) return GetPackageVersion("com.revenuecat.purchases-unity").Trim();
220
284
 
221
285
  foreach (string file in files)
222
286
  {
@@ -236,9 +300,16 @@ namespace Amanotes.Editor
236
300
 
237
301
  internal static List<IronSourceSDKAdapter> IronSourceAdapter()
238
302
  {
239
- string[] filesIRadapter = Directory.GetFiles("Assets/IronSource", "IS*AdapterDependencies.xml", SearchOption.AllDirectories);
240
- List<IronSourceSDKAdapter> listAdapter = new List<IronSourceSDKAdapter>();
241
-
303
+ var listAdapter = new List<IronSourceSDKAdapter>();
304
+ const string IRONSOURCE_PATH = "Assets/IronSource";
305
+
306
+ if (!Directory.Exists(IRONSOURCE_PATH))
307
+ {
308
+ return listAdapter;
309
+ }
310
+
311
+ string[] filesIRadapter = Directory.GetFiles(IRONSOURCE_PATH, "IS*AdapterDependencies.xml", SearchOption.AllDirectories);
312
+
242
313
  if (filesIRadapter.Length <= 0) return listAdapter;
243
314
  for (var i = 0; i < filesIRadapter.Length; i++)
244
315
  {
Binary file
Binary file
Binary file
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 2e197f38dc0b2460b9efe8fa5958a370
3
+ DefaultImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
Binary file
Binary file
Binary file
Binary file
@@ -17,6 +17,12 @@ namespace Amanotes.Core
17
17
  public static partial class Analytics
18
18
  {
19
19
  public static bool HasMigrated => localData.migrationLog.count > 0;
20
+
21
+ public static bool enableAnalyticsLog
22
+ {
23
+ set => Config.analytics.showAnalyticsLog = value;
24
+ get => Config.analytics.showAnalyticsLog;
25
+ }
20
26
 
21
27
  public interface IEventParamsBuilder { }
22
28
 
@@ -480,7 +486,7 @@ namespace Amanotes.Core
480
486
  NormalizeKeyString(ref eventName, sb, dryRun);
481
487
  if (reservedEvents.Contains(eventName))
482
488
  sb.AppendLine($" - EventName <{eventName}> is reserved and should not be used");
483
- if (sb.Length > 0 && dryRun) LogWarningOnce($"Warning for event name <{eventName}>:\n{sb}", $"NormalizeEventName<{eventName}>");
489
+ if (sb.Length > 0 && dryRun) LogWarningOnce($"NormalizeEventName <{eventName}> warnings:\n{sb}\n", $"NormalizeEventName<{eventName}>");
484
490
  sbPool.Return(sb);
485
491
  }
486
492
  Profiler.EndSample();
@@ -1042,7 +1048,7 @@ namespace Amanotes.Core.Internal
1042
1048
  [Serializable] public class AnalyticsConfig
1043
1049
  {
1044
1050
  // [Header("----- MODULE CONFIG -----")]
1045
- public bool showAnalyticsLog = true;
1051
+ public bool showAnalyticsLog;
1046
1052
  public bool normalizeEventName = true;
1047
1053
  public bool checkMigrationIntegrity = true;
1048
1054
  public bool migrateAccumulatedCount = true;
package/Runtime/AmaGDK.cs CHANGED
@@ -17,7 +17,7 @@ namespace Amanotes.Core
17
17
  {
18
18
  public partial class AmaGDK : MonoBehaviour
19
19
  {
20
- public const string VERSION = "0.2.52";
20
+ public const string VERSION = "0.2.53";
21
21
 
22
22
  internal static AmaGDK _instance;
23
23
  internal static Status _status = Status.None;
@@ -90,7 +90,7 @@ namespace Amanotes.Core
90
90
  });
91
91
  yield return new WaitUntil(() => hookCompleted);
92
92
  float elapsed = Time.realtimeSinceStartup - stTime;
93
- Log($"[Hook] {nHooks} hooks complete after " + elapsed);
93
+ Log($"[Hook] {nHooks} hooks complete after {elapsed} secs");
94
94
  dispatcher.Dispatch(Event.GDK_HOOK_END);
95
95
  }
96
96
 
@@ -304,10 +304,10 @@ namespace Amanotes.Core
304
304
  public partial class AmaGDK // Switch dev mode
305
305
  {
306
306
  #if UNITY_EDITOR
307
- [ContextMenu("Change Dev Mode")]
307
+ [ContextMenu("Change To Dev Mode")]
308
308
  public void ChangeDevMode()
309
309
  {
310
- string variableName = "GDK_HOME";
310
+ const string variableName = "GDK_HOME";
311
311
  string zshrcPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".zshrc");
312
312
  string zshrcContent;
313
313
 
@@ -341,13 +341,19 @@ namespace Amanotes.Core
341
341
  Debug.LogWarning($"{variableName} environment variable is set but has an empty value in {zshrcPath}.");
342
342
  return;
343
343
  }
344
+
345
+ if (!Directory.Exists(gdkHomeValue))
346
+ {
347
+ Debug.LogWarning($"{variableName} environment variable is set to <{gdkHomeValue}> but the path is not exist!");
348
+ return;
349
+ }
344
350
  }
345
351
 
346
352
  string output = RunShellCommand($"source ~/.zshrc && echo file:${variableName}");
347
353
  output = output.Trim();
348
- UpdateManifest(output);
349
- Debug.Log("AmaGDK changes to dev mode successfully");
350
- UnityEditor.AssetDatabase.Refresh();
354
+ UpdateManifest(output);
355
+
356
+ UnityEditor.AssetDatabase.Refresh(UnityEditor.ImportAssetOptions.ForceUpdate);
351
357
  }
352
358
 
353
359
  private string RunShellCommand(string command)
@@ -368,11 +374,28 @@ namespace Amanotes.Core
368
374
 
369
375
  private void UpdateManifest(string strDesired)
370
376
  {
371
- const string manifestPath = "Packages/manifest.json";
372
- string manifestJson = File.ReadAllText(manifestPath);
377
+ try
378
+ {
379
+ const string manifestPath = "Packages/manifest.json";
380
+ string manifestJson = File.ReadAllText(manifestPath);
373
381
 
374
- manifestJson = Regex.Replace(manifestJson, "\"com\\.amanotes\\.gdk\"\\s*:\\s*\"\\d+\\.\\d+\\.\\d+\"", $"\"com.amanotes.gdk\": \"{strDesired}\"");
375
- File.WriteAllText(manifestPath, manifestJson);
382
+ string pattern = "\"com\\.amanotes\\.gdk\": \"(.*)\"";
383
+ string devModeEntry = $"\"com.amanotes.gdk\": \"{strDesired}\"";
384
+
385
+ manifestJson = Regex.Replace(manifestJson, pattern, devModeEntry);
386
+ File.WriteAllText(manifestPath, manifestJson);
387
+
388
+ if (!File.ReadAllText(manifestPath).Contains(devModeEntry))
389
+ {
390
+ Debug.LogWarning($"AmaGDK changes to dev mode failed. The expected value is: {devModeEntry}");
391
+ return;
392
+ }
393
+ Debug.Log("AmaGDK changes to dev mode successfully");
394
+ }
395
+ catch (Exception e)
396
+ {
397
+ Debug.LogWarning($"AmaGDK changes to dev exception: {e.Message}");
398
+ }
376
399
  }
377
400
  #endif
378
401
  }
@@ -66,6 +66,9 @@ namespace Amanotes.Core.Internal
66
66
 
67
67
  public static class Logging
68
68
  {
69
+ public static Action<string> logNonfatalErrorHook = null;
70
+ private static readonly HashSet<string> nonFatalDict = new HashSet<string>();
71
+
69
72
  public static readonly StringBuilder tmpWarningSB = new StringBuilder();
70
73
  public static readonly HashSet<string> logWarningDict = new HashSet<string>();
71
74
 
@@ -84,6 +87,12 @@ namespace Amanotes.Core.Internal
84
87
  public static void LogError(string message)
85
88
  {
86
89
  if (Config.common.logLevel >= LogLevel.Error) Debug.LogError($"AmaGDK {message}");
90
+ if (logNonfatalErrorHook != null)
91
+ {
92
+ if (nonFatalDict.Contains(message)) return; // LogOnce
93
+ nonFatalDict.Add(message);
94
+ logNonfatalErrorHook(message);
95
+ }
87
96
  }
88
97
  public static void Log(string message)
89
98
  {
@@ -459,7 +459,7 @@ namespace Amanotes.Core.Internal
459
459
  jsonSb.Append("[");
460
460
  var isFirstElement = true;
461
461
 
462
- foreach (var item in list)
462
+ foreach (object item in list)
463
463
  {
464
464
  if (isFirstElement)
465
465
  isFirstElement = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.amanotes.gdk",
3
- "version": "0.2.52",
3
+ "version": "0.2.53",
4
4
  "displayName": "AmaGDK",
5
5
  "description": "Amanotes Game Development Kit",
6
6
  "unity": "2019.4",