com.amanotes.gdk 0.2.51 → 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.
@@ -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
  {
@@ -93,6 +102,27 @@ namespace Amanotes.Core.Internal
93
102
 
94
103
  public static class Forbidden
95
104
  {
105
+ private static bool presetShowAnalyticsLog;
106
+ private static bool presetEnableEventStat;
107
+ private static LogLevel presetLogLevel = LogLevel.Warning;
108
+
109
+ public static void PresetConfig()
110
+ {
111
+ presetLogLevel = Config.common.logLevel;
112
+ Config.common.logLevel = LogLevel.Warning;
113
+ presetShowAnalyticsLog = Config.analytics.showAnalyticsLog;
114
+ Config.analytics.showAnalyticsLog = true;
115
+ presetEnableEventStat = Config.analytics.enableEventStat;
116
+ Config.analytics.enableEventStat = true;
117
+ }
118
+
119
+ public static void ReloadConfig()
120
+ {
121
+ Config.analytics.showAnalyticsLog = presetShowAnalyticsLog;
122
+ Config.analytics.enableEventStat = presetEnableEventStat;
123
+ Config.common.logLevel = presetLogLevel;
124
+ }
125
+
96
126
  public static void DestroyAndReset()
97
127
  {
98
128
  if (_instance != null)
@@ -139,9 +169,12 @@ namespace Amanotes.Core.Internal
139
169
  public static void ClearAnalyticsData()
140
170
  {
141
171
  AnalyticsData analyticsData = localData;
172
+ analyticsData._dirty = true;
142
173
  analyticsData.funnelSignatures.Clear();
143
174
  analyticsData.eventDetails.Clear();
175
+ analyticsData.cachedEventDetails.Clear();
144
176
  analyticsData.migrationLog = new MigrationLog();
177
+ analyticsData.SaveIfDirty();
145
178
  }
146
179
  }
147
180
 
@@ -1,5 +1,6 @@
1
1
  using System;
2
2
  using System.Collections;
3
+ using System.Collections.Concurrent;
3
4
  using System.Collections.Generic;
4
5
  using System.IO;
5
6
  using System.Reflection;
@@ -391,7 +392,6 @@ namespace Amanotes.Core.Internal
391
392
 
392
393
  internal interface IJsonFile { }
393
394
 
394
-
395
395
  internal static class JsonFileExtension
396
396
  {
397
397
  public static T LoadJsonFromFile<T>(this T instance) where T : IJsonFile, new()
@@ -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;
@@ -569,4 +569,30 @@ namespace Amanotes.Core.Internal
569
569
  // public T[] items;
570
570
  //}
571
571
  }
572
+
573
+ internal class Pool<T> where T : new()
574
+ {
575
+ private readonly ConcurrentQueue<T> _pool;
576
+
577
+ public Pool(int initialCapacity)
578
+ {
579
+ _pool = new ConcurrentQueue<T>();
580
+ for (int i = 0; i < initialCapacity; i++)
581
+ {
582
+ _pool.Enqueue(new T());
583
+ }
584
+ }
585
+
586
+ public T Get()
587
+ {
588
+ return _pool.TryDequeue(out var obj) ? obj : new T();
589
+ }
590
+
591
+ public void Return(T obj)
592
+ {
593
+ _pool.Enqueue(obj);
594
+ }
595
+
596
+ public int Count => _pool.Count;
597
+ }
572
598
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.amanotes.gdk",
3
- "version": "0.2.51",
3
+ "version": "0.2.53",
4
4
  "displayName": "AmaGDK",
5
5
  "description": "Amanotes Game Development Kit",
6
6
  "unity": "2019.4",